summaryrefslogtreecommitdiff
path: root/libopie2
authoralwin <alwin>2004-03-02 12:14:15 (UTC)
committer alwin <alwin>2004-03-02 12:14:15 (UTC)
commit0d59c780513da78033f4d9040475dee9db0256d4 (patch) (unidiff)
tree503d320b4aa3daae9982082e7b34e3e2c48bdfb7 /libopie2
parenta0981652d61776d70f25980f035748b21339e946 (diff)
downloadopie-0d59c780513da78033f4d9040475dee9db0256d4.zip
opie-0d59c780513da78033f4d9040475dee9db0256d4.tar.gz
opie-0d59c780513da78033f4d9040475dee9db0256d4.tar.bz2
run the optimize_connect script
the whole cvs is tagged with "before_optimize_connect" if there are problems you can check the diff (but it had compiled and run here)
Diffstat (limited to 'libopie2') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/examples/opieui/osplitter_example/osplitter_mail.cpp4
-rw-r--r--libopie2/examples/opieui/oversatileviewdemo/opieuidemo.cpp2
-rw-r--r--libopie2/examples/opieui/oversatileviewdemo/oversatileviewdemo.cpp20
-rw-r--r--libopie2/opiecore/device/odevice.cpp2
-rw-r--r--libopie2/opiecore/device/odevice_ipaq.cpp2
-rw-r--r--libopie2/opiecore/device/odevice_simpad.cpp2
-rw-r--r--libopie2/opiecore/device/odevice_yopy.cpp4
-rw-r--r--libopie2/opiecore/device/odevice_zaurus.cpp4
-rw-r--r--libopie2/opiecore/oprocess.cpp12
-rw-r--r--libopie2/opiepim/core/ocontactaccess.cpp8
-rw-r--r--libopie2/opiepim/ui/opimmainwindow.cpp8
-rw-r--r--libopie2/opiepim/ui/opimrecurrencewidget.cpp4
-rw-r--r--libopie2/opieui/fileselector/ofiledialog.cpp4
-rw-r--r--libopie2/opieui/fileselector/ofileselector.cpp14
-rw-r--r--libopie2/opieui/ofontselector.cpp8
-rw-r--r--libopie2/opieui/otabwidget.cpp4
-rw-r--r--libopie2/opieui/otimepicker.cpp12
-rw-r--r--libopie2/opieui/oversatileview.cpp40
18 files changed, 77 insertions, 77 deletions
diff --git a/libopie2/examples/opieui/osplitter_example/osplitter_mail.cpp b/libopie2/examples/opieui/osplitter_example/osplitter_mail.cpp
index a75f9dc..789496c 100644
--- a/libopie2/examples/opieui/osplitter_example/osplitter_mail.cpp
+++ b/libopie2/examples/opieui/osplitter_example/osplitter_mail.cpp
@@ -1,79 +1,79 @@
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 8
9#include <opie2/oapplicationfactory.h> 9#include <opie2/oapplicationfactory.h>
10#include "osplitter_mail.h" 10#include "osplitter_mail.h"
11 11
12OPIE_EXPORT_APP( OApplicationFactory<ListViews> ) 12OPIE_EXPORT_APP( OApplicationFactory<ListViews> )
13 13
14class Folder { 14class Folder {
15 int dummy; 15 int dummy;
16}; 16};
17 17
18// ----------------------------------------------------------------- 18// -----------------------------------------------------------------
19 19
20ListViews::ListViews( QWidget* p, const char* name, WFlags fl ) 20ListViews::ListViews( QWidget* p, const char* name, WFlags fl )
21 : QWidget( p, name, fl ) { 21 : QWidget( p, name, fl ) {
22 qApp->installEventFilter( this ); 22 qApp->installEventFilter( this );
23 m_lstFolders.setAutoDelete( true ); 23 m_lstFolders.setAutoDelete( true );
24 QHBoxLayout *lay = new QHBoxLayout(this); 24 QHBoxLayout *lay = new QHBoxLayout(this);
25 25
26 m_splitter = new OSplitter( Horizontal, this, "SPlitter 1" ); 26 m_splitter = new OSplitter( Horizontal, this, "SPlitter 1" );
27 lay->addWidget( m_splitter ); 27 lay->addWidget( m_splitter );
28 connect(m_splitter, SIGNAL(sizeChange(bool, const QSize& ) ), 28 connect(m_splitter, SIGNAL(sizeChange(bool,const QSize&) ),
29 this, SLOT(slotSizeChange(bool, const QSize& ) ) ); 29 this, SLOT(slotSizeChange(bool,const QSize&) ) );
30 30
31 m_overview = new QListView( m_splitter ); 31 m_overview = new QListView( m_splitter );
32 m_overview->header()->setClickEnabled( FALSE ); 32 m_overview->header()->setClickEnabled( FALSE );
33 m_overview->addColumn( tr("Folder") ); 33 m_overview->addColumn( tr("Folder") );
34 m_overview->setMaximumWidth( 200 ); 34 m_overview->setMaximumWidth( 200 );
35 m_splitter->addWidget( m_overview, "zoom", tr("Folder Overview") ); 35 m_splitter->addWidget( m_overview, "zoom", tr("Folder Overview") );
36 m_splitter->setSizeChange( 300 ); 36 m_splitter->setSizeChange( 300 );
37 37
38 /* OSplitter starts with the small mode */ 38 /* OSplitter starts with the small mode */
39 m_messages = 0; 39 m_messages = 0;
40 m_message = m_attach = 0; 40 m_message = m_attach = 0;
41 41
42 splitti = new OSplitter( Vertical, m_splitter, "Splitti2" ); 42 splitti = new OSplitter( Vertical, m_splitter, "Splitti2" );
43 splitti->setSizeChange( 300 ); 43 splitti->setSizeChange( 300 );
44 splitti->setSizePolicy( QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding ) ); 44 splitti->setSizePolicy( QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding ) );
45 45
46 QLabel *lbl = new QLabel(splitti); 46 QLabel *lbl = new QLabel(splitti);
47 lbl->setTextFormat ( Qt::RichText ); 47 lbl->setTextFormat ( Qt::RichText );
48 lbl->setText("<br><br><b>Test Test Test</b><br><br><p>Fooooo hjhh</p>"); 48 lbl->setText("<br><br><b>Test Test Test</b><br><br><p>Fooooo hjhh</p>");
49 49
50 m_messages = new QListView( splitti ); 50 m_messages = new QListView( splitti );
51 m_messages->addColumn(" Messages "); 51 m_messages->addColumn(" Messages ");
52 52
53 folder1 = new QListView( splitti ); 53 folder1 = new QListView( splitti );
54 folder1->addColumn( "Messages 2 " ); 54 folder1->addColumn( "Messages 2 " );
55 55
56 splitti->addWidget(m_messages, "mail", tr("Mails") ); 56 splitti->addWidget(m_messages, "mail", tr("Mails") );
57 splitti->addWidget(folder1, "folder", tr("Folder") ); 57 splitti->addWidget(folder1, "folder", tr("Folder") );
58 splitti->addWidget( lbl, "logo", tr("Label") ); 58 splitti->addWidget( lbl, "logo", tr("Label") );
59 m_message = lbl; 59 m_message = lbl;
60 60
61 m_splitter->addWidget( splitti ); 61 m_splitter->addWidget( splitti );
62 62
63} 63}
64 64
65 65
66ListViews::~ListViews() { 66ListViews::~ListViews() {
67 67
68} 68}
69 69
70 70
71bool ListViews::eventFilter( QObject* obj, QEvent* ev ) { 71bool ListViews::eventFilter( QObject* obj, QEvent* ev ) {
72 if (!obj->isWidgetType() ) 72 if (!obj->isWidgetType() )
73 return false; 73 return false;
74 if ( ev->type() == QEvent::MouseButtonRelease ) { 74 if ( ev->type() == QEvent::MouseButtonRelease ) {
75 qWarning(" name %s, class %s", obj->name(), obj->className() ); 75 qWarning(" name %s, class %s", obj->name(), obj->className() );
76 } 76 }
77 77
78 return false; 78 return false;
79} 79}
diff --git a/libopie2/examples/opieui/oversatileviewdemo/opieuidemo.cpp b/libopie2/examples/opieui/oversatileviewdemo/opieuidemo.cpp
index f62729c..0d8bc9f 100644
--- a/libopie2/examples/opieui/oversatileviewdemo/opieuidemo.cpp
+++ b/libopie2/examples/opieui/oversatileviewdemo/opieuidemo.cpp
@@ -1,205 +1,205 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. 2** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved.
3** 3**
4** This file is part of Opie Environment. 4** This file is part of Opie Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14***********************************************************************/ 14***********************************************************************/
15 15
16// Qt 16// Qt
17 17
18#include <qcolor.h> 18#include <qcolor.h>
19#include <qpopupmenu.h> 19#include <qpopupmenu.h>
20#include <qmenubar.h> 20#include <qmenubar.h>
21#include <qmessagebox.h> 21#include <qmessagebox.h>
22#include <qvbox.h> 22#include <qvbox.h>
23#include <qstring.h> 23#include <qstring.h>
24#include <qstringlist.h> 24#include <qstringlist.h>
25 25
26// Qtopia 26// Qtopia
27 27
28#ifdef QWS 28#ifdef QWS
29#include <qpe/qpeapplication.h> 29#include <qpe/qpeapplication.h>
30#include <qpe/global.h> 30#include <qpe/global.h>
31#endif 31#endif
32 32
33// Opie 33// Opie
34 34
35#ifdef QWS 35#ifdef QWS
36#include <opie2/odevice.h> 36#include <opie2/odevice.h>
37using namespace Opie; 37using namespace Opie;
38#endif 38#endif
39 39
40#include <opie2/ocompletionbox.h> 40#include <opie2/ocompletionbox.h>
41#include <opie2/olineedit.h> 41#include <opie2/olineedit.h>
42#include <opie2/ocombobox.h> 42#include <opie2/ocombobox.h>
43#include <opie2/oeditlistbox.h> 43#include <opie2/oeditlistbox.h>
44#include <opie2/oselector.h> 44#include <opie2/oselector.h>
45#include <opie2/opopupmenu.h> 45#include <opie2/opopupmenu.h>
46 46
47#include <qtabwidget.h> 47#include <qtabwidget.h>
48#include "oversatileviewdemo.h" 48#include "oversatileviewdemo.h"
49 49
50// Local 50// Local
51 51
52#include "opieuidemo.h" 52#include "opieuidemo.h"
53 53
54enum Demos { ocompletionbox, olineedit, ocombobox, oeditlistbox, oselector }; 54enum Demos { ocompletionbox, olineedit, ocombobox, oeditlistbox, oselector };
55 55
56OpieUIDemo::OpieUIDemo( QWidget* parent, const char* name, WFlags fl ) 56OpieUIDemo::OpieUIDemo( QWidget* parent, const char* name, WFlags fl )
57 : QMainWindow( parent, name, fl ) 57 : QMainWindow( parent, name, fl )
58{ 58{
59 59
60 QMenuBar* mbar = this->menuBar(); 60 QMenuBar* mbar = this->menuBar();
61 OPopupMenu* demo = new OPopupMenu( this ); 61 OPopupMenu* demo = new OPopupMenu( this );
62 demo->setTitle( "Title" ); 62 demo->setTitle( "Title" );
63 demo->setItemParameter( demo->insertItem( "OCompletionBox", this, SLOT( demo(int) ) ), ocompletionbox ); 63 demo->setItemParameter( demo->insertItem( "OCompletionBox", this, SLOT( demo(int) ) ), ocompletionbox );
64 demo->setItemParameter( demo->insertItem( "OLineEdit", this, SLOT( demo(int) ) ), olineedit ); 64 demo->setItemParameter( demo->insertItem( "OLineEdit", this, SLOT( demo(int) ) ), olineedit );
65 demo->setItemParameter( demo->insertItem( "OComboBox", this, SLOT( demo(int) ) ), ocombobox ); 65 demo->setItemParameter( demo->insertItem( "OComboBox", this, SLOT( demo(int) ) ), ocombobox );
66 demo->setItemParameter( demo->insertItem( "OEditListBox", this, SLOT( demo(int) ) ), oeditlistbox ); 66 demo->setItemParameter( demo->insertItem( "OEditListBox", this, SLOT( demo(int) ) ), oeditlistbox );
67 demo->setItemParameter( demo->insertItem( "OSelector", this, SLOT( demo(int) ) ), oselector ); 67 demo->setItemParameter( demo->insertItem( "OSelector", this, SLOT( demo(int) ) ), oselector );
68 mbar->insertItem( "Demonstrate", demo ); 68 mbar->insertItem( "Demonstrate", demo );
69 69
70 build(); 70 build();
71 71
72} 72}
73 73
74OpieUIDemo::~OpieUIDemo() 74OpieUIDemo::~OpieUIDemo()
75{ 75{
76} 76}
77 77
78void OpieUIDemo::build() 78void OpieUIDemo::build()
79{ 79{
80 main = new QTabWidget( this, "tabwidget" ); 80 main = new QTabWidget( this, "tabwidget" );
81 setCentralWidget( main ); 81 setCentralWidget( main );
82 main->show(); 82 main->show();
83 83
84 main->addTab( new OVersatileViewDemo( main ), "VersatileView" ); 84 main->addTab( new OVersatileViewDemo( main ), "VersatileView" );
85} 85}
86 86
87 87
88void OpieUIDemo::demo( int d ) 88void OpieUIDemo::demo( int d )
89{ 89{
90 switch (d) 90 switch (d)
91 { 91 {
92 case ocompletionbox: demoOCompletionBox(); break; 92 case ocompletionbox: demoOCompletionBox(); break;
93 case olineedit: demoOLineEdit(); break; 93 case olineedit: demoOLineEdit(); break;
94 case ocombobox: demoOComboBox(); break; 94 case ocombobox: demoOComboBox(); break;
95 case oeditlistbox: demoOEditListBox(); break; 95 case oeditlistbox: demoOEditListBox(); break;
96 case oselector: demoOSelector(); break; 96 case oselector: demoOSelector(); break;
97 97
98 } 98 }
99 99
100} 100}
101 101
102void OpieUIDemo::demoOCompletionBox() 102void OpieUIDemo::demoOCompletionBox()
103{ 103{
104 qDebug( "ocompletionbox" ); 104 qDebug( "ocompletionbox" );
105 105
106 OCompletionBox* box = new OCompletionBox( 0 ); 106 OCompletionBox* box = new OCompletionBox( 0 );
107 box->insertItem( "This CompletionBox" ); 107 box->insertItem( "This CompletionBox" );
108 box->insertItem( "Says 'Hello World'" ); 108 box->insertItem( "Says 'Hello World'" );
109 box->insertItem( "Here are some" ); 109 box->insertItem( "Here are some" );
110 box->insertItem( "Additional Items" ); 110 box->insertItem( "Additional Items" );
111 box->insertItem( "Complete Completion Box" ); 111 box->insertItem( "Complete Completion Box" );
112 112
113 connect( box, SIGNAL( activated( const QString& ) ), this, SLOT( messageBox( const QString& ) ) ); 113 connect( box, SIGNAL( activated(const QString&) ), this, SLOT( messageBox(const QString&) ) );
114 box->popup(); 114 box->popup();
115 115
116} 116}
117 117
118void OpieUIDemo::demoOLineEdit() 118void OpieUIDemo::demoOLineEdit()
119{ 119{
120 qDebug( "olineedit" ); 120 qDebug( "olineedit" );
121 121
122 OLineEdit *edit = new OLineEdit( 0, "lineedit" ); 122 OLineEdit *edit = new OLineEdit( 0, "lineedit" );
123 123
124 edit->setCompletionMode( OGlobalSettings::CompletionPopup ); 124 edit->setCompletionMode( OGlobalSettings::CompletionPopup );
125 OCompletion* comp = edit->completionObject(); 125 OCompletion* comp = edit->completionObject();
126 126
127 QStringList list; 127 QStringList list;
128 list << "mickeyl@handhelds.org"; 128 list << "mickeyl@handhelds.org";
129 list << "mickey@tm.informatik.uni-frankfurt.de"; 129 list << "mickey@tm.informatik.uni-frankfurt.de";
130 list << "mickey@vanille.de"; 130 list << "mickey@vanille.de";
131 131
132 comp->setItems( list ); 132 comp->setItems( list );
133 133
134 edit->show(); 134 edit->show();
135 135
136} 136}
137 137
138void OpieUIDemo::demoOComboBox() 138void OpieUIDemo::demoOComboBox()
139{ 139{
140 qDebug( "ocombobox" ); 140 qDebug( "ocombobox" );
141 141
142 OComboBox *combo = new OComboBox( true, 0, "combobox" ); 142 OComboBox *combo = new OComboBox( true, 0, "combobox" );
143 143
144 combo->setCompletionMode( OGlobalSettings::CompletionPopup ); 144 combo->setCompletionMode( OGlobalSettings::CompletionPopup );
145 OCompletion* comp = combo->completionObject(); 145 OCompletion* comp = combo->completionObject();
146 146
147 QStringList ilist; 147 QStringList ilist;
148 ilist << "kergoth@handhelds.org"; 148 ilist << "kergoth@handhelds.org";
149 ilist << "harlekin@handhelds.org"; 149 ilist << "harlekin@handhelds.org";
150 ilist << "groucho@handhelds.org"; 150 ilist << "groucho@handhelds.org";
151 combo->insertStringList( ilist ); 151 combo->insertStringList( ilist );
152 152
153 QStringList clist; 153 QStringList clist;
154 clist << "mickeyl@handhelds.org"; 154 clist << "mickeyl@handhelds.org";
155 clist << "mickey@tm.informatik.uni-frankfurt.de"; 155 clist << "mickey@tm.informatik.uni-frankfurt.de";
156 clist << "mickey@vanille.de"; 156 clist << "mickey@vanille.de";
157 comp->setItems( clist ); 157 comp->setItems( clist );
158 158
159 combo->show(); 159 combo->show();
160 160
161} 161}
162 162
163void OpieUIDemo::demoOEditListBox() 163void OpieUIDemo::demoOEditListBox()
164{ 164{
165 qDebug( "oeditlistbox" ); 165 qDebug( "oeditlistbox" );
166 166
167 OEditListBox* edit = new OEditListBox( "OEditListBox", 0, "editlistbox" ); 167 OEditListBox* edit = new OEditListBox( "OEditListBox", 0, "editlistbox" );
168 168
169 edit->lineEdit()->setCompletionMode( OGlobalSettings::CompletionPopup ); 169 edit->lineEdit()->setCompletionMode( OGlobalSettings::CompletionPopup );
170 OCompletion* comp = edit->lineEdit()->completionObject(); 170 OCompletion* comp = edit->lineEdit()->completionObject();
171 QStringList clist; 171 QStringList clist;
172 clist << "Completion everywhere"; 172 clist << "Completion everywhere";
173 clist << "Cool Completion everywhere"; 173 clist << "Cool Completion everywhere";
174 clist << "History History History"; 174 clist << "History History History";
175 comp->setItems( clist ); 175 comp->setItems( clist );
176 176
177 QStringList list; 177 QStringList list;
178 list << "kergoth@handhelds.org"; 178 list << "kergoth@handhelds.org";
179 list << "harlekin@handhelds.org"; 179 list << "harlekin@handhelds.org";
180 list << "groucho@handhelds.org"; 180 list << "groucho@handhelds.org";
181 list << "mickeyl@handhelds.org"; 181 list << "mickeyl@handhelds.org";
182 edit->insertStringList( list ); 182 edit->insertStringList( list );
183 183
184 edit->show(); 184 edit->show();
185 185
186} 186}
187 187
188void OpieUIDemo::demoOSelector() 188void OpieUIDemo::demoOSelector()
189{ 189{
190 qDebug( "oselector" ); 190 qDebug( "oselector" );
191 191
192 OHSSelector* sel = new OHSSelector( 0, "gradientselector" ); 192 OHSSelector* sel = new OHSSelector( 0, "gradientselector" );
193 //#sel->resize( QSize( 200, 30 ) ); 193 //#sel->resize( QSize( 200, 30 ) );
194 //#sel->setColors( QColor( 90, 190, 60 ), QColor( 200, 55, 255 ) ); 194 //#sel->setColors( QColor( 90, 190, 60 ), QColor( 200, 55, 255 ) );
195 //#sel->setText( "Dark", "Light" ); 195 //#sel->setText( "Dark", "Light" );
196 196
197 sel->show(); 197 sel->show();
198} 198}
199 199
200void OpieUIDemo::messageBox( const QString& text ) 200void OpieUIDemo::messageBox( const QString& text )
201{ 201{
202 QString info; 202 QString info;
203 info = "You have selected '" + text + "'"; 203 info = "You have selected '" + text + "'";
204 QMessageBox::information( this, "OpieUIDemo", info ); 204 QMessageBox::information( this, "OpieUIDemo", info );
205} 205}
diff --git a/libopie2/examples/opieui/oversatileviewdemo/oversatileviewdemo.cpp b/libopie2/examples/opieui/oversatileviewdemo/oversatileviewdemo.cpp
index cf1e443..9db4e62 100644
--- a/libopie2/examples/opieui/oversatileviewdemo/oversatileviewdemo.cpp
+++ b/libopie2/examples/opieui/oversatileviewdemo/oversatileviewdemo.cpp
@@ -1,158 +1,158 @@
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) 2003 Michael 'Mickey' Lauer 4              Copyright (C) 2003 Michael 'Mickey' Lauer
5 <mickey@tm.informatik.uni-frankfurt.de> 5 <mickey@tm.informatik.uni-frankfurt.de>
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 "oversatileviewdemo.h" 33#include "oversatileviewdemo.h"
34#include <opie2/oversatileview.h> 34#include <opie2/oversatileview.h>
35#include <opie2/oversatileviewitem.h> 35#include <opie2/oversatileviewitem.h>
36 36
37#include <qstring.h> 37#include <qstring.h>
38#include <qpixmap.h> 38#include <qpixmap.h>
39#include <qlistview.h> 39#include <qlistview.h>
40 40
41OVersatileViewDemo::OVersatileViewDemo( QWidget* parent, const char* name, WFlags f ) 41OVersatileViewDemo::OVersatileViewDemo( QWidget* parent, const char* name, WFlags f )
42 :QVBox( parent, name, f ) 42 :QVBox( parent, name, f )
43{ 43{
44 vv = new OVersatileView( this ); 44 vv = new OVersatileView( this );
45 45
46 vv->addColumn( "First" ); 46 vv->addColumn( "First" );
47 vv->addColumn( "2nd" ); 47 vv->addColumn( "2nd" );
48 vv->addColumn( "IIIrd" ); 48 vv->addColumn( "IIIrd" );
49 49
50 QString counter; 50 QString counter;
51 51
52 QPixmap leaf( "leaf.png" ); 52 QPixmap leaf( "leaf.png" );
53 QPixmap opened( "folder_opened.png" ); 53 QPixmap opened( "folder_opened.png" );
54 QPixmap closed( "folder_closed.png" ); 54 QPixmap closed( "folder_closed.png" );
55 55
56 QPixmap leaf32( "leaf32.png" ); 56 QPixmap leaf32( "leaf32.png" );
57 QPixmap opened32( "folder_opened32.png" ); 57 QPixmap opened32( "folder_opened32.png" );
58 QPixmap closed32( "folder_closed32.png" ); 58 QPixmap closed32( "folder_closed32.png" );
59 59
60 vv->setDefaultPixmaps( OVersatileView::Tree, leaf, opened, closed ); 60 vv->setDefaultPixmaps( OVersatileView::Tree, leaf, opened, closed );
61 vv->setDefaultPixmaps( OVersatileView::Icons, leaf32, opened32, closed32 ); 61 vv->setDefaultPixmaps( OVersatileView::Icons, leaf32, opened32, closed32 );
62 62
63 OVersatileViewItem* item; 63 OVersatileViewItem* item;
64 OVersatileViewItem* item2; 64 OVersatileViewItem* item2;
65 65
66 for ( int i = 0; i < 5; ++i ) 66 for ( int i = 0; i < 5; ++i )
67 { 67 {
68 counter.sprintf( "%d", i ); 68 counter.sprintf( "%d", i );
69 item = new OVersatileViewItem( vv, "Item", "Text", "Some more", counter ); 69 item = new OVersatileViewItem( vv, "Item", "Text", "Some more", counter );
70 item->setRenameEnabled( true ); 70 item->setRenameEnabled( true );
71 item2 = new OVersatileViewItem( item, "OSubitem", "123", "...", counter ); 71 item2 = new OVersatileViewItem( item, "OSubitem", "123", "...", counter );
72 item2->setRenameEnabled( true ); 72 item2->setRenameEnabled( true );
73 73
74 } 74 }
75 75
76 connect( vv, SIGNAL( selectionChanged() ), this, SLOT( selectionChanged() ) ); 76 connect( vv, SIGNAL( selectionChanged() ), this, SLOT( selectionChanged() ) );
77 connect( vv, SIGNAL( selectionChanged( OVersatileViewItem * ) ), this, SLOT( selectionChanged( OVersatileViewItem * ) ) ); 77 connect( vv, SIGNAL( selectionChanged(OVersatileViewItem*) ), this, SLOT( selectionChanged(OVersatileViewItem*) ) );
78 connect( vv, SIGNAL( currentChanged( OVersatileViewItem * ) ), this, SLOT( currentChanged( OVersatileViewItem * ) ) ); 78 connect( vv, SIGNAL( currentChanged(OVersatileViewItem*) ), this, SLOT( currentChanged(OVersatileViewItem*) ) );
79 connect( vv, SIGNAL( clicked( OVersatileViewItem * ) ), this, SLOT( clicked( OVersatileViewItem * ) ) ); 79 connect( vv, SIGNAL( clicked(OVersatileViewItem*) ), this, SLOT( clicked(OVersatileViewItem*) ) );
80 connect( vv, SIGNAL( pressed( OVersatileViewItem * ) ), this, SLOT( pressed( OVersatileViewItem * ) ) ); 80 connect( vv, SIGNAL( pressed(OVersatileViewItem*) ), this, SLOT( pressed(OVersatileViewItem*) ) );
81 81
82 connect( vv, SIGNAL( doubleClicked( OVersatileViewItem * ) ), this, SLOT( doubleClicked( OVersatileViewItem * ) ) ); 82 connect( vv, SIGNAL( doubleClicked(OVersatileViewItem*) ), this, SLOT( doubleClicked(OVersatileViewItem*) ) );
83 connect( vv, SIGNAL( returnPressed( OVersatileViewItem * ) ), this, SLOT( returnPressed( OVersatileViewItem * ) ) ); 83 connect( vv, SIGNAL( returnPressed(OVersatileViewItem*) ), this, SLOT( returnPressed(OVersatileViewItem*) ) );
84 84
85 connect( vv, SIGNAL( onItem( OVersatileViewItem * ) ), this, SLOT( onItem( OVersatileViewItem * ) ) ); 85 connect( vv, SIGNAL( onItem(OVersatileViewItem*) ), this, SLOT( onItem(OVersatileViewItem*) ) );
86 connect( vv, SIGNAL( onViewport() ), this, SLOT( onViewport() ) ); 86 connect( vv, SIGNAL( onViewport() ), this, SLOT( onViewport() ) );
87 87
88 connect( vv, SIGNAL( expanded( OVersatileViewItem * ) ), this, SLOT( expanded( OVersatileViewItem * ) ) ); 88 connect( vv, SIGNAL( expanded(OVersatileViewItem*) ), this, SLOT( expanded(OVersatileViewItem*) ) );
89 connect( vv, SIGNAL( collapsed( OVersatileViewItem * ) ), this, SLOT( collapsed( OVersatileViewItem * ) ) ); 89 connect( vv, SIGNAL( collapsed(OVersatileViewItem*) ), this, SLOT( collapsed(OVersatileViewItem*) ) );
90 90
91 connect( vv, SIGNAL( moved() ), this, SLOT( moved() ) ); 91 connect( vv, SIGNAL( moved() ), this, SLOT( moved() ) );
92 92
93 connect( vv, SIGNAL( contextMenuRequested( OVersatileViewItem *, const QPoint&, int ) ), this, SLOT( contextMenuRequested( OVersatileViewItem *, const QPoint&, int ) ) ); 93 connect( vv, SIGNAL( contextMenuRequested(OVersatileViewItem*,const QPoint&,int) ), this, SLOT( contextMenuRequested(OVersatileViewItem*,const QPoint&,int) ) );
94 94
95} 95}
96 96
97OVersatileViewDemo::~OVersatileViewDemo() 97OVersatileViewDemo::~OVersatileViewDemo()
98{ 98{
99} 99}
100 100
101void OVersatileViewDemo::selectionChanged() 101void OVersatileViewDemo::selectionChanged()
102{ 102{
103 qDebug( "received signal selectionChanged()" ); 103 qDebug( "received signal selectionChanged()" );
104} 104}
105void OVersatileViewDemo::selectionChanged( OVersatileViewItem * item ) 105void OVersatileViewDemo::selectionChanged( OVersatileViewItem * item )
106{ 106{
107 qDebug( "received signal selectionChanged(OVersatileViewItem*)" ); 107 qDebug( "received signal selectionChanged(OVersatileViewItem*)" );
108} 108}
109void OVersatileViewDemo::currentChanged( OVersatileViewItem * item ) 109void OVersatileViewDemo::currentChanged( OVersatileViewItem * item )
110{ 110{
111 qDebug( "received signal currentChanged( OVersatileViewItem * )" ); 111 qDebug( "received signal currentChanged( OVersatileViewItem * )" );
112} 112}
113void OVersatileViewDemo::clicked( OVersatileViewItem * item ) 113void OVersatileViewDemo::clicked( OVersatileViewItem * item )
114{ 114{
115 qDebug( "received signal clicked( OVersatileViewItem * )" ); 115 qDebug( "received signal clicked( OVersatileViewItem * )" );
116} 116}
117void OVersatileViewDemo::pressed( OVersatileViewItem * item ) 117void OVersatileViewDemo::pressed( OVersatileViewItem * item )
118{ 118{
119 qDebug( "received signal pressed( OVersatileViewItem * )" ); 119 qDebug( "received signal pressed( OVersatileViewItem * )" );
120} 120}
121 121
122void OVersatileViewDemo::doubleClicked( OVersatileViewItem *item ) 122void OVersatileViewDemo::doubleClicked( OVersatileViewItem *item )
123{ 123{
124 qDebug( "received signal doubleClicked( OVersatileViewItem *item )" ); 124 qDebug( "received signal doubleClicked( OVersatileViewItem *item )" );
125} 125}
126void OVersatileViewDemo::returnPressed( OVersatileViewItem *item ) 126void OVersatileViewDemo::returnPressed( OVersatileViewItem *item )
127{ 127{
128 qDebug( "received signal returnPressed( OVersatileViewItem *item )" ); 128 qDebug( "received signal returnPressed( OVersatileViewItem *item )" );
129} 129}
130 130
131void OVersatileViewDemo::onItem( OVersatileViewItem *item ) 131void OVersatileViewDemo::onItem( OVersatileViewItem *item )
132{ 132{
133 qDebug( "received signal onItem( OVersatileViewItem *item )" ); 133 qDebug( "received signal onItem( OVersatileViewItem *item )" );
134} 134}
135void OVersatileViewDemo::onViewport() 135void OVersatileViewDemo::onViewport()
136{ 136{
137 qDebug( "received signal onViewport()" ); 137 qDebug( "received signal onViewport()" );
138} 138}
139 139
140void OVersatileViewDemo::expanded( OVersatileViewItem *item ) 140void OVersatileViewDemo::expanded( OVersatileViewItem *item )
141{ 141{
142 qDebug( "received signal expanded( OVersatileViewItem *item )" ); 142 qDebug( "received signal expanded( OVersatileViewItem *item )" );
143} 143}
144 144
145void OVersatileViewDemo::collapsed( OVersatileViewItem *item ) 145void OVersatileViewDemo::collapsed( OVersatileViewItem *item )
146{ 146{
147 qDebug( "received signal collapsed( OVersatileViewItem *item )" ); 147 qDebug( "received signal collapsed( OVersatileViewItem *item )" );
148} 148}
149 149
150void OVersatileViewDemo::moved() 150void OVersatileViewDemo::moved()
151{ 151{
152 qDebug( "received signal moved( OVersatileViewItem *item )" ); 152 qDebug( "received signal moved( OVersatileViewItem *item )" );
153} 153}
154 154
155void OVersatileViewDemo::contextMenuRequested( OVersatileViewItem *item, const QPoint& pos, int col ) 155void OVersatileViewDemo::contextMenuRequested( OVersatileViewItem *item, const QPoint& pos, int col )
156{ 156{
157 qDebug( "received signal contextMenuRequested( OVersatileViewItem *item )" ); 157 qDebug( "received signal contextMenuRequested( OVersatileViewItem *item )" );
158} 158}
diff --git a/libopie2/opiecore/device/odevice.cpp b/libopie2/opiecore/device/odevice.cpp
index b8d48fe..27b0e53 100644
--- a/libopie2/opiecore/device/odevice.cpp
+++ b/libopie2/opiecore/device/odevice.cpp
@@ -1,340 +1,340 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) The Opie Team <opie-devel@handhelds.org> 3 Copyright (C) The Opie Team <opie-devel@handhelds.org>
4 =. 4 =.
5 .=l. 5 .=l.
6 .>+-= 6 .>+-=
7_;:, .> :=|. This program is free software; you can 7_;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under 8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11- . .-<_> .<> Foundation; either version 2 of the License, 11- . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_. 13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 20++= -. .` .: details.
21: = ...= . :.=- 21: = ...= . :.=-
22-. .:....=;==+<; You should have received a copy of the GNU 22-. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29 29
30#include "odevice_ipaq.h" 30#include "odevice_ipaq.h"
31#include "odevice_jornada.h" 31#include "odevice_jornada.h"
32#include "odevice_ramses.h" 32#include "odevice_ramses.h"
33#include "odevice_simpad.h" 33#include "odevice_simpad.h"
34#include "odevice_yopy.h" 34#include "odevice_yopy.h"
35#include "odevice_zaurus.h" 35#include "odevice_zaurus.h"
36 36
37/* QT */ 37/* QT */
38#include <qapplication.h> 38#include <qapplication.h>
39#include <qfile.h> 39#include <qfile.h>
40#include <qtextstream.h> 40#include <qtextstream.h>
41#include <qwindowsystem_qws.h> 41#include <qwindowsystem_qws.h>
42 42
43/* OPIE */ 43/* OPIE */
44#include <qpe/config.h> 44#include <qpe/config.h>
45#include <qpe/resource.h> 45#include <qpe/resource.h>
46#include <qpe/sound.h> 46#include <qpe/sound.h>
47#include <qpe/qcopenvelope_qws.h> 47#include <qpe/qcopenvelope_qws.h>
48 48
49/* STD */ 49/* STD */
50#include <fcntl.h> 50#include <fcntl.h>
51#include <math.h> 51#include <math.h>
52#include <stdlib.h> 52#include <stdlib.h>
53#include <signal.h> 53#include <signal.h>
54#include <sys/ioctl.h> 54#include <sys/ioctl.h>
55#include <sys/time.h> 55#include <sys/time.h>
56#include <unistd.h> 56#include <unistd.h>
57#ifndef QT_NO_SOUND 57#ifndef QT_NO_SOUND
58#include <linux/soundcard.h> 58#include <linux/soundcard.h>
59#endif 59#endif
60 60
61const char* PATH_PROC_CPUINFO = "/proc/cpuinfo"; 61const char* PATH_PROC_CPUINFO = "/proc/cpuinfo";
62 62
63using namespace Opie; 63using namespace Opie;
64 64
65ODevice *ODevice::inst() 65ODevice *ODevice::inst()
66{ 66{
67 static ODevice *dev = 0; 67 static ODevice *dev = 0;
68 68
69 // rewrite this to only use /proc/cpuinfo or so 69 // rewrite this to only use /proc/cpuinfo or so
70 70
71 if ( !dev ) 71 if ( !dev )
72 { 72 {
73 QFile f( PATH_PROC_CPUINFO ); 73 QFile f( PATH_PROC_CPUINFO );
74 if ( f.open( IO_ReadOnly ) ) 74 if ( f.open( IO_ReadOnly ) )
75 { 75 {
76 QTextStream s( &f ); 76 QTextStream s( &f );
77 while ( !s.atEnd() ) 77 while ( !s.atEnd() )
78 { 78 {
79 QString line; 79 QString line;
80 line = s.readLine(); 80 line = s.readLine();
81 if ( line.startsWith( "Hardware" ) ) 81 if ( line.startsWith( "Hardware" ) )
82 { 82 {
83 qDebug( "ODevice() - found '%s'", (const char*) line ); 83 qDebug( "ODevice() - found '%s'", (const char*) line );
84 if ( line.contains( "sharp", false ) ) dev = new Zaurus(); 84 if ( line.contains( "sharp", false ) ) dev = new Zaurus();
85 else if ( line.contains( "ipaq", false ) ) dev = new iPAQ(); 85 else if ( line.contains( "ipaq", false ) ) dev = new iPAQ();
86 else if ( line.contains( "simpad", false ) ) dev = new SIMpad(); 86 else if ( line.contains( "simpad", false ) ) dev = new SIMpad();
87 else if ( line.contains( "jornada", false ) ) dev = new Jornada(); 87 else if ( line.contains( "jornada", false ) ) dev = new Jornada();
88 else if ( line.contains( "ramses", false ) ) dev = new Ramses(); 88 else if ( line.contains( "ramses", false ) ) dev = new Ramses();
89 else qWarning( "ODevice() - unknown hardware - using default." ); 89 else qWarning( "ODevice() - unknown hardware - using default." );
90 break; 90 break;
91 } 91 }
92 } 92 }
93 } 93 }
94 else 94 else
95 { 95 {
96 qWarning( "ODevice() - can't open '%s' - unknown hardware - using default." ); 96 qWarning( "ODevice() - can't open '%s' - unknown hardware - using default." );
97 } 97 }
98 if ( !dev ) dev = new ODevice(); 98 if ( !dev ) dev = new ODevice();
99 dev->init(); 99 dev->init();
100 } 100 }
101 return dev; 101 return dev;
102} 102}
103 103
104ODevice::ODevice() 104ODevice::ODevice()
105{ 105{
106 d = new ODeviceData; 106 d = new ODeviceData;
107 107
108 d->m_modelstr = "Unknown"; 108 d->m_modelstr = "Unknown";
109 d->m_model = Model_Unknown; 109 d->m_model = Model_Unknown;
110 d->m_vendorstr = "Unknown"; 110 d->m_vendorstr = "Unknown";
111 d->m_vendor = Vendor_Unknown; 111 d->m_vendor = Vendor_Unknown;
112 d->m_systemstr = "Unknown"; 112 d->m_systemstr = "Unknown";
113 d->m_system = System_Unknown; 113 d->m_system = System_Unknown;
114 d->m_sysverstr = "0.0"; 114 d->m_sysverstr = "0.0";
115 d->m_rotation = Rot0; 115 d->m_rotation = Rot0;
116 d->m_direction = CW; 116 d->m_direction = CW;
117 117
118 d->m_holdtime = 1000; // 1000ms 118 d->m_holdtime = 1000; // 1000ms
119 d->m_buttons = 0; 119 d->m_buttons = 0;
120 d->m_cpu_frequencies = new QStrList; 120 d->m_cpu_frequencies = new QStrList;
121} 121}
122 122
123void ODevice::systemMessage ( const QCString &msg, const QByteArray & ) 123void ODevice::systemMessage ( const QCString &msg, const QByteArray & )
124{ 124{
125 if ( msg == "deviceButtonMappingChanged()" ) { 125 if ( msg == "deviceButtonMappingChanged()" ) {
126 reloadButtonMapping(); 126 reloadButtonMapping();
127 } 127 }
128} 128}
129 129
130void ODevice::init() 130void ODevice::init()
131{ 131{
132} 132}
133 133
134/** 134/**
135* This method initialises the button mapping 135* This method initialises the button mapping
136*/ 136*/
137void ODevice::initButtons() 137void ODevice::initButtons()
138{ 138{
139 if ( d->m_buttons ) 139 if ( d->m_buttons )
140 return; 140 return;
141 141
142 qDebug ( "init Buttons" ); 142 qDebug ( "init Buttons" );
143 d->m_buttons = new QValueList <ODeviceButton>; 143 d->m_buttons = new QValueList <ODeviceButton>;
144 144
145 reloadButtonMapping(); 145 reloadButtonMapping();
146 146
147 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 147 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
148 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); 148 connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&)));
149} 149}
150 150
151ODevice::~ODevice() 151ODevice::~ODevice()
152{ 152{
153// we leak m_devicebuttons and m_cpu_frequency 153// we leak m_devicebuttons and m_cpu_frequency
154// but it's a singleton and it is not so importantant 154// but it's a singleton and it is not so importantant
155// -zecke 155// -zecke
156 delete d; 156 delete d;
157} 157}
158 158
159bool ODevice::setSoftSuspend ( bool /*soft*/ ) 159bool ODevice::setSoftSuspend ( bool /*soft*/ )
160{ 160{
161 return false; 161 return false;
162} 162}
163 163
164//#include <linux/apm_bios.h> 164//#include <linux/apm_bios.h>
165 165
166#define APM_IOC_SUSPEND OD_IO( 'A', 2 ) 166#define APM_IOC_SUSPEND OD_IO( 'A', 2 )
167 167
168/** 168/**
169* This method will try to suspend the device 169* This method will try to suspend the device
170* It only works if the user is the QWS Server and the apm application 170* It only works if the user is the QWS Server and the apm application
171* is installed. 171* is installed.
172* It tries to suspend and then waits some time cause some distributions 172* It tries to suspend and then waits some time cause some distributions
173* do have asynchronus apm implementations. 173* do have asynchronus apm implementations.
174* This method will either fail and return false or it'll suspend the 174* This method will either fail and return false or it'll suspend the
175* device and return once the device got woken up 175* device and return once the device got woken up
176* 176*
177* @return if the device got suspended 177* @return if the device got suspended
178*/ 178*/
179bool ODevice::suspend() 179bool ODevice::suspend()
180{ 180{
181 qDebug("ODevice::suspend"); 181 qDebug("ODevice::suspend");
182 if ( !isQWS( ) ) // only qwsserver is allowed to suspend 182 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
183 return false; 183 return false;
184 184
185 if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices 185 if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices
186 return false; 186 return false;
187 187
188 bool res = false; 188 bool res = false;
189 ODevice::sendSuspendmsg(); 189 ODevice::sendSuspendmsg();
190 190
191 struct timeval tvs, tvn; 191 struct timeval tvs, tvn;
192 ::gettimeofday ( &tvs, 0 ); 192 ::gettimeofday ( &tvs, 0 );
193 193
194 ::sync(); // flush fs caches 194 ::sync(); // flush fs caches
195 res = ( ::system ( "apm --suspend" ) == 0 ); 195 res = ( ::system ( "apm --suspend" ) == 0 );
196 196
197 // This is needed because the iPAQ apm implementation is asynchronous and we 197 // This is needed because the iPAQ apm implementation is asynchronous and we
198 // can not be sure when exactly the device is really suspended 198 // can not be sure when exactly the device is really suspended
199 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. 199 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists.
200 200
201 if ( res ) { 201 if ( res ) {
202 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed 202 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed
203 ::usleep ( 200 * 1000 ); 203 ::usleep ( 200 * 1000 );
204 ::gettimeofday ( &tvn, 0 ); 204 ::gettimeofday ( &tvn, 0 );
205 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); 205 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 );
206 } 206 }
207 207
208 return res; 208 return res;
209} 209}
210 210
211//#include <linux/fb.h> better not rely on kernel headers in userspace ... 211//#include <linux/fb.h> better not rely on kernel headers in userspace ...
212 212
213#define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 213#define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611
214 214
215/* VESA Blanking Levels */ 215/* VESA Blanking Levels */
216#define VESA_NO_BLANKING 0 216#define VESA_NO_BLANKING 0
217#define VESA_VSYNC_SUSPEND 1 217#define VESA_VSYNC_SUSPEND 1
218#define VESA_HSYNC_SUSPEND 2 218#define VESA_HSYNC_SUSPEND 2
219#define VESA_POWERDOWN 3 219#define VESA_POWERDOWN 3
220 220
221/** 221/**
222* This sets the display on or off 222* This sets the display on or off
223*/ 223*/
224bool ODevice::setDisplayStatus ( bool on ) 224bool ODevice::setDisplayStatus ( bool on )
225{ 225{
226 qDebug("ODevice::setDisplayStatus(%d)", on); 226 qDebug("ODevice::setDisplayStatus(%d)", on);
227 227
228 if ( d->m_model == Model_Unknown ) 228 if ( d->m_model == Model_Unknown )
229 return false; 229 return false;
230 230
231 bool res = false; 231 bool res = false;
232 int fd; 232 int fd;
233 233
234 if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { 234 if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) {
235 res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); 235 res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 );
236 ::close ( fd ); 236 ::close ( fd );
237 } 237 }
238 return res; 238 return res;
239} 239}
240 240
241/** 241/**
242* This sets the display brightness 242* This sets the display brightness
243* 243*
244* @param p The brightness to be set on a scale from 0 to 255 244* @param p The brightness to be set on a scale from 0 to 255
245* @return success or failure 245* @return success or failure
246*/ 246*/
247bool ODevice::setDisplayBrightness ( int p) 247bool ODevice::setDisplayBrightness ( int p)
248{ 248{
249 Q_UNUSED( p ) 249 Q_UNUSED( p )
250 return false; 250 return false;
251} 251}
252 252
253/** 253/**
254* @return returns the number of steppings on the brightness slider 254* @return returns the number of steppings on the brightness slider
255* in the Light-'n-Power settings. 255* in the Light-'n-Power settings.
256*/ 256*/
257int ODevice::displayBrightnessResolution() const 257int ODevice::displayBrightnessResolution() const
258{ 258{
259 return 16; 259 return 16;
260} 260}
261 261
262/** 262/**
263* This sets the display contrast 263* This sets the display contrast
264* @param p The contrast to be set on a scale from 0 to 255 264* @param p The contrast to be set on a scale from 0 to 255
265* @return success or failure 265* @return success or failure
266*/ 266*/
267bool ODevice::setDisplayContrast ( int p) 267bool ODevice::setDisplayContrast ( int p)
268{ 268{
269 Q_UNUSED( p ) 269 Q_UNUSED( p )
270 return false; 270 return false;
271} 271}
272 272
273/** 273/**
274* @return return the max value for the brightness settings slider 274* @return return the max value for the brightness settings slider
275* or 0 if the device doesn't support setting of a contrast 275* or 0 if the device doesn't support setting of a contrast
276*/ 276*/
277int ODevice::displayContrastResolution() const 277int ODevice::displayContrastResolution() const
278{ 278{
279 return 0; 279 return 0;
280} 280}
281 281
282/** 282/**
283* This returns the vendor as string 283* This returns the vendor as string
284* @return Vendor as QString 284* @return Vendor as QString
285*/ 285*/
286QString ODevice::vendorString() const 286QString ODevice::vendorString() const
287{ 287{
288 return d->m_vendorstr; 288 return d->m_vendorstr;
289} 289}
290 290
291/** 291/**
292* This returns the vendor as one of the values of OVendor 292* This returns the vendor as one of the values of OVendor
293* @return OVendor 293* @return OVendor
294*/ 294*/
295OVendor ODevice::vendor() const 295OVendor ODevice::vendor() const
296{ 296{
297 return d->m_vendor; 297 return d->m_vendor;
298} 298}
299 299
300/** 300/**
301* This returns the model as a string 301* This returns the model as a string
302* @return A string representing the model 302* @return A string representing the model
303*/ 303*/
304QString ODevice::modelString() const 304QString ODevice::modelString() const
305{ 305{
306 return d->m_modelstr; 306 return d->m_modelstr;
307} 307}
308 308
309/** 309/**
310* This does return the OModel used 310* This does return the OModel used
311*/ 311*/
312OModel ODevice::model() const 312OModel ODevice::model() const
313{ 313{
314 return d->m_model; 314 return d->m_model;
315} 315}
316 316
317/** 317/**
318* This does return the systen name 318* This does return the systen name
319*/ 319*/
320QString ODevice::systemString() const 320QString ODevice::systemString() const
321{ 321{
322 return d->m_systemstr; 322 return d->m_systemstr;
323} 323}
324 324
325/** 325/**
326* Return System as OSystem value 326* Return System as OSystem value
327*/ 327*/
328OSystem ODevice::system() const 328OSystem ODevice::system() const
329{ 329{
330 return d->m_system; 330 return d->m_system;
331} 331}
332 332
333/** 333/**
334* @return the version string of the base system 334* @return the version string of the base system
335*/ 335*/
336QString ODevice::systemVersionString() const 336QString ODevice::systemVersionString() const
337{ 337{
338 return d->m_sysverstr; 338 return d->m_sysverstr;
339} 339}
340 340
diff --git a/libopie2/opiecore/device/odevice_ipaq.cpp b/libopie2/opiecore/device/odevice_ipaq.cpp
index cc4b01a..8ecea1b 100644
--- a/libopie2/opiecore/device/odevice_ipaq.cpp
+++ b/libopie2/opiecore/device/odevice_ipaq.cpp
@@ -23,385 +23,385 @@
23  -_. . .   )=.  = Library General Public License along with 23  -_. . .   )=.  = Library General Public License along with
24    --        :-=` this library; see the file COPYING.LIB. 24    --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29 29
30#include "odevice_ipaq.h" 30#include "odevice_ipaq.h"
31 31
32/* QT */ 32/* QT */
33#include <qapplication.h> 33#include <qapplication.h>
34#include <qfile.h> 34#include <qfile.h>
35#include <qtextstream.h> 35#include <qtextstream.h>
36#include <qwindowsystem_qws.h> 36#include <qwindowsystem_qws.h>
37 37
38/* OPIE */ 38/* OPIE */
39#include <qpe/config.h> 39#include <qpe/config.h>
40#include <qpe/resource.h> 40#include <qpe/resource.h>
41#include <qpe/sound.h> 41#include <qpe/sound.h>
42#include <qpe/qcopenvelope_qws.h> 42#include <qpe/qcopenvelope_qws.h>
43 43
44/* STD */ 44/* STD */
45#include <fcntl.h> 45#include <fcntl.h>
46#include <math.h> 46#include <math.h>
47#include <stdlib.h> 47#include <stdlib.h>
48#include <signal.h> 48#include <signal.h>
49#include <sys/ioctl.h> 49#include <sys/ioctl.h>
50#include <sys/time.h> 50#include <sys/time.h>
51#include <unistd.h> 51#include <unistd.h>
52#ifndef QT_NO_SOUND 52#ifndef QT_NO_SOUND
53#include <linux/soundcard.h> 53#include <linux/soundcard.h>
54#endif 54#endif
55 55
56/* KERNEL */ 56/* KERNEL */
57#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) 57#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 ))
58 58
59#define OD_IO(type,number) OD_IOC(0,type,number,0) 59#define OD_IO(type,number) OD_IOC(0,type,number,0)
60#define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) 60#define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size))
61#define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) 61#define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size))
62#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) 62#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size))
63 63
64typedef struct { 64typedef struct {
65 unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ 65 unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */
66 unsigned char TotalTime; /* Units of 5 seconds */ 66 unsigned char TotalTime; /* Units of 5 seconds */
67 unsigned char OnTime; /* units of 100m/s */ 67 unsigned char OnTime; /* units of 100m/s */
68 unsigned char OffTime; /* units of 100m/s */ 68 unsigned char OffTime; /* units of 100m/s */
69} LED_IN; 69} LED_IN;
70 70
71typedef struct { 71typedef struct {
72 unsigned char mode; 72 unsigned char mode;
73 unsigned char pwr; 73 unsigned char pwr;
74 unsigned char brightness; 74 unsigned char brightness;
75} FLITE_IN; 75} FLITE_IN;
76 76
77#define LED_ON OD_IOW( 'f', 5, LED_IN ) 77#define LED_ON OD_IOW( 'f', 5, LED_IN )
78#define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) 78#define FLITE_ON OD_IOW( 'f', 7, FLITE_IN )
79 79
80struct i_button ipaq_buttons [] = { 80struct i_button ipaq_buttons [] = {
81 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, 81 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx,
82 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 82 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
83 "devicebuttons/ipaq_calendar", 83 "devicebuttons/ipaq_calendar",
84 "datebook", "nextView()", 84 "datebook", "nextView()",
85 "today", "raise()" }, 85 "today", "raise()" },
86 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, 86 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx,
87 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 87 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
88 "devicebuttons/ipaq_contact", 88 "devicebuttons/ipaq_contact",
89 "addressbook", "raise()", 89 "addressbook", "raise()",
90 "addressbook", "beamBusinessCard()" }, 90 "addressbook", "beamBusinessCard()" },
91 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx, 91 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx,
92 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 92 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
93 "devicebuttons/ipaq_menu", 93 "devicebuttons/ipaq_menu",
94 "QPE/TaskBar", "toggleMenu()", 94 "QPE/TaskBar", "toggleMenu()",
95 "QPE/TaskBar", "toggleStartMenu()" }, 95 "QPE/TaskBar", "toggleStartMenu()" },
96 { Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, 96 { Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx,
97 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), 97 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
98 "devicebuttons/ipaq_mail", 98 "devicebuttons/ipaq_mail",
99 "mail", "raise()", 99 "mail", "raise()",
100 "mail", "newMail()" }, 100 "mail", "newMail()" },
101 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, 101 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx,
102 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 102 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
103 "devicebuttons/ipaq_home", 103 "devicebuttons/ipaq_home",
104 "QPE/Launcher", "home()", 104 "QPE/Launcher", "home()",
105 "buttonsettings", "raise()" }, 105 "buttonsettings", "raise()" },
106 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, 106 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx,
107 Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"), 107 Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"),
108 "devicebuttons/ipaq_record", 108 "devicebuttons/ipaq_record",
109 "QPE/VMemo", "toggleRecord()", 109 "QPE/VMemo", "toggleRecord()",
110 "sound", "raise()" }, 110 "sound", "raise()" },
111}; 111};
112 112
113void iPAQ::init() 113void iPAQ::init()
114{ 114{
115 d->m_vendorstr = "HP"; 115 d->m_vendorstr = "HP";
116 d->m_vendor = Vendor_HP; 116 d->m_vendor = Vendor_HP;
117 117
118 QFile f ( "/proc/hal/model" ); 118 QFile f ( "/proc/hal/model" );
119 119
120 if ( f. open ( IO_ReadOnly )) { 120 if ( f. open ( IO_ReadOnly )) {
121 QTextStream ts ( &f ); 121 QTextStream ts ( &f );
122 122
123 d->m_modelstr = "H" + ts. readLine(); 123 d->m_modelstr = "H" + ts. readLine();
124 124
125 if ( d->m_modelstr == "H3100" ) 125 if ( d->m_modelstr == "H3100" )
126 d->m_model = Model_iPAQ_H31xx; 126 d->m_model = Model_iPAQ_H31xx;
127 else if ( d->m_modelstr == "H3600" ) 127 else if ( d->m_modelstr == "H3600" )
128 d->m_model = Model_iPAQ_H36xx; 128 d->m_model = Model_iPAQ_H36xx;
129 else if ( d->m_modelstr == "H3700" ) 129 else if ( d->m_modelstr == "H3700" )
130 d->m_model = Model_iPAQ_H37xx; 130 d->m_model = Model_iPAQ_H37xx;
131 else if ( d->m_modelstr == "H3800" ) 131 else if ( d->m_modelstr == "H3800" )
132 d->m_model = Model_iPAQ_H38xx; 132 d->m_model = Model_iPAQ_H38xx;
133 else if ( d->m_modelstr == "H3900" ) 133 else if ( d->m_modelstr == "H3900" )
134 d->m_model = Model_iPAQ_H39xx; 134 d->m_model = Model_iPAQ_H39xx;
135 else if ( d->m_modelstr == "H5400" ) 135 else if ( d->m_modelstr == "H5400" )
136 d->m_model = Model_iPAQ_H5xxx; 136 d->m_model = Model_iPAQ_H5xxx;
137 else 137 else
138 d->m_model = Model_Unknown; 138 d->m_model = Model_Unknown;
139 139
140 f. close(); 140 f. close();
141 } 141 }
142 142
143 switch ( d->m_model ) { 143 switch ( d->m_model ) {
144 case Model_iPAQ_H31xx: 144 case Model_iPAQ_H31xx:
145 case Model_iPAQ_H38xx: 145 case Model_iPAQ_H38xx:
146 d->m_rotation = Rot90; 146 d->m_rotation = Rot90;
147 break; 147 break;
148 case Model_iPAQ_H36xx: 148 case Model_iPAQ_H36xx:
149 case Model_iPAQ_H37xx: 149 case Model_iPAQ_H37xx:
150 case Model_iPAQ_H39xx: 150 case Model_iPAQ_H39xx:
151 151
152 default: 152 default:
153 d->m_rotation = Rot270; 153 d->m_rotation = Rot270;
154 break; 154 break;
155 case Model_iPAQ_H5xxx: 155 case Model_iPAQ_H5xxx:
156 d->m_rotation = Rot0; 156 d->m_rotation = Rot0;
157 } 157 }
158 158
159 f. setName ( "/etc/familiar-version" ); 159 f. setName ( "/etc/familiar-version" );
160 if ( f. open ( IO_ReadOnly )) { 160 if ( f. open ( IO_ReadOnly )) {
161 d->m_systemstr = "Familiar"; 161 d->m_systemstr = "Familiar";
162 d->m_system = System_Familiar; 162 d->m_system = System_Familiar;
163 163
164 QTextStream ts ( &f ); 164 QTextStream ts ( &f );
165 d->m_sysverstr = ts. readLine(). mid ( 10 ); 165 d->m_sysverstr = ts. readLine(). mid ( 10 );
166 166
167 f. close(); 167 f. close();
168 } else { 168 } else {
169 f. setName ( "/etc/oz_version" ); 169 f. setName ( "/etc/oz_version" );
170 170
171 if ( f. open ( IO_ReadOnly )) { 171 if ( f. open ( IO_ReadOnly )) {
172 d->m_systemstr = "OpenEmbedded/iPaq"; 172 d->m_systemstr = "OpenEmbedded/iPaq";
173 d->m_system = System_Familiar; 173 d->m_system = System_Familiar;
174 174
175 QTextStream ts ( &f ); 175 QTextStream ts ( &f );
176 ts.setDevice ( &f ); 176 ts.setDevice ( &f );
177 d->m_sysverstr = ts. readLine(); 177 d->m_sysverstr = ts. readLine();
178 f. close(); 178 f. close();
179 } 179 }
180 } 180 }
181 181
182 m_leds [0] = m_leds [1] = Led_Off; 182 m_leds [0] = m_leds [1] = Led_Off;
183 183
184 m_power_timer = 0; 184 m_power_timer = 0;
185 185
186} 186}
187 187
188void iPAQ::initButtons() 188void iPAQ::initButtons()
189{ 189{
190 if ( d->m_buttons ) 190 if ( d->m_buttons )
191 return; 191 return;
192 192
193 if ( isQWS( ) ) 193 if ( isQWS( ) )
194 QWSServer::setKeyboardFilter ( this ); 194 QWSServer::setKeyboardFilter ( this );
195 195
196 d->m_buttons = new QValueList <ODeviceButton>; 196 d->m_buttons = new QValueList <ODeviceButton>;
197 197
198 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { 198 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) {
199 i_button *ib = ipaq_buttons + i; 199 i_button *ib = ipaq_buttons + i;
200 ODeviceButton b; 200 ODeviceButton b;
201 201
202 if (( ib->model & d->m_model ) == d->m_model ) { 202 if (( ib->model & d->m_model ) == d->m_model ) {
203 b. setKeycode ( ib->code ); 203 b. setKeycode ( ib->code );
204 b. setUserText ( QObject::tr ( "Button", ib->utext )); 204 b. setUserText ( QObject::tr ( "Button", ib->utext ));
205 b. setPixmap ( Resource::loadPixmap ( ib->pix )); 205 b. setPixmap ( Resource::loadPixmap ( ib->pix ));
206 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib->fpressedservice ), ib->fpressedaction )); 206 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib->fpressedservice ), ib->fpressedaction ));
207 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib->fheldservice ), ib->fheldaction )); 207 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib->fheldservice ), ib->fheldaction ));
208 208
209 d->m_buttons->append ( b ); 209 d->m_buttons->append ( b );
210 } 210 }
211 } 211 }
212 reloadButtonMapping(); 212 reloadButtonMapping();
213 213
214 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 214 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
215 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); 215 connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&)));
216} 216}
217 217
218QValueList <OLed> iPAQ::ledList() const 218QValueList <OLed> iPAQ::ledList() const
219{ 219{
220 QValueList <OLed> vl; 220 QValueList <OLed> vl;
221 vl << Led_Power; 221 vl << Led_Power;
222 222
223 if ( d->m_model == Model_iPAQ_H38xx ) 223 if ( d->m_model == Model_iPAQ_H38xx )
224 vl << Led_BlueTooth; 224 vl << Led_BlueTooth;
225 return vl; 225 return vl;
226} 226}
227 227
228QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const 228QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const
229{ 229{
230 QValueList <OLedState> vl; 230 QValueList <OLedState> vl;
231 231
232 if ( l == Led_Power ) 232 if ( l == Led_Power )
233 vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast; 233 vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast;
234 else if ( l == Led_BlueTooth && d->m_model == Model_iPAQ_H38xx ) 234 else if ( l == Led_BlueTooth && d->m_model == Model_iPAQ_H38xx )
235 vl << Led_Off; // << Led_On << ??? 235 vl << Led_Off; // << Led_On << ???
236 236
237 return vl; 237 return vl;
238} 238}
239 239
240OLedState iPAQ::ledState ( OLed l ) const 240OLedState iPAQ::ledState ( OLed l ) const
241{ 241{
242 switch ( l ) { 242 switch ( l ) {
243 case Led_Power: 243 case Led_Power:
244 return m_leds [0]; 244 return m_leds [0];
245 case Led_BlueTooth: 245 case Led_BlueTooth:
246 return m_leds [1]; 246 return m_leds [1];
247 default: 247 default:
248 return Led_Off; 248 return Led_Off;
249 } 249 }
250} 250}
251 251
252bool iPAQ::setLedState ( OLed l, OLedState st ) 252bool iPAQ::setLedState ( OLed l, OLedState st )
253{ 253{
254 static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK ); 254 static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK );
255 255
256 if ( l == Led_Power ) { 256 if ( l == Led_Power ) {
257 if ( fd >= 0 ) { 257 if ( fd >= 0 ) {
258 LED_IN leds; 258 LED_IN leds;
259 ::memset ( &leds, 0, sizeof( leds )); 259 ::memset ( &leds, 0, sizeof( leds ));
260 leds. TotalTime = 0; 260 leds. TotalTime = 0;
261 leds. OnTime = 0; 261 leds. OnTime = 0;
262 leds. OffTime = 1; 262 leds. OffTime = 1;
263 leds. OffOnBlink = 2; 263 leds. OffOnBlink = 2;
264 264
265 switch ( st ) { 265 switch ( st ) {
266 case Led_Off : leds. OffOnBlink = 0; break; 266 case Led_Off : leds. OffOnBlink = 0; break;
267 case Led_On : leds. OffOnBlink = 1; break; 267 case Led_On : leds. OffOnBlink = 1; break;
268 case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; 268 case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break;
269 case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; 269 case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break;
270 } 270 }
271 271
272 if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { 272 if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) {
273 m_leds [0] = st; 273 m_leds [0] = st;
274 return true; 274 return true;
275 } 275 }
276 } 276 }
277 } 277 }
278 return false; 278 return false;
279} 279}
280 280
281 281
282bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) 282bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat )
283{ 283{
284 int newkeycode = keycode; 284 int newkeycode = keycode;
285 285
286 switch ( keycode ) { 286 switch ( keycode ) {
287 // H38xx/H39xx have no "Q" key anymore - this is now the Mail key 287 // H38xx/H39xx have no "Q" key anymore - this is now the Mail key
288 case HardKey_Menu: { 288 case HardKey_Menu: {
289 if (( d->m_model == Model_iPAQ_H38xx ) || 289 if (( d->m_model == Model_iPAQ_H38xx ) ||
290 ( d->m_model == Model_iPAQ_H39xx ) || 290 ( d->m_model == Model_iPAQ_H39xx ) ||
291 ( d->m_model == Model_iPAQ_H5xxx)) { 291 ( d->m_model == Model_iPAQ_H5xxx)) {
292 newkeycode = HardKey_Mail; 292 newkeycode = HardKey_Mail;
293 } 293 }
294 break; 294 break;
295 } 295 }
296 296
297 // Rotate cursor keys 180° or 270° 297 // Rotate cursor keys 180° or 270°
298 case Key_Left : 298 case Key_Left :
299 case Key_Right: 299 case Key_Right:
300 case Key_Up : 300 case Key_Up :
301 case Key_Down : { 301 case Key_Down : {
302 if (( d->m_model == Model_iPAQ_H31xx ) || 302 if (( d->m_model == Model_iPAQ_H31xx ) ||
303 ( d->m_model == Model_iPAQ_H38xx )) { 303 ( d->m_model == Model_iPAQ_H38xx )) {
304 newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4; 304 newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4;
305 } 305 }
306 // Rotate the cursor keys by 270° 306 // Rotate the cursor keys by 270°
307 // keycode - Key_Left = position of the button starting from left clockwise 307 // keycode - Key_Left = position of the button starting from left clockwise
308 // add the rotation to it and modolo. No we've the original offset 308 // add the rotation to it and modolo. No we've the original offset
309 // add the offset to the Key_Left key 309 // add the offset to the Key_Left key
310 if ( d-> m_model == Model_iPAQ_H5xxx ) 310 if ( d-> m_model == Model_iPAQ_H5xxx )
311 newkeycode = Key_Left + ( keycode - Key_Left + 3 ) % 4; 311 newkeycode = Key_Left + ( keycode - Key_Left + 3 ) % 4;
312 break; 312 break;
313 } 313 }
314 314
315 // map Power Button short/long press to F34/F35 315 // map Power Button short/long press to F34/F35
316 case Key_SysReq: { 316 case Key_SysReq: {
317 if ( isPress ) { 317 if ( isPress ) {
318 if ( m_power_timer ) 318 if ( m_power_timer )
319 killTimer ( m_power_timer ); 319 killTimer ( m_power_timer );
320 m_power_timer = startTimer ( 500 ); 320 m_power_timer = startTimer ( 500 );
321 } 321 }
322 else if ( m_power_timer ) { 322 else if ( m_power_timer ) {
323 killTimer ( m_power_timer ); 323 killTimer ( m_power_timer );
324 m_power_timer = 0; 324 m_power_timer = 0;
325 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); 325 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false );
326 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); 326 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false );
327 } 327 }
328 newkeycode = Key_unknown; 328 newkeycode = Key_unknown;
329 break; 329 break;
330 } 330 }
331 } 331 }
332 332
333 if ( newkeycode != keycode ) { 333 if ( newkeycode != keycode ) {
334 if ( newkeycode != Key_unknown ) 334 if ( newkeycode != Key_unknown )
335 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); 335 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat );
336 return true; 336 return true;
337 } 337 }
338 else 338 else
339 return false; 339 return false;
340} 340}
341 341
342void iPAQ::timerEvent ( QTimerEvent * ) 342void iPAQ::timerEvent ( QTimerEvent * )
343{ 343{
344 killTimer ( m_power_timer ); 344 killTimer ( m_power_timer );
345 m_power_timer = 0; 345 m_power_timer = 0;
346 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); 346 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false );
347 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); 347 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false );
348} 348}
349 349
350 350
351void iPAQ::playAlarmSound() 351void iPAQ::playAlarmSound()
352{ 352{
353#ifndef QT_NO_SOUND 353#ifndef QT_NO_SOUND
354 static Sound snd ( "alarm" ); 354 static Sound snd ( "alarm" );
355 int fd; 355 int fd;
356 int vol; 356 int vol;
357 bool vol_reset = false; 357 bool vol_reset = false;
358 358
359 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { 359 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) {
360 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { 360 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) {
361 Config cfg ( "qpe" ); 361 Config cfg ( "qpe" );
362 cfg. setGroup ( "Volume" ); 362 cfg. setGroup ( "Volume" );
363 363
364 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); 364 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 );
365 if ( volalarm < 0 ) 365 if ( volalarm < 0 )
366 volalarm = 0; 366 volalarm = 0;
367 else if ( volalarm > 100 ) 367 else if ( volalarm > 100 )
368 volalarm = 100; 368 volalarm = 100;
369 volalarm |= ( volalarm << 8 ); 369 volalarm |= ( volalarm << 8 );
370 370
371 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) 371 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 )
372 vol_reset = true; 372 vol_reset = true;
373 } 373 }
374 } 374 }
375 375
376 snd. play(); 376 snd. play();
377 while ( !snd. isFinished()) 377 while ( !snd. isFinished())
378 qApp->processEvents(); 378 qApp->processEvents();
379 379
380 if ( fd >= 0 ) { 380 if ( fd >= 0 ) {
381 if ( vol_reset ) 381 if ( vol_reset )
382 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); 382 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol );
383 ::close ( fd ); 383 ::close ( fd );
384 } 384 }
385#endif 385#endif
386} 386}
387 387
388 388
389bool iPAQ::setSoftSuspend ( bool soft ) 389bool iPAQ::setSoftSuspend ( bool soft )
390{ 390{
391 bool res = false; 391 bool res = false;
392 int fd; 392 int fd;
393 393
394 if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { 394 if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) {
395 if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) 395 if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 )
396 res = true; 396 res = true;
397 else 397 else
398 ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); 398 ::perror ( "write to /proc/sys/ts/suspend_button_mode" );
399 399
400 ::close ( fd ); 400 ::close ( fd );
401 } 401 }
402 else 402 else
403 ::perror ( "/proc/sys/ts/suspend_button_mode" ); 403 ::perror ( "/proc/sys/ts/suspend_button_mode" );
404 404
405 return res; 405 return res;
406} 406}
407 407
diff --git a/libopie2/opiecore/device/odevice_simpad.cpp b/libopie2/opiecore/device/odevice_simpad.cpp
index 31b9297..90aca2f 100644
--- a/libopie2/opiecore/device/odevice_simpad.cpp
+++ b/libopie2/opiecore/device/odevice_simpad.cpp
@@ -1,384 +1,384 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) The Opie Team <opie-devel@handhelds.org> 3 Copyright (C) The Opie Team <opie-devel@handhelds.org>
4 =. 4 =.
5 .=l. 5 .=l.
6 .>+-= 6 .>+-=
7_;:, .> :=|. This program is free software; you can 7_;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under 8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11- . .-<_> .<> Foundation; either version 2 of the License, 11- . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_. 13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 20++= -. .` .: details.
21: = ...= . :.=- 21: = ...= . :.=-
22-. .:....=;==+<; You should have received a copy of the GNU 22-. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29 29
30#include "odevice_simpad.h" 30#include "odevice_simpad.h"
31 31
32/* QT */ 32/* QT */
33#include <qapplication.h> 33#include <qapplication.h>
34#include <qfile.h> 34#include <qfile.h>
35#include <qtextstream.h> 35#include <qtextstream.h>
36#include <qwindowsystem_qws.h> 36#include <qwindowsystem_qws.h>
37 37
38/* OPIE */ 38/* OPIE */
39#include <qpe/config.h> 39#include <qpe/config.h>
40#include <qpe/resource.h> 40#include <qpe/resource.h>
41#include <qpe/sound.h> 41#include <qpe/sound.h>
42#include <qpe/qcopenvelope_qws.h> 42#include <qpe/qcopenvelope_qws.h>
43 43
44/* STD */ 44/* STD */
45#include <fcntl.h> 45#include <fcntl.h>
46#include <math.h> 46#include <math.h>
47#include <stdlib.h> 47#include <stdlib.h>
48#include <signal.h> 48#include <signal.h>
49#include <sys/ioctl.h> 49#include <sys/ioctl.h>
50#include <sys/time.h> 50#include <sys/time.h>
51#include <unistd.h> 51#include <unistd.h>
52#ifndef QT_NO_SOUND 52#ifndef QT_NO_SOUND
53#include <linux/soundcard.h> 53#include <linux/soundcard.h>
54#endif 54#endif
55 55
56using namespace Opie; 56using namespace Opie;
57 57
58struct s_button simpad_buttons [] = { 58struct s_button simpad_buttons [] = {
59 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 59 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
60 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Lower+Up"), 60 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Lower+Up"),
61 "devicebuttons/simpad_lower_up", 61 "devicebuttons/simpad_lower_up",
62 "datebook", "nextView()", 62 "datebook", "nextView()",
63 "today", "raise()" }, 63 "today", "raise()" },
64 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 64 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
65 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Lower+Down"), 65 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Lower+Down"),
66 "devicebuttons/simpad_lower_down", 66 "devicebuttons/simpad_lower_down",
67 "addressbook", "raise()", 67 "addressbook", "raise()",
68 "addressbook", "beamBusinessCard()" }, 68 "addressbook", "beamBusinessCard()" },
69 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 69 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
70 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Lower+Right"), 70 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Lower+Right"),
71 "devicebuttons/simpad_lower_right", 71 "devicebuttons/simpad_lower_right",
72 "QPE/TaskBar", "toggleMenu()", 72 "QPE/TaskBar", "toggleMenu()",
73 "QPE/TaskBar", "toggleStartMenu()" }, 73 "QPE/TaskBar", "toggleStartMenu()" },
74 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 74 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
75 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Lower+Left"), 75 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Lower+Left"),
76 "devicebuttons/simpad_lower_left", 76 "devicebuttons/simpad_lower_left",
77 "mail", "raise()", 77 "mail", "raise()",
78 "mail", "newMail()" }, 78 "mail", "newMail()" },
79 79
80 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 80 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
81 Qt::Key_F5, QT_TRANSLATE_NOOP("Button", "Upper+Up"), 81 Qt::Key_F5, QT_TRANSLATE_NOOP("Button", "Upper+Up"),
82 "devicebuttons/simpad_upper_up", 82 "devicebuttons/simpad_upper_up",
83 "QPE/Launcher", "home()", 83 "QPE/Launcher", "home()",
84 "buttonsettings", "raise()" }, 84 "buttonsettings", "raise()" },
85 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 85 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
86 Qt::Key_F6, QT_TRANSLATE_NOOP("Button", "Upper+Down"), 86 Qt::Key_F6, QT_TRANSLATE_NOOP("Button", "Upper+Down"),
87 "devicebuttons/simpad_upper_down", 87 "devicebuttons/simpad_upper_down",
88 "addressbook", "raise()", 88 "addressbook", "raise()",
89 "addressbook", "beamBusinessCard()" }, 89 "addressbook", "beamBusinessCard()" },
90 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 90 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
91 Qt::Key_F7, QT_TRANSLATE_NOOP("Button", "Upper+Right"), 91 Qt::Key_F7, QT_TRANSLATE_NOOP("Button", "Upper+Right"),
92 "devicebuttons/simpad_upper_right", 92 "devicebuttons/simpad_upper_right",
93 "QPE/TaskBar", "toggleMenu()", 93 "QPE/TaskBar", "toggleMenu()",
94 "QPE/TaskBar", "toggleStartMenu()" }, 94 "QPE/TaskBar", "toggleStartMenu()" },
95 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 95 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
96 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Upper+Left"), 96 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Upper+Left"),
97 "devicebuttons/simpad_upper_left", 97 "devicebuttons/simpad_upper_left",
98 "QPE/Rotation", "flip()", 98 "QPE/Rotation", "flip()",
99 "QPE/Rotation", "flip()" }, 99 "QPE/Rotation", "flip()" },
100 /* 100 /*
101 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 101 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
102 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), 102 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"),
103 "devicebuttons/simpad_lower_upper", 103 "devicebuttons/simpad_lower_upper",
104 "QPE/Launcher", "home()", 104 "QPE/Launcher", "home()",
105 "buttonsettings", "raise()" }, 105 "buttonsettings", "raise()" },
106 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 106 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
107 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), 107 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"),
108 "devicebuttons/simpad_upper_lower", 108 "devicebuttons/simpad_upper_lower",
109 "QPE/Launcher", "home()", 109 "QPE/Launcher", "home()",
110 "buttonsettings", "raise()" }, 110 "buttonsettings", "raise()" },
111 */ 111 */
112}; 112};
113 113
114void SIMpad::init() 114void SIMpad::init()
115{ 115{
116 d->m_vendorstr = "SIEMENS"; 116 d->m_vendorstr = "SIEMENS";
117 d->m_vendor = Vendor_SIEMENS; 117 d->m_vendor = Vendor_SIEMENS;
118 118
119 QFile f ( "/proc/hal/model" ); 119 QFile f ( "/proc/hal/model" );
120 120
121 //TODO Implement model checking 121 //TODO Implement model checking
122 //FIXME For now we assume an SL4 122 //FIXME For now we assume an SL4
123 123
124 d->m_modelstr = "SL4"; 124 d->m_modelstr = "SL4";
125 d->m_model = Model_SIMpad_SL4; 125 d->m_model = Model_SIMpad_SL4;
126 126
127 switch ( d->m_model ) { 127 switch ( d->m_model ) {
128 default: 128 default:
129 d->m_rotation = Rot0; 129 d->m_rotation = Rot0;
130 d->m_direction = CCW; 130 d->m_direction = CCW;
131 d->m_holdtime = 1000; // 1000ms 131 d->m_holdtime = 1000; // 1000ms
132 132
133 break; 133 break;
134 } 134 }
135 135
136 f. setName ( "/etc/familiar-version" ); 136 f. setName ( "/etc/familiar-version" );
137 if ( f. open ( IO_ReadOnly )) { 137 if ( f. open ( IO_ReadOnly )) {
138 d->m_systemstr = "Familiar"; 138 d->m_systemstr = "Familiar";
139 d->m_system = System_Familiar; 139 d->m_system = System_Familiar;
140 140
141 QTextStream ts ( &f ); 141 QTextStream ts ( &f );
142 d->m_sysverstr = ts. readLine(). mid ( 10 ); 142 d->m_sysverstr = ts. readLine(). mid ( 10 );
143 143
144 f. close(); 144 f. close();
145 } else { 145 } else {
146 f. setName ( "/etc/oz_version" ); 146 f. setName ( "/etc/oz_version" );
147 147
148 if ( f. open ( IO_ReadOnly )) { 148 if ( f. open ( IO_ReadOnly )) {
149 d->m_systemstr = "OpenEmbedded/SIMpad"; 149 d->m_systemstr = "OpenEmbedded/SIMpad";
150 d->m_system = System_OpenZaurus; 150 d->m_system = System_OpenZaurus;
151 151
152 QTextStream ts ( &f ); 152 QTextStream ts ( &f );
153 ts.setDevice ( &f ); 153 ts.setDevice ( &f );
154 d->m_sysverstr = ts. readLine(); 154 d->m_sysverstr = ts. readLine();
155 f. close(); 155 f. close();
156 } 156 }
157 } 157 }
158 158
159 m_leds [0] = m_leds [1] = Led_Off; 159 m_leds [0] = m_leds [1] = Led_Off;
160 160
161 m_power_timer = 0; 161 m_power_timer = 0;
162 162
163} 163}
164 164
165void SIMpad::initButtons() 165void SIMpad::initButtons()
166{ 166{
167 if ( d->m_buttons ) 167 if ( d->m_buttons )
168 return; 168 return;
169 169
170 if ( isQWS( ) ) 170 if ( isQWS( ) )
171 QWSServer::setKeyboardFilter ( this ); 171 QWSServer::setKeyboardFilter ( this );
172 172
173 d->m_buttons = new QValueList <ODeviceButton>; 173 d->m_buttons = new QValueList <ODeviceButton>;
174 174
175 for ( uint i = 0; i < ( sizeof( simpad_buttons ) / sizeof( s_button )); i++ ) { 175 for ( uint i = 0; i < ( sizeof( simpad_buttons ) / sizeof( s_button )); i++ ) {
176 s_button *sb = simpad_buttons + i; 176 s_button *sb = simpad_buttons + i;
177 ODeviceButton b; 177 ODeviceButton b;
178 178
179 if (( sb->model & d->m_model ) == d->m_model ) { 179 if (( sb->model & d->m_model ) == d->m_model ) {
180 b. setKeycode ( sb->code ); 180 b. setKeycode ( sb->code );
181 b. setUserText ( QObject::tr ( "Button", sb->utext )); 181 b. setUserText ( QObject::tr ( "Button", sb->utext ));
182 b. setPixmap ( Resource::loadPixmap ( sb->pix )); 182 b. setPixmap ( Resource::loadPixmap ( sb->pix ));
183 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( sb->fpressedservice ), sb->fpressedaction )); 183 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( sb->fpressedservice ), sb->fpressedaction ));
184 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( sb->fheldservice ), sb->fheldaction )); 184 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( sb->fheldservice ), sb->fheldaction ));
185 185
186 d->m_buttons->append ( b ); 186 d->m_buttons->append ( b );
187 } 187 }
188 } 188 }
189 reloadButtonMapping(); 189 reloadButtonMapping();
190 190
191 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 191 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
192 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); 192 connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&)));
193} 193}
194 194
195// SIMpad boardcontrol register CS3 195// SIMpad boardcontrol register CS3
196#define SIMPAD_BOARDCONTROL "/proc/cs3" 196#define SIMPAD_BOARDCONTROL "/proc/cs3"
197#define SIMPAD_VCC_5V_EN 0x0001 // For 5V PCMCIA 197#define SIMPAD_VCC_5V_EN 0x0001 // For 5V PCMCIA
198#define SIMPAD_VCC_3V_EN 0x0002 // FOR 3.3V PCMCIA 198#define SIMPAD_VCC_3V_EN 0x0002 // FOR 3.3V PCMCIA
199#define SIMPAD_EN1 0x0004 // This is only for EPROM's 199#define SIMPAD_EN1 0x0004 // This is only for EPROM's
200#define SIMPAD_EN0 0x0008 // Both should be enable for 3.3V or 5V 200#define SIMPAD_EN0 0x0008 // Both should be enable for 3.3V or 5V
201#define SIMPAD_DISPLAY_ON 0x0010 201#define SIMPAD_DISPLAY_ON 0x0010
202#define SIMPAD_PCMCIA_BUFF_DIS 0x0020 202#define SIMPAD_PCMCIA_BUFF_DIS 0x0020
203#define SIMPAD_MQ_RESET 0x0040 203#define SIMPAD_MQ_RESET 0x0040
204#define SIMPAD_PCMCIA_RESET 0x0080 204#define SIMPAD_PCMCIA_RESET 0x0080
205#define SIMPAD_DECT_POWER_ON 0x0100 205#define SIMPAD_DECT_POWER_ON 0x0100
206#define SIMPAD_IRDA_SD 0x0200 // Shutdown for powersave 206#define SIMPAD_IRDA_SD 0x0200 // Shutdown for powersave
207#define SIMPAD_RS232_ON 0x0400 207#define SIMPAD_RS232_ON 0x0400
208#define SIMPAD_SD_MEDIAQ 0x0800 // Shutdown for powersave 208#define SIMPAD_SD_MEDIAQ 0x0800 // Shutdown for powersave
209#define SIMPAD_LED2_ON 0x1000 209#define SIMPAD_LED2_ON 0x1000
210#define SIMPAD_IRDA_MODE 0x2000 // Fast/Slow IrDA mode 210#define SIMPAD_IRDA_MODE 0x2000 // Fast/Slow IrDA mode
211#define SIMPAD_ENABLE_5V 0x4000 // Enable 5V circuit 211#define SIMPAD_ENABLE_5V 0x4000 // Enable 5V circuit
212#define SIMPAD_RESET_SIMCARD 0x8000 212#define SIMPAD_RESET_SIMCARD 0x8000
213 213
214//SIMpad touchscreen backlight strength control 214//SIMpad touchscreen backlight strength control
215#define SIMPAD_BACKLIGHT_CONTROL "/proc/driver/mq200/registers/PWM_CONTROL" 215#define SIMPAD_BACKLIGHT_CONTROL "/proc/driver/mq200/registers/PWM_CONTROL"
216#define SIMPAD_BACKLIGHT_MASK 0x00a10044 216#define SIMPAD_BACKLIGHT_MASK 0x00a10044
217 217
218QValueList <OLed> SIMpad::ledList() const 218QValueList <OLed> SIMpad::ledList() const
219{ 219{
220 QValueList <OLed> vl; 220 QValueList <OLed> vl;
221 vl << Led_Power; //FIXME which LED is LED2 ? The green one or the amber one? 221 vl << Led_Power; //FIXME which LED is LED2 ? The green one or the amber one?
222 //vl << Led_Mail; //TODO find out if LED1 is accessible anyway 222 //vl << Led_Mail; //TODO find out if LED1 is accessible anyway
223 return vl; 223 return vl;
224} 224}
225 225
226QValueList <OLedState> SIMpad::ledStateList ( OLed l ) const 226QValueList <OLedState> SIMpad::ledStateList ( OLed l ) const
227{ 227{
228 QValueList <OLedState> vl; 228 QValueList <OLedState> vl;
229 229
230 if ( l == Led_Power ) //FIXME which LED is LED2 ? The green one or the amber one? 230 if ( l == Led_Power ) //FIXME which LED is LED2 ? The green one or the amber one?
231 vl << Led_Off << Led_On; 231 vl << Led_Off << Led_On;
232 //else if ( l == Led_Mail ) //TODO find out if LED1 is accessible anyway 232 //else if ( l == Led_Mail ) //TODO find out if LED1 is accessible anyway
233 //vl << Led_Off; 233 //vl << Led_Off;
234 return vl; 234 return vl;
235} 235}
236 236
237OLedState SIMpad::ledState ( OLed l ) const 237OLedState SIMpad::ledState ( OLed l ) const
238{ 238{
239 switch ( l ) { 239 switch ( l ) {
240 case Led_Power: 240 case Led_Power:
241 return m_leds [0]; 241 return m_leds [0];
242 //case Led_Mail: 242 //case Led_Mail:
243 //return m_leds [1]; 243 //return m_leds [1];
244 default: 244 default:
245 return Led_Off; 245 return Led_Off;
246 } 246 }
247} 247}
248 248
249bool SIMpad::setLedState ( OLed l, OLedState st ) 249bool SIMpad::setLedState ( OLed l, OLedState st )
250{ 250{
251#if 0 251#if 0
252 static int fd = ::open ( SIMPAD_BOARDCONTROL, O_RDWR | O_NONBLOCK ); 252 static int fd = ::open ( SIMPAD_BOARDCONTROL, O_RDWR | O_NONBLOCK );
253 253
254 /*TODO Implement this like that: 254 /*TODO Implement this like that:
255 read from cs3 255 read from cs3
256 && with SIMPAD_LED2_ON 256 && with SIMPAD_LED2_ON
257 write to cs3 */ 257 write to cs3 */
258 m_leds [0] = st; 258 m_leds [0] = st;
259 return true; 259 return true;
260 } 260 }
261 } 261 }
262 } 262 }
263 263
264#endif 264#endif
265 return false; 265 return false;
266} 266}
267 267
268 268
269bool SIMpad::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) 269bool SIMpad::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat )
270{ 270{
271 //TODO 271 //TODO
272 return false; 272 return false;
273} 273}
274 274
275void SIMpad::timerEvent ( QTimerEvent * ) 275void SIMpad::timerEvent ( QTimerEvent * )
276{ 276{
277 killTimer ( m_power_timer ); 277 killTimer ( m_power_timer );
278 m_power_timer = 0; 278 m_power_timer = 0;
279 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); 279 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false );
280 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); 280 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false );
281} 281}
282 282
283 283
284void SIMpad::playAlarmSound() 284void SIMpad::playAlarmSound()
285{ 285{
286#ifndef QT_NO_SOUND 286#ifndef QT_NO_SOUND
287 static Sound snd ( "alarm" ); 287 static Sound snd ( "alarm" );
288 int fd; 288 int fd;
289 int vol; 289 int vol;
290 bool vol_reset = false; 290 bool vol_reset = false;
291 291
292 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { 292 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) {
293 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { 293 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) {
294 Config cfg ( "qpe" ); 294 Config cfg ( "qpe" );
295 cfg. setGroup ( "Volume" ); 295 cfg. setGroup ( "Volume" );
296 296
297 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); 297 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 );
298 if ( volalarm < 0 ) 298 if ( volalarm < 0 )
299 volalarm = 0; 299 volalarm = 0;
300 else if ( volalarm > 100 ) 300 else if ( volalarm > 100 )
301 volalarm = 100; 301 volalarm = 100;
302 volalarm |= ( volalarm << 8 ); 302 volalarm |= ( volalarm << 8 );
303 303
304 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) 304 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 )
305 vol_reset = true; 305 vol_reset = true;
306 } 306 }
307 } 307 }
308 308
309 snd. play(); 309 snd. play();
310 while ( !snd. isFinished()) 310 while ( !snd. isFinished())
311 qApp->processEvents(); 311 qApp->processEvents();
312 312
313 if ( fd >= 0 ) { 313 if ( fd >= 0 ) {
314 if ( vol_reset ) 314 if ( vol_reset )
315 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); 315 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol );
316 ::close ( fd ); 316 ::close ( fd );
317 } 317 }
318#endif 318#endif
319} 319}
320 320
321 321
322bool SIMpad::suspend() // Must override because SIMpad does NOT have apm 322bool SIMpad::suspend() // Must override because SIMpad does NOT have apm
323{ 323{
324 qDebug( "ODevice for SIMpad: suspend()" ); 324 qDebug( "ODevice for SIMpad: suspend()" );
325 if ( !isQWS( ) ) // only qwsserver is allowed to suspend 325 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
326 return false; 326 return false;
327 327
328 bool res = false; 328 bool res = false;
329 ODevice::sendSuspendmsg(); 329 ODevice::sendSuspendmsg();
330 330
331 struct timeval tvs, tvn; 331 struct timeval tvs, tvn;
332 ::gettimeofday ( &tvs, 0 ); 332 ::gettimeofday ( &tvs, 0 );
333 333
334 ::sync(); // flush fs caches 334 ::sync(); // flush fs caches
335 res = ( ::system ( "cat /dev/fb/0 >/tmp/.buffer; echo > /proc/sys/pm/suspend; cat /tmp/.buffer >/dev/fb/0" ) == 0 ); //TODO make better :) 335 res = ( ::system ( "cat /dev/fb/0 >/tmp/.buffer; echo > /proc/sys/pm/suspend; cat /tmp/.buffer >/dev/fb/0" ) == 0 ); //TODO make better :)
336 336
337 return res; 337 return res;
338} 338}
339 339
340 340
341bool SIMpad::setSoftSuspend ( bool soft ) 341bool SIMpad::setSoftSuspend ( bool soft )
342{ 342{
343 qDebug( "ODevice for SIMpad: UNHANDLED setSoftSuspend(%s)", soft? "on" : "off" ); 343 qDebug( "ODevice for SIMpad: UNHANDLED setSoftSuspend(%s)", soft? "on" : "off" );
344 return false; 344 return false;
345} 345}
346 346
347 347
348bool SIMpad::setDisplayStatus ( bool on ) 348bool SIMpad::setDisplayStatus ( bool on )
349{ 349{
350 qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" ); 350 qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" );
351 351
352 bool res = false; 352 bool res = false;
353 int fd; 353 int fd;
354 354
355 QString cmdline = QString().sprintf( "echo %s > /proc/cs3", on ? "0xd41a" : "0xd40a" ); //TODO make better :) 355 QString cmdline = QString().sprintf( "echo %s > /proc/cs3", on ? "0xd41a" : "0xd40a" ); //TODO make better :)
356 356
357 res = ( ::system( (const char*) cmdline ) == 0 ); 357 res = ( ::system( (const char*) cmdline ) == 0 );
358 358
359 return res; 359 return res;
360} 360}
361 361
362 362
363bool SIMpad::setDisplayBrightness ( int bright ) 363bool SIMpad::setDisplayBrightness ( int bright )
364{ 364{
365 qDebug( "ODevice for SIMpad: setDisplayBrightness( %d )", bright ); 365 qDebug( "ODevice for SIMpad: setDisplayBrightness( %d )", bright );
366 bool res = false; 366 bool res = false;
367 int fd; 367 int fd;
368 368
369 if ( bright > 255 ) 369 if ( bright > 255 )
370 bright = 255; 370 bright = 255;
371 if ( bright < 1 ) 371 if ( bright < 1 )
372 bright = 0; 372 bright = 0;
373 373
374 if (( fd = ::open ( SIMPAD_BACKLIGHT_CONTROL, O_WRONLY )) >= 0 ) { 374 if (( fd = ::open ( SIMPAD_BACKLIGHT_CONTROL, O_WRONLY )) >= 0 ) {
375 int value = 255 - bright; 375 int value = 255 - bright;
376 const int mask = SIMPAD_BACKLIGHT_MASK; 376 const int mask = SIMPAD_BACKLIGHT_MASK;
377 value = value << 8; 377 value = value << 8;
378 value += mask; 378 value += mask;
379 char writeCommand[100]; 379 char writeCommand[100];
380 const int count = sprintf( writeCommand, "0x%x\n", value ); 380 const int count = sprintf( writeCommand, "0x%x\n", value );
381 res = ( ::write ( fd, writeCommand, count ) != -1 ); 381 res = ( ::write ( fd, writeCommand, count ) != -1 );
382 ::close ( fd ); 382 ::close ( fd );
383 } 383 }
384 return res; 384 return res;
diff --git a/libopie2/opiecore/device/odevice_yopy.cpp b/libopie2/opiecore/device/odevice_yopy.cpp
index a76f90b..d241db8 100644
--- a/libopie2/opiecore/device/odevice_yopy.cpp
+++ b/libopie2/opiecore/device/odevice_yopy.cpp
@@ -1,163 +1,163 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3             Copyright (C) The Opie Team <opie-devel@handhelds.org> 3             Copyright (C) The Opie Team <opie-devel@handhelds.org>
4 =. 4 =.
5 .=l. 5 .=l.
6          .>+-= 6          .>+-=
7_;:,     .>    :=|. This program is free software; you can 7_;:,     .>    :=|. This program is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under 8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
10.="- .-=="i,     .._ License as published by the Free Software 10.="- .-=="i,     .._ License as published by the Free Software
11- .   .-<_>     .<> Foundation; either version 2 of the License, 11- .   .-<_>     .<> Foundation; either version 2 of the License,
12    ._= =}       : or (at your option) any later version. 12    ._= =}       : or (at your option) any later version.
13   .%`+i>       _;_. 13   .%`+i>       _;_.
14   .i_,=:_.      -<s. This program is distributed in the hope that 14   .i_,=:_.      -<s. This program is distributed in the hope that
15    +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15    +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16   : ..    .:,     . . . without even the implied warranty of 16   : ..    .:,     . . . without even the implied warranty of
17   =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17   =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more 19..}^=.=       =       ; Library General Public License for more
20++=   -.     .`     .: details. 20++=   -.     .`     .: details.
21:     =  ...= . :.=- 21:     =  ...= . :.=-
22-.   .:....=;==+<; You should have received a copy of the GNU 22-.   .:....=;==+<; You should have received a copy of the GNU
23 -_. . .   )=.  = Library General Public License along with 23 -_. . .   )=.  = Library General Public License along with
24   --        :-=` this library; see the file COPYING.LIB. 24   --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29 29
30#include "odevice_yopy.h" 30#include "odevice_yopy.h"
31 31
32/* QT */ 32/* QT */
33#include <qapplication.h> 33#include <qapplication.h>
34#include <qfile.h> 34#include <qfile.h>
35#include <qtextstream.h> 35#include <qtextstream.h>
36#include <qwindowsystem_qws.h> 36#include <qwindowsystem_qws.h>
37 37
38/* OPIE */ 38/* OPIE */
39#include <qpe/config.h> 39#include <qpe/config.h>
40#include <qpe/resource.h> 40#include <qpe/resource.h>
41#include <qpe/sound.h> 41#include <qpe/sound.h>
42#include <qpe/qcopenvelope_qws.h> 42#include <qpe/qcopenvelope_qws.h>
43 43
44/* STD */ 44/* STD */
45#include <fcntl.h> 45#include <fcntl.h>
46#include <math.h> 46#include <math.h>
47#include <stdlib.h> 47#include <stdlib.h>
48#include <signal.h> 48#include <signal.h>
49#include <sys/ioctl.h> 49#include <sys/ioctl.h>
50#include <sys/time.h> 50#include <sys/time.h>
51#include <unistd.h> 51#include <unistd.h>
52#ifndef QT_NO_SOUND 52#ifndef QT_NO_SOUND
53#include <linux/soundcard.h> 53#include <linux/soundcard.h>
54#endif 54#endif
55 55
56using namespace Opie; 56using namespace Opie;
57 57
58struct yopy_button yopy_buttons [] = { 58struct yopy_button yopy_buttons [] = {
59 { Qt::Key_F10, QT_TRANSLATE_NOOP( "Button", "Action Button" ), 59 { Qt::Key_F10, QT_TRANSLATE_NOOP( "Button", "Action Button" ),
60 "devicebuttons/yopy_action", 60 "devicebuttons/yopy_action",
61 "datebook", "nextView()", 61 "datebook", "nextView()",
62 "today", "raise()" }, 62 "today", "raise()" },
63 { Qt::Key_F11, QT_TRANSLATE_NOOP( "Button", "OK Button" ), 63 { Qt::Key_F11, QT_TRANSLATE_NOOP( "Button", "OK Button" ),
64 "devicebuttons/yopy_ok", 64 "devicebuttons/yopy_ok",
65 "addressbook", "raise()", 65 "addressbook", "raise()",
66 "addressbook", "beamBusinessCard()" }, 66 "addressbook", "beamBusinessCard()" },
67 { Qt::Key_F12, QT_TRANSLATE_NOOP( "Button", "End Button" ), 67 { Qt::Key_F12, QT_TRANSLATE_NOOP( "Button", "End Button" ),
68 "devicebuttons/yopy_end", 68 "devicebuttons/yopy_end",
69 "QPE/Launcher", "home()", 69 "QPE/Launcher", "home()",
70 "buttonsettings", "raise()" }, 70 "buttonsettings", "raise()" },
71}; 71};
72 72
73void Yopy::init() 73void Yopy::init()
74{ 74{
75 d->m_vendorstr = "G.Mate"; 75 d->m_vendorstr = "G.Mate";
76 d->m_vendor = Vendor_GMate; 76 d->m_vendor = Vendor_GMate;
77 d->m_modelstr = "Yopy3700"; 77 d->m_modelstr = "Yopy3700";
78 d->m_model = Model_Yopy_3700; 78 d->m_model = Model_Yopy_3700;
79 d->m_rotation = Rot0; 79 d->m_rotation = Rot0;
80 80
81 d->m_systemstr = "Linupy"; 81 d->m_systemstr = "Linupy";
82 d->m_system = System_Linupy; 82 d->m_system = System_Linupy;
83 83
84 QFile f ( "/etc/issue" ); 84 QFile f ( "/etc/issue" );
85 if ( f. open ( IO_ReadOnly ) ) 85 if ( f. open ( IO_ReadOnly ) )
86 { 86 {
87 QTextStream ts ( &f ); 87 QTextStream ts ( &f );
88 ts.readLine(); 88 ts.readLine();
89 d->m_sysverstr = ts. readLine(); 89 d->m_sysverstr = ts. readLine();
90 f. close(); 90 f. close();
91 } 91 }
92} 92}
93 93
94 94
95void Yopy::initButtons() 95void Yopy::initButtons()
96{ 96{
97 if ( d->m_buttons ) 97 if ( d->m_buttons )
98 return ; 98 return ;
99 99
100 d->m_buttons = new QValueList <ODeviceButton>; 100 d->m_buttons = new QValueList <ODeviceButton>;
101 101
102 for ( uint i = 0; i < ( sizeof( yopy_buttons ) / sizeof( yopy_button ) ); i++ ) 102 for ( uint i = 0; i < ( sizeof( yopy_buttons ) / sizeof( yopy_button ) ); i++ )
103 { 103 {
104 104
105 yopy_button *ib = yopy_buttons + i; 105 yopy_button *ib = yopy_buttons + i;
106 106
107 ODeviceButton b; 107 ODeviceButton b;
108 108
109 b. setKeycode ( ib->code ); 109 b. setKeycode ( ib->code );
110 b. setUserText ( QObject::tr ( "Button", ib->utext ) ); 110 b. setUserText ( QObject::tr ( "Button", ib->utext ) );
111 b. setPixmap ( Resource::loadPixmap ( ib->pix ) ); 111 b. setPixmap ( Resource::loadPixmap ( ib->pix ) );
112 b. setFactoryPresetPressedAction 112 b. setFactoryPresetPressedAction
113 ( OQCopMessage( makeChannel( ib->fpressedservice ), ib->fpressedaction ) ); 113 ( OQCopMessage( makeChannel( ib->fpressedservice ), ib->fpressedaction ) );
114 b. setFactoryPresetHeldAction 114 b. setFactoryPresetHeldAction
115 ( OQCopMessage( makeChannel( ib->fheldservice ), ib->fheldaction ) ); 115 ( OQCopMessage( makeChannel( ib->fheldservice ), ib->fheldaction ) );
116 116
117 d->m_buttons->append ( b ); 117 d->m_buttons->append ( b );
118 } 118 }
119 reloadButtonMapping(); 119 reloadButtonMapping();
120 120
121 QCopChannel *sysch = new QCopChannel( "QPE/System", this ); 121 QCopChannel *sysch = new QCopChannel( "QPE/System", this );
122 connect( sysch, SIGNAL( received( const QCString &, const QByteArray & ) ), 122 connect( sysch, SIGNAL( received(const QCString&,const QByteArray&) ),
123 this, SLOT( systemMessage( const QCString &, const QByteArray & ) ) ); 123 this, SLOT( systemMessage(const QCString&,const QByteArray&) ) );
124} 124}
125 125
126 126
127bool Yopy::suspend() 127bool Yopy::suspend()
128{ 128{
129 /* Opie for Yopy does not implement its own power management at the 129 /* Opie for Yopy does not implement its own power management at the
130 moment. The public version runs parallel to X, and relies on the 130 moment. The public version runs parallel to X, and relies on the
131 existing power management features. */ 131 existing power management features. */
132 return false; 132 return false;
133} 133}
134 134
135 135
136bool Yopy::setDisplayBrightness( int bright ) 136bool Yopy::setDisplayBrightness( int bright )
137{ 137{
138 /* The code here works, but is disabled as the current version runs 138 /* The code here works, but is disabled as the current version runs
139 parallel to X, and relies on the existing backlight demon. */ 139 parallel to X, and relies on the existing backlight demon. */
140#if 0 140#if 0
141 if ( QFile::exists( "/proc/sys/pm/light" ) ) 141 if ( QFile::exists( "/proc/sys/pm/light" ) )
142 { 142 {
143 int fd = ::open( "/proc/sys/pm/light", O_WRONLY ); 143 int fd = ::open( "/proc/sys/pm/light", O_WRONLY );
144 if ( fd >= 0 ) 144 if ( fd >= 0 )
145 { 145 {
146 if ( bright ) 146 if ( bright )
147 ::write( fd, "1\n", 2 ); 147 ::write( fd, "1\n", 2 );
148 else 148 else
149 ::write( fd, "0\n", 2 ); 149 ::write( fd, "0\n", 2 );
150 ::close( fd ); 150 ::close( fd );
151 return true; 151 return true;
152 } 152 }
153 } 153 }
154#endif 154#endif
155 return false; 155 return false;
156} 156}
157 157
158 158
159int Yopy::displayBrightnessResolution() const 159int Yopy::displayBrightnessResolution() const
160{ 160{
161 return 2; 161 return 2;
162} 162}
163 163
diff --git a/libopie2/opiecore/device/odevice_zaurus.cpp b/libopie2/opiecore/device/odevice_zaurus.cpp
index 9d23a12..8ab3cbe 100644
--- a/libopie2/opiecore/device/odevice_zaurus.cpp
+++ b/libopie2/opiecore/device/odevice_zaurus.cpp
@@ -63,386 +63,386 @@ struct z_button z_buttons [] = {
63 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 63 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
64 "devicebuttons/z_contact", 64 "devicebuttons/z_contact",
65 "addressbook", "raise()", 65 "addressbook", "raise()",
66 "addressbook", "beamBusinessCard()" }, 66 "addressbook", "beamBusinessCard()" },
67 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 67 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
68 "devicebuttons/z_home", 68 "devicebuttons/z_home",
69 "QPE/Launcher", "home()", 69 "QPE/Launcher", "home()",
70 "buttonsettings", "raise()" }, 70 "buttonsettings", "raise()" },
71 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 71 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
72 "devicebuttons/z_menu", 72 "devicebuttons/z_menu",
73 "QPE/TaskBar", "toggleMenu()", 73 "QPE/TaskBar", "toggleMenu()",
74 "QPE/TaskBar", "toggleStartMenu()" }, 74 "QPE/TaskBar", "toggleStartMenu()" },
75 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), 75 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
76 "devicebuttons/z_mail", 76 "devicebuttons/z_mail",
77 "mail", "raise()", 77 "mail", "raise()",
78 "mail", "newMail()" }, 78 "mail", "newMail()" },
79}; 79};
80 80
81struct z_button z_buttons_c700 [] = { 81struct z_button z_buttons_c700 [] = {
82 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 82 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
83 "devicebuttons/z_calendar", 83 "devicebuttons/z_calendar",
84 "datebook", "nextView()", 84 "datebook", "nextView()",
85 "today", "raise()" }, 85 "today", "raise()" },
86 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 86 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
87 "devicebuttons/z_contact", 87 "devicebuttons/z_contact",
88 "addressbook", "raise()", 88 "addressbook", "raise()",
89 "addressbook", "beamBusinessCard()" }, 89 "addressbook", "beamBusinessCard()" },
90 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 90 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
91 "devicebuttons/z_home", 91 "devicebuttons/z_home",
92 "QPE/Launcher", "home()", 92 "QPE/Launcher", "home()",
93 "buttonsettings", "raise()" }, 93 "buttonsettings", "raise()" },
94 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 94 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
95 "devicebuttons/z_menu", 95 "devicebuttons/z_menu",
96 "QPE/TaskBar", "toggleMenu()", 96 "QPE/TaskBar", "toggleMenu()",
97 "QPE/TaskBar", "toggleStartMenu()" }, 97 "QPE/TaskBar", "toggleStartMenu()" },
98 { Qt::Key_F14, QT_TRANSLATE_NOOP("Button", "Display Rotate"), 98 { Qt::Key_F14, QT_TRANSLATE_NOOP("Button", "Display Rotate"),
99 "devicebuttons/z_hinge", 99 "devicebuttons/z_hinge",
100 "QPE/Rotation", "rotateDefault()", 100 "QPE/Rotation", "rotateDefault()",
101 "QPE/Dummy", "doNothing()" }, 101 "QPE/Dummy", "doNothing()" },
102}; 102};
103 103
104// FIXME This gets unnecessary complicated. We should think about splitting the Zaurus 104// FIXME This gets unnecessary complicated. We should think about splitting the Zaurus
105// class up into individual classes. We need three classes 105// class up into individual classes. We need three classes
106// 106//
107// Zaurus-Collie (SA-model w/ 320x240 lcd, for SL5500 and SL5000) 107// Zaurus-Collie (SA-model w/ 320x240 lcd, for SL5500 and SL5000)
108// Zaurus-Poodle (PXA-model w/ 320x240 lcd, for SL5600) 108// Zaurus-Poodle (PXA-model w/ 320x240 lcd, for SL5600)
109// Zaurus-Corgi (PXA-model w/ 640x480 lcd, for C700, C750, C760, and C860) 109// Zaurus-Corgi (PXA-model w/ 640x480 lcd, for C700, C750, C760, and C860)
110// 110//
111// Only question right now is: Do we really need to do it? Because as soon 111// Only question right now is: Do we really need to do it? Because as soon
112// as the OpenZaurus kernel is ready, there will be a unified interface for all 112// as the OpenZaurus kernel is ready, there will be a unified interface for all
113// Zaurus models (concerning apm, backlight, buttons, etc.) 113// Zaurus models (concerning apm, backlight, buttons, etc.)
114// 114//
115// Comments? - mickeyl. 115// Comments? - mickeyl.
116 116
117void Zaurus::init() 117void Zaurus::init()
118{ 118{
119 d->m_vendorstr = "Sharp"; 119 d->m_vendorstr = "Sharp";
120 d->m_vendor = Vendor_Sharp; 120 d->m_vendor = Vendor_Sharp;
121 m_embedix = true; // Not openzaurus means: It has an embedix kernel ! 121 m_embedix = true; // Not openzaurus means: It has an embedix kernel !
122 122
123 // QFile f ( "/proc/filesystems" ); 123 // QFile f ( "/proc/filesystems" );
124 QString model; 124 QString model;
125 125
126 // It isn't a good idea to check the system configuration to 126 // It isn't a good idea to check the system configuration to
127 // detect the distribution ! 127 // detect the distribution !
128 // Otherwise it may happen that any other distribution is detected as openzaurus, just 128 // Otherwise it may happen that any other distribution is detected as openzaurus, just
129 // because it uses a jffs2 filesystem.. 129 // because it uses a jffs2 filesystem..
130 // (eilers) 130 // (eilers)
131 // if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read(). find ( "\tjffs2\n" ) >= 0 )) { 131 // if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read(). find ( "\tjffs2\n" ) >= 0 )) {
132 QFile f ("/etc/oz_version"); 132 QFile f ("/etc/oz_version");
133 if ( f.exists() ){ 133 if ( f.exists() ){
134 d->m_vendorstr = "OpenZaurus Team"; 134 d->m_vendorstr = "OpenZaurus Team";
135 d->m_systemstr = "OpenZaurus"; 135 d->m_systemstr = "OpenZaurus";
136 d->m_system = System_OpenZaurus; 136 d->m_system = System_OpenZaurus;
137 137
138 if ( f. open ( IO_ReadOnly )) { 138 if ( f. open ( IO_ReadOnly )) {
139 QTextStream ts ( &f ); 139 QTextStream ts ( &f );
140 d->m_sysverstr = ts. readLine();//. mid ( 10 ); 140 d->m_sysverstr = ts. readLine();//. mid ( 10 );
141 f. close(); 141 f. close();
142 } 142 }
143 143
144 // Openzaurus sometimes uses the embedix kernel! 144 // Openzaurus sometimes uses the embedix kernel!
145 // => Check whether this is an embedix kernel 145 // => Check whether this is an embedix kernel
146 FILE *uname = popen("uname -r", "r"); 146 FILE *uname = popen("uname -r", "r");
147 QString line; 147 QString line;
148 if ( f.open(IO_ReadOnly, uname) ) { 148 if ( f.open(IO_ReadOnly, uname) ) {
149 QTextStream ts ( &f ); 149 QTextStream ts ( &f );
150 line = ts. readLine(); 150 line = ts. readLine();
151 int loc = line. find ( "embedix" ); 151 int loc = line. find ( "embedix" );
152 if ( loc != -1 ) 152 if ( loc != -1 )
153 m_embedix = true; 153 m_embedix = true;
154 else 154 else
155 m_embedix = false; 155 m_embedix = false;
156 f. close(); 156 f. close();
157 } 157 }
158 pclose(uname); 158 pclose(uname);
159 } 159 }
160 else { 160 else {
161 d->m_systemstr = "Zaurus"; 161 d->m_systemstr = "Zaurus";
162 d->m_system = System_Zaurus; 162 d->m_system = System_Zaurus;
163 } 163 }
164 164
165 f. setName ( "/proc/cpuinfo" ); 165 f. setName ( "/proc/cpuinfo" );
166 if ( f. open ( IO_ReadOnly ) ) { 166 if ( f. open ( IO_ReadOnly ) ) {
167 QTextStream ts ( &f ); 167 QTextStream ts ( &f );
168 QString line; 168 QString line;
169 while( line = ts. readLine() ) { 169 while( line = ts. readLine() ) {
170 if ( line. left ( 8 ) == "Hardware" ) 170 if ( line. left ( 8 ) == "Hardware" )
171 break; 171 break;
172 } 172 }
173 int loc = line. find ( ":" ); 173 int loc = line. find ( ":" );
174 if ( loc != -1 ) 174 if ( loc != -1 )
175 model = line. mid ( loc + 2 ). simplifyWhiteSpace( ); 175 model = line. mid ( loc + 2 ). simplifyWhiteSpace( );
176 } 176 }
177 177
178 if ( model == "SHARP Corgi" ) { 178 if ( model == "SHARP Corgi" ) {
179 d->m_model = Model_Zaurus_SLC7x0; 179 d->m_model = Model_Zaurus_SLC7x0;
180 d->m_modelstr = "Zaurus SL-C700"; 180 d->m_modelstr = "Zaurus SL-C700";
181 } else if ( model == "SHARP Shepherd" ) { 181 } else if ( model == "SHARP Shepherd" ) {
182 d->m_model = Model_Zaurus_SLC7x0; 182 d->m_model = Model_Zaurus_SLC7x0;
183 d->m_modelstr = "Zaurus SL-C750"; 183 d->m_modelstr = "Zaurus SL-C750";
184 } else if ( model == "SHARP Husky" ) { 184 } else if ( model == "SHARP Husky" ) {
185 d->m_model = Model_Zaurus_SLC7x0; 185 d->m_model = Model_Zaurus_SLC7x0;
186 d->m_modelstr = "Zaurus SL-C760"; 186 d->m_modelstr = "Zaurus SL-C760";
187 } else if ( model == "SHARP Poodle" ) { 187 } else if ( model == "SHARP Poodle" ) {
188 d->m_model = Model_Zaurus_SLB600; 188 d->m_model = Model_Zaurus_SLB600;
189 d->m_modelstr = "Zaurus SL-B500 or SL-5600"; 189 d->m_modelstr = "Zaurus SL-B500 or SL-5600";
190 } else if ( model == "Sharp-Collie" || model == "Collie" ) { 190 } else if ( model == "Sharp-Collie" || model == "Collie" ) {
191 d->m_model = Model_Zaurus_SL5500; 191 d->m_model = Model_Zaurus_SL5500;
192 d->m_modelstr = "Zaurus SL-5500 or SL-5000d"; 192 d->m_modelstr = "Zaurus SL-5500 or SL-5000d";
193 } else { 193 } else {
194 d->m_model = Model_Zaurus_SL5500; 194 d->m_model = Model_Zaurus_SL5500;
195 d->m_modelstr = "Zaurus (Model unknown)"; 195 d->m_modelstr = "Zaurus (Model unknown)";
196 } 196 }
197 197
198 bool flipstate = false; 198 bool flipstate = false;
199 switch ( d->m_model ) { 199 switch ( d->m_model ) {
200 case Model_Zaurus_SLA300: 200 case Model_Zaurus_SLA300:
201 d->m_rotation = Rot0; 201 d->m_rotation = Rot0;
202 break; 202 break;
203 case Model_Zaurus_SLC7x0: 203 case Model_Zaurus_SLC7x0:
204 d->m_rotation = rotation(); 204 d->m_rotation = rotation();
205 d->m_direction = direction(); 205 d->m_direction = direction();
206 break; 206 break;
207 case Model_Zaurus_SLB600: 207 case Model_Zaurus_SLB600:
208 case Model_Zaurus_SL5500: 208 case Model_Zaurus_SL5500:
209 case Model_Zaurus_SL5000: 209 case Model_Zaurus_SL5000:
210 default: 210 default:
211 d->m_rotation = Rot270; 211 d->m_rotation = Rot270;
212 break; 212 break;
213 } 213 }
214 m_leds [0] = Led_Off; 214 m_leds [0] = Led_Off;
215} 215}
216 216
217void Zaurus::initButtons() 217void Zaurus::initButtons()
218{ 218{
219 if ( d->m_buttons ) 219 if ( d->m_buttons )
220 return; 220 return;
221 221
222 d->m_buttons = new QValueList <ODeviceButton>; 222 d->m_buttons = new QValueList <ODeviceButton>;
223 223
224 struct z_button * pz_buttons; 224 struct z_button * pz_buttons;
225 int buttoncount; 225 int buttoncount;
226 switch ( d->m_model ) { 226 switch ( d->m_model ) {
227 case Model_Zaurus_SLC7x0: 227 case Model_Zaurus_SLC7x0:
228 pz_buttons = z_buttons_c700; 228 pz_buttons = z_buttons_c700;
229 buttoncount = ARRAY_SIZE(z_buttons_c700); 229 buttoncount = ARRAY_SIZE(z_buttons_c700);
230 break; 230 break;
231 default: 231 default:
232 pz_buttons = z_buttons; 232 pz_buttons = z_buttons;
233 buttoncount = ARRAY_SIZE(z_buttons); 233 buttoncount = ARRAY_SIZE(z_buttons);
234 break; 234 break;
235 } 235 }
236 236
237 for ( int i = 0; i < buttoncount; i++ ) { 237 for ( int i = 0; i < buttoncount; i++ ) {
238 struct z_button *zb = pz_buttons + i; 238 struct z_button *zb = pz_buttons + i;
239 ODeviceButton b; 239 ODeviceButton b;
240 240
241 b. setKeycode ( zb->code ); 241 b. setKeycode ( zb->code );
242 b. setUserText ( QObject::tr ( "Button", zb->utext )); 242 b. setUserText ( QObject::tr ( "Button", zb->utext ));
243 b. setPixmap ( Resource::loadPixmap ( zb->pix )); 243 b. setPixmap ( Resource::loadPixmap ( zb->pix ));
244 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb->fpressedservice ), 244 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb->fpressedservice ),
245 zb->fpressedaction )); 245 zb->fpressedaction ));
246 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb->fheldservice ), 246 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb->fheldservice ),
247 zb->fheldaction )); 247 zb->fheldaction ));
248 248
249 d->m_buttons->append ( b ); 249 d->m_buttons->append ( b );
250 } 250 }
251 251
252 reloadButtonMapping(); 252 reloadButtonMapping();
253 253
254 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 254 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
255 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), 255 connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)),
256 this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); 256 this, SLOT( systemMessage(const QCString&,const QByteArray&)));
257} 257}
258 258
259#include <unistd.h> 259#include <unistd.h>
260#include <fcntl.h> 260#include <fcntl.h>
261#include <sys/ioctl.h> 261#include <sys/ioctl.h>
262 262
263//#include <asm/sharp_char.h> // including kernel headers is evil ... 263//#include <asm/sharp_char.h> // including kernel headers is evil ...
264 264
265#define SHARP_DEV_IOCTL_COMMAND_START 0x5680 265#define SHARP_DEV_IOCTL_COMMAND_START 0x5680
266 266
267 #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 267 #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
268#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) 268#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START)
269 269
270#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ 270#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */
271#define SHARP_BUZ_KEYSOUND 2 /* key sound */ 271#define SHARP_BUZ_KEYSOUND 2 /* key sound */
272#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ 272#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */
273 273
274/* --- for SHARP_BUZZER device --- */ 274/* --- for SHARP_BUZZER device --- */
275 275
276 //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 276 //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
277//#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) 277//#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START)
278 278
279#define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) 279#define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1)
280#define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) 280#define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2)
281#define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) 281#define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3)
282#define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) 282#define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4)
283#define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) 283#define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5)
284 284
285//#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ 285//#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */
286//#define SHARP_BUZ_KEYSOUND 2 /* key sound */ 286//#define SHARP_BUZ_KEYSOUND 2 /* key sound */
287 287
288//#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */ 288//#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */
289//#define SHARP_PDA_WARNSOUND 4 /* warning occurred */ 289//#define SHARP_PDA_WARNSOUND 4 /* warning occurred */
290//#define SHARP_PDA_ERRORSOUND 5 /* error occurred */ 290//#define SHARP_PDA_ERRORSOUND 5 /* error occurred */
291//#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */ 291//#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */
292//#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */ 292//#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */
293//#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */ 293//#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */
294//#define SHARP_PDA_APPSTART 9 /* application start */ 294//#define SHARP_PDA_APPSTART 9 /* application start */
295//#define SHARP_PDA_APPQUIT 10 /* application ends */ 295//#define SHARP_PDA_APPQUIT 10 /* application ends */
296 296
297//#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ 297//#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */
298//#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */ 298//#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */
299//#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */ 299//#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */
300//#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */ 300//#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */
301// 301//
302 302
303 #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 303 #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
304#define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) 304#define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1)
305 305
306#define SHARP_IOCTL_GET_ROTATION 0x413c 306#define SHARP_IOCTL_GET_ROTATION 0x413c
307 307
308typedef struct sharp_led_status { 308typedef struct sharp_led_status {
309int which; /* select which LED status is wanted. */ 309int which; /* select which LED status is wanted. */
310int status; /* set new led status if you call SHARP_LED_SETSTATUS */ 310int status; /* set new led status if you call SHARP_LED_SETSTATUS */
311} sharp_led_status; 311} sharp_led_status;
312 312
313#define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ 313#define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */
314 314
315#define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ 315#define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */
316#define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ 316#define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */
317#define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ 317#define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */
318 318
319// #include <asm/sharp_apm.h> // including kernel headers is evil ... 319// #include <asm/sharp_apm.h> // including kernel headers is evil ...
320 320
321#define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) 321#define APM_IOCGEVTSRC OD_IOR( 'A', 203, int )
322#define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) 322#define APM_IOCSEVTSRC OD_IORW( 'A', 204, int )
323#define APM_EVT_POWER_BUTTON (1 << 0) 323#define APM_EVT_POWER_BUTTON (1 << 0)
324 324
325#define FL_IOCTL_STEP_CONTRAST 100 325#define FL_IOCTL_STEP_CONTRAST 100
326 326
327 327
328void Zaurus::buzzer ( int sound ) 328void Zaurus::buzzer ( int sound )
329{ 329{
330#ifndef QT_NO_SOUND 330#ifndef QT_NO_SOUND
331 QString soundname; 331 QString soundname;
332 332
333 // Not all devices have real sound 333 // Not all devices have real sound
334 if ( d->m_model == Model_Zaurus_SLC7x0 334 if ( d->m_model == Model_Zaurus_SLC7x0
335 || d->m_model == Model_Zaurus_SLB600 ){ 335 || d->m_model == Model_Zaurus_SLB600 ){
336 336
337 switch ( sound ){ 337 switch ( sound ){
338 case SHARP_BUZ_SCHEDULE_ALARM: 338 case SHARP_BUZ_SCHEDULE_ALARM:
339 soundname = "alarm"; 339 soundname = "alarm";
340 break; 340 break;
341 case SHARP_BUZ_TOUCHSOUND: 341 case SHARP_BUZ_TOUCHSOUND:
342 soundname = "touchsound"; 342 soundname = "touchsound";
343 break; 343 break;
344 case SHARP_BUZ_KEYSOUND: 344 case SHARP_BUZ_KEYSOUND:
345 soundname = "keysound"; 345 soundname = "keysound";
346 break; 346 break;
347 default: 347 default:
348 soundname = "alarm"; 348 soundname = "alarm";
349 349
350 } 350 }
351 } 351 }
352 352
353 // If a soundname is defined, we expect that this device has 353 // If a soundname is defined, we expect that this device has
354 // sound capabilities.. Otherwise we expect to have the buzzer 354 // sound capabilities.. Otherwise we expect to have the buzzer
355 // device.. 355 // device..
356 if ( !soundname.isEmpty() ){ 356 if ( !soundname.isEmpty() ){
357 int fd; 357 int fd;
358 int vol; 358 int vol;
359 bool vol_reset = false; 359 bool vol_reset = false;
360 360
361 Sound snd ( soundname ); 361 Sound snd ( soundname );
362 362
363 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { 363 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) {
364 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { 364 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) {
365 Config cfg ( "qpe" ); 365 Config cfg ( "qpe" );
366 cfg. setGroup ( "Volume" ); 366 cfg. setGroup ( "Volume" );
367 367
368 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); 368 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 );
369 if ( volalarm < 0 ) 369 if ( volalarm < 0 )
370 volalarm = 0; 370 volalarm = 0;
371 else if ( volalarm > 100 ) 371 else if ( volalarm > 100 )
372 volalarm = 100; 372 volalarm = 100;
373 volalarm |= ( volalarm << 8 ); 373 volalarm |= ( volalarm << 8 );
374 374
375 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) 375 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 )
376 vol_reset = true; 376 vol_reset = true;
377 } 377 }
378 } 378 }
379 379
380 snd. play(); 380 snd. play();
381 while ( !snd. isFinished()) 381 while ( !snd. isFinished())
382 qApp->processEvents(); 382 qApp->processEvents();
383 383
384 if ( fd >= 0 ) { 384 if ( fd >= 0 ) {
385 if ( vol_reset ) 385 if ( vol_reset )
386 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); 386 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol );
387 ::close ( fd ); 387 ::close ( fd );
388 } 388 }
389 } else { 389 } else {
390 int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); 390 int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK );
391 391
392 if ( fd >= 0 ) { 392 if ( fd >= 0 ) {
393 ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); 393 ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound );
394 ::close ( fd ); 394 ::close ( fd );
395 } 395 }
396 396
397 } 397 }
398#endif 398#endif
399} 399}
400 400
401 401
402void Zaurus::playAlarmSound() 402void Zaurus::playAlarmSound()
403{ 403{
404 buzzer ( SHARP_BUZ_SCHEDULE_ALARM ); 404 buzzer ( SHARP_BUZ_SCHEDULE_ALARM );
405} 405}
406 406
407void Zaurus::playTouchSound() 407void Zaurus::playTouchSound()
408{ 408{
409 buzzer ( SHARP_BUZ_TOUCHSOUND ); 409 buzzer ( SHARP_BUZ_TOUCHSOUND );
410} 410}
411 411
412void Zaurus::playKeySound() 412void Zaurus::playKeySound()
413{ 413{
414 buzzer ( SHARP_BUZ_KEYSOUND ); 414 buzzer ( SHARP_BUZ_KEYSOUND );
415} 415}
416 416
417 417
418QValueList <OLed> Zaurus::ledList() const 418QValueList <OLed> Zaurus::ledList() const
419{ 419{
420 QValueList <OLed> vl; 420 QValueList <OLed> vl;
421 vl << Led_Mail; 421 vl << Led_Mail;
422 return vl; 422 return vl;
423} 423}
424 424
425QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const 425QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const
426{ 426{
427 QValueList <OLedState> vl; 427 QValueList <OLedState> vl;
428 428
429 if ( l == Led_Mail ) 429 if ( l == Led_Mail )
430 vl << Led_Off << Led_On << Led_BlinkSlow; 430 vl << Led_Off << Led_On << Led_BlinkSlow;
431 return vl; 431 return vl;
432} 432}
433 433
434OLedState Zaurus::ledState ( OLed which ) const 434OLedState Zaurus::ledState ( OLed which ) const
435{ 435{
436 if ( which == Led_Mail ) 436 if ( which == Led_Mail )
437 return m_leds [0]; 437 return m_leds [0];
438 else 438 else
439 return Led_Off; 439 return Led_Off;
440} 440}
441 441
442bool Zaurus::setLedState ( OLed which, OLedState st ) 442bool Zaurus::setLedState ( OLed which, OLedState st )
443{ 443{
444 if (!m_embedix) // Currently not supported on non_embedix kernels 444 if (!m_embedix) // Currently not supported on non_embedix kernels
445 return false; 445 return false;
446 446
447 static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); 447 static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK );
448 448
diff --git a/libopie2/opiecore/oprocess.cpp b/libopie2/opiecore/oprocess.cpp
index 0a361a1..6349c83 100644
--- a/libopie2/opiecore/oprocess.cpp
+++ b/libopie2/opiecore/oprocess.cpp
@@ -483,406 +483,406 @@ void OProcess::flushStdin ( )
483 do 483 do
484 { 484 {
485 d1 = input_total - input_sent; 485 d1 = input_total - input_sent;
486 slotSendData ( 0 ); 486 slotSendData ( 0 );
487 d2 = input_total - input_sent; 487 d2 = input_total - input_sent;
488 } 488 }
489 while ( d2 <= d1 ); 489 while ( d2 <= d1 );
490} 490}
491 491
492void OProcess::suspend() 492void OProcess::suspend()
493{ 493{
494 if ( ( communication & Stdout ) && outnot ) 494 if ( ( communication & Stdout ) && outnot )
495 outnot->setEnabled( false ); 495 outnot->setEnabled( false );
496} 496}
497 497
498void OProcess::resume() 498void OProcess::resume()
499{ 499{
500 if ( ( communication & Stdout ) && outnot ) 500 if ( ( communication & Stdout ) && outnot )
501 outnot->setEnabled( true ); 501 outnot->setEnabled( true );
502} 502}
503 503
504bool OProcess::closeStdin() 504bool OProcess::closeStdin()
505{ 505{
506 bool rv; 506 bool rv;
507 507
508 if ( communication & Stdin ) 508 if ( communication & Stdin )
509 { 509 {
510 communication = ( Communication ) ( communication & ~Stdin ); 510 communication = ( Communication ) ( communication & ~Stdin );
511 delete innot; 511 delete innot;
512 innot = 0; 512 innot = 0;
513 close( in[ 1 ] ); 513 close( in[ 1 ] );
514 rv = true; 514 rv = true;
515 } 515 }
516 else 516 else
517 rv = false; 517 rv = false;
518 return rv; 518 return rv;
519} 519}
520 520
521bool OProcess::closeStdout() 521bool OProcess::closeStdout()
522{ 522{
523 bool rv; 523 bool rv;
524 524
525 if ( communication & Stdout ) 525 if ( communication & Stdout )
526 { 526 {
527 communication = ( Communication ) ( communication & ~Stdout ); 527 communication = ( Communication ) ( communication & ~Stdout );
528 delete outnot; 528 delete outnot;
529 outnot = 0; 529 outnot = 0;
530 close( out[ 0 ] ); 530 close( out[ 0 ] );
531 rv = true; 531 rv = true;
532 } 532 }
533 else 533 else
534 rv = false; 534 rv = false;
535 return rv; 535 return rv;
536} 536}
537 537
538bool OProcess::closeStderr() 538bool OProcess::closeStderr()
539{ 539{
540 bool rv; 540 bool rv;
541 541
542 if ( communication & Stderr ) 542 if ( communication & Stderr )
543 { 543 {
544 communication = static_cast<Communication>( communication & ~Stderr ); 544 communication = static_cast<Communication>( communication & ~Stderr );
545 delete errnot; 545 delete errnot;
546 errnot = 0; 546 errnot = 0;
547 close( err[ 0 ] ); 547 close( err[ 0 ] );
548 rv = true; 548 rv = true;
549 } 549 }
550 else 550 else
551 rv = false; 551 rv = false;
552 return rv; 552 return rv;
553} 553}
554 554
555void OProcess::slotChildOutput( int fdno ) 555void OProcess::slotChildOutput( int fdno )
556{ 556{
557 if ( !childOutput( fdno ) ) 557 if ( !childOutput( fdno ) )
558 closeStdout(); 558 closeStdout();
559} 559}
560 560
561void OProcess::slotChildError( int fdno ) 561void OProcess::slotChildError( int fdno )
562{ 562{
563 if ( !childError( fdno ) ) 563 if ( !childError( fdno ) )
564 closeStderr(); 564 closeStderr();
565} 565}
566 566
567void OProcess::slotSendData( int ) 567void OProcess::slotSendData( int )
568{ 568{
569 if ( input_sent == input_total ) 569 if ( input_sent == input_total )
570 { 570 {
571 innot->setEnabled( false ); 571 innot->setEnabled( false );
572 input_data = 0; 572 input_data = 0;
573 emit wroteStdin( this ); 573 emit wroteStdin( this );
574 } 574 }
575 else 575 else
576 input_sent += ::write( in[ 1 ], input_data + input_sent, input_total - input_sent ); 576 input_sent += ::write( in[ 1 ], input_data + input_sent, input_total - input_sent );
577} 577}
578 578
579void OProcess::processHasExited( int state ) 579void OProcess::processHasExited( int state )
580{ 580{
581 if ( runs ) 581 if ( runs )
582 { 582 {
583 runs = false; 583 runs = false;
584 status = state; 584 status = state;
585 585
586 commClose(); // cleanup communication sockets 586 commClose(); // cleanup communication sockets
587 587
588 // also emit a signal if the process was run Blocking 588 // also emit a signal if the process was run Blocking
589 if ( DontCare != run_mode ) 589 if ( DontCare != run_mode )
590 { 590 {
591 emit processExited( this ); 591 emit processExited( this );
592 } 592 }
593 } 593 }
594} 594}
595 595
596int OProcess::childOutput( int fdno ) 596int OProcess::childOutput( int fdno )
597{ 597{
598 if ( communication & NoRead ) 598 if ( communication & NoRead )
599 { 599 {
600 int len = -1; 600 int len = -1;
601 emit receivedStdout( fdno, len ); 601 emit receivedStdout( fdno, len );
602 errno = 0; // Make sure errno doesn't read "EAGAIN" 602 errno = 0; // Make sure errno doesn't read "EAGAIN"
603 return len; 603 return len;
604 } 604 }
605 else 605 else
606 { 606 {
607 char buffer[ 1024 ]; 607 char buffer[ 1024 ];
608 int len; 608 int len;
609 609
610 len = ::read( fdno, buffer, 1024 ); 610 len = ::read( fdno, buffer, 1024 );
611 611
612 if ( 0 < len ) 612 if ( 0 < len )
613 { 613 {
614 emit receivedStdout( this, buffer, len ); 614 emit receivedStdout( this, buffer, len );
615 } 615 }
616 return len; 616 return len;
617 } 617 }
618} 618}
619 619
620int OProcess::childError( int fdno ) 620int OProcess::childError( int fdno )
621{ 621{
622 char buffer[ 1024 ]; 622 char buffer[ 1024 ];
623 int len; 623 int len;
624 624
625 len = ::read( fdno, buffer, 1024 ); 625 len = ::read( fdno, buffer, 1024 );
626 626
627 if ( 0 < len ) 627 if ( 0 < len )
628 emit receivedStderr( this, buffer, len ); 628 emit receivedStderr( this, buffer, len );
629 return len; 629 return len;
630} 630}
631 631
632int OProcess::setupCommunication( Communication comm ) 632int OProcess::setupCommunication( Communication comm )
633{ 633{
634 int ok; 634 int ok;
635 635
636 communication = comm; 636 communication = comm;
637 637
638 ok = 1; 638 ok = 1;
639 if ( comm & Stdin ) 639 if ( comm & Stdin )
640 ok &= socketpair( AF_UNIX, SOCK_STREAM, 0, in ) >= 0; 640 ok &= socketpair( AF_UNIX, SOCK_STREAM, 0, in ) >= 0;
641 641
642 if ( comm & Stdout ) 642 if ( comm & Stdout )
643 ok &= socketpair( AF_UNIX, SOCK_STREAM, 0, out ) >= 0; 643 ok &= socketpair( AF_UNIX, SOCK_STREAM, 0, out ) >= 0;
644 644
645 if ( comm & Stderr ) 645 if ( comm & Stderr )
646 ok &= socketpair( AF_UNIX, SOCK_STREAM, 0, err ) >= 0; 646 ok &= socketpair( AF_UNIX, SOCK_STREAM, 0, err ) >= 0;
647 647
648 return ok; 648 return ok;
649} 649}
650 650
651int OProcess::commSetupDoneP() 651int OProcess::commSetupDoneP()
652{ 652{
653 int ok = 1; 653 int ok = 1;
654 654
655 if ( communication != NoCommunication ) 655 if ( communication != NoCommunication )
656 { 656 {
657 if ( communication & Stdin ) 657 if ( communication & Stdin )
658 close( in[ 0 ] ); 658 close( in[ 0 ] );
659 if ( communication & Stdout ) 659 if ( communication & Stdout )
660 close( out[ 1 ] ); 660 close( out[ 1 ] );
661 if ( communication & Stderr ) 661 if ( communication & Stderr )
662 close( err[ 1 ] ); 662 close( err[ 1 ] );
663 663
664 // Don't create socket notifiers and set the sockets non-blocking if 664 // Don't create socket notifiers and set the sockets non-blocking if
665 // blocking is requested. 665 // blocking is requested.
666 if ( run_mode == Block ) 666 if ( run_mode == Block )
667 return ok; 667 return ok;
668 668
669 if ( communication & Stdin ) 669 if ( communication & Stdin )
670 { 670 {
671 // ok &= (-1 != fcntl(in[1], F_SETFL, O_NONBLOCK)); 671 // ok &= (-1 != fcntl(in[1], F_SETFL, O_NONBLOCK));
672 innot = new QSocketNotifier( in[ 1 ], QSocketNotifier::Write, this ); 672 innot = new QSocketNotifier( in[ 1 ], QSocketNotifier::Write, this );
673 CHECK_PTR( innot ); 673 CHECK_PTR( innot );
674 innot->setEnabled( false ); // will be enabled when data has to be sent 674 innot->setEnabled( false ); // will be enabled when data has to be sent
675 QObject::connect( innot, SIGNAL( activated( int ) ), 675 QObject::connect( innot, SIGNAL( activated(int) ),
676 this, SLOT( slotSendData( int ) ) ); 676 this, SLOT( slotSendData(int) ) );
677 } 677 }
678 678
679 if ( communication & Stdout ) 679 if ( communication & Stdout )
680 { 680 {
681 // ok &= (-1 != fcntl(out[0], F_SETFL, O_NONBLOCK)); 681 // ok &= (-1 != fcntl(out[0], F_SETFL, O_NONBLOCK));
682 outnot = new QSocketNotifier( out[ 0 ], QSocketNotifier::Read, this ); 682 outnot = new QSocketNotifier( out[ 0 ], QSocketNotifier::Read, this );
683 CHECK_PTR( outnot ); 683 CHECK_PTR( outnot );
684 QObject::connect( outnot, SIGNAL( activated( int ) ), 684 QObject::connect( outnot, SIGNAL( activated(int) ),
685 this, SLOT( slotChildOutput( int ) ) ); 685 this, SLOT( slotChildOutput(int) ) );
686 if ( communication & NoRead ) 686 if ( communication & NoRead )
687 suspend(); 687 suspend();
688 } 688 }
689 689
690 if ( communication & Stderr ) 690 if ( communication & Stderr )
691 { 691 {
692 // ok &= (-1 != fcntl(err[0], F_SETFL, O_NONBLOCK)); 692 // ok &= (-1 != fcntl(err[0], F_SETFL, O_NONBLOCK));
693 errnot = new QSocketNotifier( err[ 0 ], QSocketNotifier::Read, this ); 693 errnot = new QSocketNotifier( err[ 0 ], QSocketNotifier::Read, this );
694 CHECK_PTR( errnot ); 694 CHECK_PTR( errnot );
695 QObject::connect( errnot, SIGNAL( activated( int ) ), 695 QObject::connect( errnot, SIGNAL( activated(int) ),
696 this, SLOT( slotChildError( int ) ) ); 696 this, SLOT( slotChildError(int) ) );
697 } 697 }
698 } 698 }
699 return ok; 699 return ok;
700} 700}
701 701
702int OProcess::commSetupDoneC() 702int OProcess::commSetupDoneC()
703{ 703{
704 int ok = 1; 704 int ok = 1;
705 struct linger so; 705 struct linger so;
706 memset( &so, 0, sizeof( so ) ); 706 memset( &so, 0, sizeof( so ) );
707 707
708 if ( communication & Stdin ) 708 if ( communication & Stdin )
709 close( in[ 1 ] ); 709 close( in[ 1 ] );
710 if ( communication & Stdout ) 710 if ( communication & Stdout )
711 close( out[ 0 ] ); 711 close( out[ 0 ] );
712 if ( communication & Stderr ) 712 if ( communication & Stderr )
713 close( err[ 0 ] ); 713 close( err[ 0 ] );
714 714
715 if ( communication & Stdin ) 715 if ( communication & Stdin )
716 ok &= dup2( in[ 0 ], STDIN_FILENO ) != -1; 716 ok &= dup2( in[ 0 ], STDIN_FILENO ) != -1;
717 else 717 else
718 { 718 {
719 int null_fd = open( "/dev/null", O_RDONLY ); 719 int null_fd = open( "/dev/null", O_RDONLY );
720 ok &= dup2( null_fd, STDIN_FILENO ) != -1; 720 ok &= dup2( null_fd, STDIN_FILENO ) != -1;
721 close( null_fd ); 721 close( null_fd );
722 } 722 }
723 if ( communication & Stdout ) 723 if ( communication & Stdout )
724 { 724 {
725 ok &= dup2( out[ 1 ], STDOUT_FILENO ) != -1; 725 ok &= dup2( out[ 1 ], STDOUT_FILENO ) != -1;
726 ok &= !setsockopt( out[ 1 ], SOL_SOCKET, SO_LINGER, ( char* ) & so, sizeof( so ) ); 726 ok &= !setsockopt( out[ 1 ], SOL_SOCKET, SO_LINGER, ( char* ) & so, sizeof( so ) );
727 } 727 }
728 else 728 else
729 { 729 {
730 int null_fd = open( "/dev/null", O_WRONLY ); 730 int null_fd = open( "/dev/null", O_WRONLY );
731 ok &= dup2( null_fd, STDOUT_FILENO ) != -1; 731 ok &= dup2( null_fd, STDOUT_FILENO ) != -1;
732 close( null_fd ); 732 close( null_fd );
733 } 733 }
734 if ( communication & Stderr ) 734 if ( communication & Stderr )
735 { 735 {
736 ok &= dup2( err[ 1 ], STDERR_FILENO ) != -1; 736 ok &= dup2( err[ 1 ], STDERR_FILENO ) != -1;
737 ok &= !setsockopt( err[ 1 ], SOL_SOCKET, SO_LINGER, reinterpret_cast<char *>( &so ), sizeof( so ) ); 737 ok &= !setsockopt( err[ 1 ], SOL_SOCKET, SO_LINGER, reinterpret_cast<char *>( &so ), sizeof( so ) );
738 } 738 }
739 else 739 else
740 { 740 {
741 int null_fd = open( "/dev/null", O_WRONLY ); 741 int null_fd = open( "/dev/null", O_WRONLY );
742 ok &= dup2( null_fd, STDERR_FILENO ) != -1; 742 ok &= dup2( null_fd, STDERR_FILENO ) != -1;
743 close( null_fd ); 743 close( null_fd );
744 } 744 }
745 return ok; 745 return ok;
746} 746}
747 747
748void OProcess::commClose() 748void OProcess::commClose()
749{ 749{
750 if ( NoCommunication != communication ) 750 if ( NoCommunication != communication )
751 { 751 {
752 bool b_in = ( communication & Stdin ); 752 bool b_in = ( communication & Stdin );
753 bool b_out = ( communication & Stdout ); 753 bool b_out = ( communication & Stdout );
754 bool b_err = ( communication & Stderr ); 754 bool b_err = ( communication & Stderr );
755 if ( b_in ) 755 if ( b_in )
756 delete innot; 756 delete innot;
757 757
758 if ( b_out || b_err ) 758 if ( b_out || b_err )
759 { 759 {
760 // If both channels are being read we need to make sure that one socket buffer 760 // If both channels are being read we need to make sure that one socket buffer
761 // doesn't fill up whilst we are waiting for data on the other (causing a deadlock). 761 // doesn't fill up whilst we are waiting for data on the other (causing a deadlock).
762 // Hence we need to use select. 762 // Hence we need to use select.
763 763
764 // Once one or other of the channels has reached EOF (or given an error) go back 764 // Once one or other of the channels has reached EOF (or given an error) go back
765 // to the usual mechanism. 765 // to the usual mechanism.
766 766
767 int fds_ready = 1; 767 int fds_ready = 1;
768 fd_set rfds; 768 fd_set rfds;
769 769
770 int max_fd = 0; 770 int max_fd = 0;
771 if ( b_out ) 771 if ( b_out )
772 { 772 {
773 fcntl( out[ 0 ], F_SETFL, O_NONBLOCK ); 773 fcntl( out[ 0 ], F_SETFL, O_NONBLOCK );
774 if ( out[ 0 ] > max_fd ) 774 if ( out[ 0 ] > max_fd )
775 max_fd = out[ 0 ]; 775 max_fd = out[ 0 ];
776 delete outnot; 776 delete outnot;
777 outnot = 0; 777 outnot = 0;
778 } 778 }
779 if ( b_err ) 779 if ( b_err )
780 { 780 {
781 fcntl( err[ 0 ], F_SETFL, O_NONBLOCK ); 781 fcntl( err[ 0 ], F_SETFL, O_NONBLOCK );
782 if ( err[ 0 ] > max_fd ) 782 if ( err[ 0 ] > max_fd )
783 max_fd = err[ 0 ]; 783 max_fd = err[ 0 ];
784 delete errnot; 784 delete errnot;
785 errnot = 0; 785 errnot = 0;
786 } 786 }
787 787
788 788
789 while ( b_out || b_err ) 789 while ( b_out || b_err )
790 { 790 {
791 // * If the process is still running we block until we 791 // * If the process is still running we block until we
792 // receive data. (p_timeout = 0, no timeout) 792 // receive data. (p_timeout = 0, no timeout)
793 // * If the process has already exited, we only check 793 // * If the process has already exited, we only check
794 // the available data, we don't wait for more. 794 // the available data, we don't wait for more.
795 // (p_timeout = &timeout, timeout immediately) 795 // (p_timeout = &timeout, timeout immediately)
796 struct timeval timeout; 796 struct timeval timeout;
797 timeout.tv_sec = 0; 797 timeout.tv_sec = 0;
798 timeout.tv_usec = 0; 798 timeout.tv_usec = 0;
799 struct timeval *p_timeout = runs ? 0 : &timeout; 799 struct timeval *p_timeout = runs ? 0 : &timeout;
800 800
801 FD_ZERO( &rfds ); 801 FD_ZERO( &rfds );
802 if ( b_out ) 802 if ( b_out )
803 FD_SET( out[ 0 ], &rfds ); 803 FD_SET( out[ 0 ], &rfds );
804 804
805 if ( b_err ) 805 if ( b_err )
806 FD_SET( err[ 0 ], &rfds ); 806 FD_SET( err[ 0 ], &rfds );
807 807
808 fds_ready = select( max_fd + 1, &rfds, 0, 0, p_timeout ); 808 fds_ready = select( max_fd + 1, &rfds, 0, 0, p_timeout );
809 if ( fds_ready <= 0 ) 809 if ( fds_ready <= 0 )
810 break; 810 break;
811 811
812 if ( b_out && FD_ISSET( out[ 0 ], &rfds ) ) 812 if ( b_out && FD_ISSET( out[ 0 ], &rfds ) )
813 { 813 {
814 int ret = 1; 814 int ret = 1;
815 while ( ret > 0 ) 815 while ( ret > 0 )
816 ret = childOutput( out[ 0 ] ); 816 ret = childOutput( out[ 0 ] );
817 if ( ( ret == -1 && errno != EAGAIN ) || ret == 0 ) 817 if ( ( ret == -1 && errno != EAGAIN ) || ret == 0 )
818 b_out = false; 818 b_out = false;
819 } 819 }
820 820
821 if ( b_err && FD_ISSET( err[ 0 ], &rfds ) ) 821 if ( b_err && FD_ISSET( err[ 0 ], &rfds ) )
822 { 822 {
823 int ret = 1; 823 int ret = 1;
824 while ( ret > 0 ) 824 while ( ret > 0 )
825 ret = childError( err[ 0 ] ); 825 ret = childError( err[ 0 ] );
826 if ( ( ret == -1 && errno != EAGAIN ) || ret == 0 ) 826 if ( ( ret == -1 && errno != EAGAIN ) || ret == 0 )
827 b_err = false; 827 b_err = false;
828 } 828 }
829 } 829 }
830 } 830 }
831 831
832 if ( b_in ) 832 if ( b_in )
833 { 833 {
834 communication = ( Communication ) ( communication & ~Stdin ); 834 communication = ( Communication ) ( communication & ~Stdin );
835 close( in[ 1 ] ); 835 close( in[ 1 ] );
836 } 836 }
837 if ( b_out ) 837 if ( b_out )
838 { 838 {
839 communication = ( Communication ) ( communication & ~Stdout ); 839 communication = ( Communication ) ( communication & ~Stdout );
840 close( out[ 0 ] ); 840 close( out[ 0 ] );
841 } 841 }
842 if ( b_err ) 842 if ( b_err )
843 { 843 {
844 communication = ( Communication ) ( communication & ~Stderr ); 844 communication = ( Communication ) ( communication & ~Stderr );
845 close( err[ 0 ] ); 845 close( err[ 0 ] );
846 } 846 }
847 } 847 }
848} 848}
849 849
850void OProcess::setUseShell( bool useShell, const char *shell ) 850void OProcess::setUseShell( bool useShell, const char *shell )
851{ 851{
852 if ( !d ) 852 if ( !d )
853 d = new OProcessPrivate; 853 d = new OProcessPrivate;
854 d->useShell = useShell; 854 d->useShell = useShell;
855 d->shell = shell; 855 d->shell = shell;
856 if ( d->shell.isEmpty() ) 856 if ( d->shell.isEmpty() )
857 d->shell = searchShell(); 857 d->shell = searchShell();
858} 858}
859 859
860QString OProcess::quote( const QString &arg ) 860QString OProcess::quote( const QString &arg )
861{ 861{
862 QString res = arg; 862 QString res = arg;
863 res.replace( QRegExp( QString::fromLatin1( "\'" ) ), 863 res.replace( QRegExp( QString::fromLatin1( "\'" ) ),
864 QString::fromLatin1( "'\"'\"'" ) ); 864 QString::fromLatin1( "'\"'\"'" ) );
865 res.prepend( '\'' ); 865 res.prepend( '\'' );
866 res.append( '\'' ); 866 res.append( '\'' );
867 return res; 867 return res;
868} 868}
869 869
870QCString OProcess::searchShell() 870QCString OProcess::searchShell()
871{ 871{
872 QCString tmpShell = QCString( getenv( "SHELL" ) ).stripWhiteSpace(); 872 QCString tmpShell = QCString( getenv( "SHELL" ) ).stripWhiteSpace();
873 if ( !isExecutable( tmpShell ) ) 873 if ( !isExecutable( tmpShell ) )
874 { 874 {
875 tmpShell = "/bin/sh"; 875 tmpShell = "/bin/sh";
876 } 876 }
877 877
878 return tmpShell; 878 return tmpShell;
879} 879}
880 880
881bool OProcess::isExecutable( const QCString &filename ) 881bool OProcess::isExecutable( const QCString &filename )
882{ 882{
883 struct stat fileinfo; 883 struct stat fileinfo;
884 884
885 if ( filename.isEmpty() ) 885 if ( filename.isEmpty() )
886 return false; 886 return false;
887 887
888 // CC: we've got a valid filename, now let's see whether we can execute that file 888 // CC: we've got a valid filename, now let's see whether we can execute that file
diff --git a/libopie2/opiepim/core/ocontactaccess.cpp b/libopie2/opiepim/core/ocontactaccess.cpp
index c12e138..4f9b504 100644
--- a/libopie2/opiepim/core/ocontactaccess.cpp
+++ b/libopie2/opiepim/core/ocontactaccess.cpp
@@ -1,152 +1,152 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) The Main Author <main-author@whereever.org> 3 Copyright (C) The Main Author <main-author@whereever.org>
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org> 4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 .=l. 5 .=l.
6 .>+-= 6 .>+-=
7 _;:, .> :=|. This program is free software; you can 7 _;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under 8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11 - . .-<_> .<> Foundation; either version 2 of the License, 11 - . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_. 13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 20++= -. .` .: details.
21 : = ...= . :.=- 21 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU 22 -. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29/* 29/*
30 * ===================================================================== 30 * =====================================================================
31 * ToDo: XML-Backend: Automatic reload if something was changed... 31 * ToDo: XML-Backend: Automatic reload if something was changed...
32 * 32 *
33 * 33 *
34 */ 34 */
35 35
36#include "ocontactaccess.h" 36#include "ocontactaccess.h"
37#include "obackendfactory.h" 37#include "obackendfactory.h"
38 38
39#include <qasciidict.h> 39#include <qasciidict.h>
40#include <qdatetime.h> 40#include <qdatetime.h>
41#include <qfile.h> 41#include <qfile.h>
42#include <qregexp.h> 42#include <qregexp.h>
43#include <qlist.h> 43#include <qlist.h>
44#include <qcopchannel_qws.h> 44#include <qcopchannel_qws.h>
45 45
46//#include <qpe/qcopenvelope_qws.h> 46//#include <qpe/qcopenvelope_qws.h>
47#include <qpe/global.h> 47#include <qpe/global.h>
48 48
49#include <errno.h> 49#include <errno.h>
50#include <fcntl.h> 50#include <fcntl.h>
51#include <unistd.h> 51#include <unistd.h>
52#include <stdlib.h> 52#include <stdlib.h>
53 53
54#include <opie2/ocontactaccessbackend_xml.h> 54#include <opie2/ocontactaccessbackend_xml.h>
55 55
56namespace Opie { 56namespace Opie {
57 57
58OPimContactAccess::OPimContactAccess ( const QString appname, const QString , 58OPimContactAccess::OPimContactAccess ( const QString appname, const QString ,
59 OPimContactAccessBackend* end, bool autosync ): 59 OPimContactAccessBackend* end, bool autosync ):
60 OPimAccessTemplate<OPimContact>( end ) 60 OPimAccessTemplate<OPimContact>( end )
61{ 61{
62 /* take care of the backend. If there is no one defined, we 62 /* take care of the backend. If there is no one defined, we
63 * will use the XML-Backend as default (until we have a cute SQL-Backend..). 63 * will use the XML-Backend as default (until we have a cute SQL-Backend..).
64 */ 64 */
65 if( end == 0 ) { 65 if( end == 0 ) {
66 qWarning ("Using BackendFactory !"); 66 qWarning ("Using BackendFactory !");
67 end = OBackendFactory<OPimContactAccessBackend>::Default( "contact", appname ); 67 end = OBackendFactory<OPimContactAccessBackend>::Default( "contact", appname );
68 } 68 }
69 // Set backend locally and in template 69 // Set backend locally and in template
70 m_backEnd = end; 70 m_backEnd = end;
71 OPimAccessTemplate<OPimContact>::setBackEnd (end); 71 OPimAccessTemplate<OPimContact>::setBackEnd (end);
72 72
73 73
74 /* Connect signal of external db change to function */ 74 /* Connect signal of external db change to function */
75 QCopChannel *dbchannel = new QCopChannel( "QPE/PIM", this ); 75 QCopChannel *dbchannel = new QCopChannel( "QPE/PIM", this );
76 connect( dbchannel, SIGNAL(received(const QCString &, const QByteArray &)), 76 connect( dbchannel, SIGNAL(received(const QCString&,const QByteArray&)),
77 this, SLOT(copMessage( const QCString &, const QByteArray &)) ); 77 this, SLOT(copMessage(const QCString&,const QByteArray&)) );
78 if ( autosync ){ 78 if ( autosync ){
79 QCopChannel *syncchannel = new QCopChannel( "QPE/Sync", this ); 79 QCopChannel *syncchannel = new QCopChannel( "QPE/Sync", this );
80 connect( syncchannel, SIGNAL(received(const QCString &, const QByteArray &)), 80 connect( syncchannel, SIGNAL(received(const QCString&,const QByteArray&)),
81 this, SLOT(copMessage( const QCString &, const QByteArray &)) ); 81 this, SLOT(copMessage(const QCString&,const QByteArray&)) );
82 } 82 }
83 83
84 84
85} 85}
86OPimContactAccess::~OPimContactAccess () 86OPimContactAccess::~OPimContactAccess ()
87{ 87{
88 /* The user may forget to save the changed database, therefore try to 88 /* The user may forget to save the changed database, therefore try to
89 * do it for him.. 89 * do it for him..
90 */ 90 */
91 save(); 91 save();
92 // delete m_backEnd; is done by template.. 92 // delete m_backEnd; is done by template..
93} 93}
94 94
95 95
96bool OPimContactAccess::save () 96bool OPimContactAccess::save ()
97{ 97{
98 /* If the database was changed externally, we could not save the 98 /* If the database was changed externally, we could not save the
99 * Data. This will remove added items which is unacceptable ! 99 * Data. This will remove added items which is unacceptable !
100 * Therefore: Reload database and merge the data... 100 * Therefore: Reload database and merge the data...
101 */ 101 */
102 if ( OPimAccessTemplate<OPimContact>::wasChangedExternally() ) 102 if ( OPimAccessTemplate<OPimContact>::wasChangedExternally() )
103 reload(); 103 reload();
104 104
105 bool status = OPimAccessTemplate<OPimContact>::save(); 105 bool status = OPimAccessTemplate<OPimContact>::save();
106 if ( !status ) return false; 106 if ( !status ) return false;
107 107
108 /* Now tell everyone that new data is available. 108 /* Now tell everyone that new data is available.
109 */ 109 */
110 QCopEnvelope e( "QPE/PIM", "addressbookUpdated()" ); 110 QCopEnvelope e( "QPE/PIM", "addressbookUpdated()" );
111 111
112 return true; 112 return true;
113} 113}
114 114
115const uint OPimContactAccess::querySettings() 115const uint OPimContactAccess::querySettings()
116{ 116{
117 return ( m_backEnd->querySettings() ); 117 return ( m_backEnd->querySettings() );
118} 118}
119 119
120bool OPimContactAccess::hasQuerySettings ( int querySettings ) const 120bool OPimContactAccess::hasQuerySettings ( int querySettings ) const
121{ 121{
122 return ( m_backEnd->hasQuerySettings ( querySettings ) ); 122 return ( m_backEnd->hasQuerySettings ( querySettings ) );
123} 123}
124OPimRecordList<OPimContact> OPimContactAccess::sorted( bool ascending, int sortOrder, int sortFilter, int cat ) const 124OPimRecordList<OPimContact> OPimContactAccess::sorted( bool ascending, int sortOrder, int sortFilter, int cat ) const
125{ 125{
126 QArray<int> matchingContacts = m_backEnd -> sorted( ascending, sortOrder, sortFilter, cat ); 126 QArray<int> matchingContacts = m_backEnd -> sorted( ascending, sortOrder, sortFilter, cat );
127 return ( OPimRecordList<OPimContact>(matchingContacts, this) ); 127 return ( OPimRecordList<OPimContact>(matchingContacts, this) );
128} 128}
129 129
130 130
131bool OPimContactAccess::wasChangedExternally()const 131bool OPimContactAccess::wasChangedExternally()const
132{ 132{
133 return ( m_backEnd->wasChangedExternally() ); 133 return ( m_backEnd->wasChangedExternally() );
134} 134}
135 135
136 136
137void OPimContactAccess::copMessage( const QCString &msg, const QByteArray & ) 137void OPimContactAccess::copMessage( const QCString &msg, const QByteArray & )
138{ 138{
139 if ( msg == "addressbookUpdated()" ){ 139 if ( msg == "addressbookUpdated()" ){
140 qWarning ("OPimContactAccess: Received addressbokUpdated()"); 140 qWarning ("OPimContactAccess: Received addressbokUpdated()");
141 emit signalChanged ( this ); 141 emit signalChanged ( this );
142 } else if ( msg == "flush()" ) { 142 } else if ( msg == "flush()" ) {
143 qWarning ("OPimContactAccess: Received flush()"); 143 qWarning ("OPimContactAccess: Received flush()");
144 save (); 144 save ();
145 } else if ( msg == "reload()" ) { 145 } else if ( msg == "reload()" ) {
146 qWarning ("OPimContactAccess: Received reload()"); 146 qWarning ("OPimContactAccess: Received reload()");
147 reload (); 147 reload ();
148 emit signalChanged ( this ); 148 emit signalChanged ( this );
149 } 149 }
150} 150}
151 151
152} 152}
diff --git a/libopie2/opiepim/ui/opimmainwindow.cpp b/libopie2/opiepim/ui/opimmainwindow.cpp
index 10ed743..40dc297 100644
--- a/libopie2/opiepim/ui/opimmainwindow.cpp
+++ b/libopie2/opiepim/ui/opimmainwindow.cpp
@@ -1,181 +1,181 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de) 3 Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de)
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org> 4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 .=l. 5 .=l.
6 .>+-= 6 .>+-=
7 _;:, .> :=|. This program is free software; you can 7 _;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under 8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11 - . .-<_> .<> Foundation; either version 2 of the License, 11 - . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_. 13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 20++= -. .` .: details.
21 : = ...= . :.=- 21 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU 22 -. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29#include <qapplication.h> 29#include <qapplication.h>
30#include <qdatetime.h> 30#include <qdatetime.h>
31#include <qcopchannel_qws.h> 31#include <qcopchannel_qws.h>
32 32
33#include <qpe/sound.h> 33#include <qpe/sound.h>
34#include <qpe/qcopenvelope_qws.h> 34#include <qpe/qcopenvelope_qws.h>
35#include <qpe/qpeapplication.h> 35#include <qpe/qpeapplication.h>
36 36
37#include <opie2/opimresolver.h> 37#include <opie2/opimresolver.h>
38#include "opimmainwindow.h" 38#include "opimmainwindow.h"
39 39
40namespace Opie { 40namespace Opie {
41OPimMainWindow::OPimMainWindow( const QString& service, QWidget* parent, 41OPimMainWindow::OPimMainWindow( const QString& service, QWidget* parent,
42 const char* name, WFlags flag ) 42 const char* name, WFlags flag )
43 : QMainWindow( parent, name, flag ), m_rtti(-1), m_service( service ), m_fallBack(0l) { 43 : QMainWindow( parent, name, flag ), m_rtti(-1), m_service( service ), m_fallBack(0l) {
44 44
45 /* 45 /*
46 * let's generate our QCopChannel 46 * let's generate our QCopChannel
47 */ 47 */
48 m_str = QString("QPE/"+m_service).local8Bit(); 48 m_str = QString("QPE/"+m_service).local8Bit();
49 m_channel= new QCopChannel(m_str, this ); 49 m_channel= new QCopChannel(m_str, this );
50 connect(m_channel, SIGNAL(received(const QCString&, const QByteArray& ) ), 50 connect(m_channel, SIGNAL(received(const QCString&,const QByteArray&) ),
51 this, SLOT( appMessage( const QCString&, const QByteArray& ) ) ); 51 this, SLOT( appMessage(const QCString&,const QByteArray&) ) );
52 connect(qApp, SIGNAL(appMessage(const QCString&, const QByteArray& ) ), 52 connect(qApp, SIGNAL(appMessage(const QCString&,const QByteArray&) ),
53 this, SLOT( appMessage( const QCString&, const QByteArray& ) ) ); 53 this, SLOT( appMessage(const QCString&,const QByteArray&) ) );
54 54
55 /* connect flush and reload */ 55 /* connect flush and reload */
56 connect(qApp, SIGNAL(flush() ), 56 connect(qApp, SIGNAL(flush() ),
57 this, SLOT(flush() ) ); 57 this, SLOT(flush() ) );
58 connect(qApp, SIGNAL(reload() ), 58 connect(qApp, SIGNAL(reload() ),
59 this, SLOT(reload() ) ); 59 this, SLOT(reload() ) );
60} 60}
61OPimMainWindow::~OPimMainWindow() { 61OPimMainWindow::~OPimMainWindow() {
62 delete m_channel; 62 delete m_channel;
63} 63}
64QCopChannel* OPimMainWindow::channel() { 64QCopChannel* OPimMainWindow::channel() {
65 return m_channel; 65 return m_channel;
66} 66}
67void OPimMainWindow::doSetDocument( const QString& ) { 67void OPimMainWindow::doSetDocument( const QString& ) {
68 68
69} 69}
70void OPimMainWindow::appMessage( const QCString& cmd, const QByteArray& array ) { 70void OPimMainWindow::appMessage( const QCString& cmd, const QByteArray& array ) {
71 bool needShow = false; 71 bool needShow = false;
72 /* 72 /*
73 * create demands to create 73 * create demands to create
74 * a new record... 74 * a new record...
75 */ 75 */
76 QDataStream stream(array, IO_ReadOnly); 76 QDataStream stream(array, IO_ReadOnly);
77 if ( cmd == "create()" ) { 77 if ( cmd == "create()" ) {
78 raise(); 78 raise();
79 int uid = create(); 79 int uid = create();
80 QCopEnvelope e(m_str, "created(int)" ); 80 QCopEnvelope e(m_str, "created(int)" );
81 e << uid; 81 e << uid;
82 needShow = true; 82 needShow = true;
83 }else if ( cmd == "remove(int)" ) { 83 }else if ( cmd == "remove(int)" ) {
84 int uid; 84 int uid;
85 stream >> uid; 85 stream >> uid;
86 bool rem = remove( uid ); 86 bool rem = remove( uid );
87 QCopEnvelope e(m_str, "removed(bool)" ); 87 QCopEnvelope e(m_str, "removed(bool)" );
88 e << rem; 88 e << rem;
89 needShow = true; 89 needShow = true;
90 }else if ( cmd == "beam(int)" ) { 90 }else if ( cmd == "beam(int)" ) {
91 int uid; 91 int uid;
92 stream >> uid; 92 stream >> uid;
93 beam( uid); 93 beam( uid);
94 }else if ( cmd == "show(int)" ) { 94 }else if ( cmd == "show(int)" ) {
95 raise(); 95 raise();
96 int uid; 96 int uid;
97 stream >> uid; 97 stream >> uid;
98 show( uid ); 98 show( uid );
99 needShow = true; 99 needShow = true;
100 }else if ( cmd == "edit(int)" ) { 100 }else if ( cmd == "edit(int)" ) {
101 raise(); 101 raise();
102 int uid; 102 int uid;
103 stream >> uid; 103 stream >> uid;
104 edit( uid ); 104 edit( uid );
105 }else if ( cmd == "add(int,QByteArray)" ) { 105 }else if ( cmd == "add(int,QByteArray)" ) {
106 int rtti; 106 int rtti;
107 QByteArray array; 107 QByteArray array;
108 stream >> rtti; 108 stream >> rtti;
109 stream >> array; 109 stream >> array;
110 m_fallBack = record(rtti, array ); 110 m_fallBack = record(rtti, array );
111 if (!m_fallBack) return; 111 if (!m_fallBack) return;
112 add( *m_fallBack ); 112 add( *m_fallBack );
113 delete m_fallBack; 113 delete m_fallBack;
114 }else if ( cmd == "alarm(QDateTime,int)" ) { 114 }else if ( cmd == "alarm(QDateTime,int)" ) {
115 raise(); 115 raise();
116 QDateTime dt; int uid; 116 QDateTime dt; int uid;
117 stream >> dt; 117 stream >> dt;
118 stream >> uid; 118 stream >> uid;
119 qWarning(" Date: %s Uid: %d", dt.toString().latin1(), uid ); 119 qWarning(" Date: %s Uid: %d", dt.toString().latin1(), uid );
120 QDateTime current = QDateTime::currentDateTime(); 120 QDateTime current = QDateTime::currentDateTime();
121 if ( current.time().hour() != dt.time().hour() && current.time().minute() != dt.time().minute() ) 121 if ( current.time().hour() != dt.time().hour() && current.time().minute() != dt.time().minute() )
122 return; 122 return;
123 doAlarm( dt, uid ); 123 doAlarm( dt, uid );
124 needShow = true; 124 needShow = true;
125 } 125 }
126 126
127 if (needShow ) 127 if (needShow )
128 QPEApplication::setKeepRunning(); 128 QPEApplication::setKeepRunning();
129} 129}
130/* implement the url scripting here */ 130/* implement the url scripting here */
131void OPimMainWindow::setDocument( const QString& str) { 131void OPimMainWindow::setDocument( const QString& str) {
132 doSetDocument( str ); 132 doSetDocument( str );
133} 133}
134/* 134/*
135 * we now try to get the array demarshalled 135 * we now try to get the array demarshalled
136 * check if the rtti matches this one 136 * check if the rtti matches this one
137 */ 137 */
138OPimRecord* OPimMainWindow::record( int rtti, const QByteArray& array ) { 138OPimRecord* OPimMainWindow::record( int rtti, const QByteArray& array ) {
139 if ( service() != rtti ) 139 if ( service() != rtti )
140 return 0l; 140 return 0l;
141 141
142 OPimRecord* record = OPimResolver::self()->record( rtti ); 142 OPimRecord* record = OPimResolver::self()->record( rtti );
143 QDataStream str(array, IO_ReadOnly ); 143 QDataStream str(array, IO_ReadOnly );
144 if ( !record || !record->loadFromStream(str) ) { 144 if ( !record || !record->loadFromStream(str) ) {
145 delete record; 145 delete record;
146 record = 0l; 146 record = 0l;
147 } 147 }
148 148
149 return record; 149 return record;
150} 150}
151/* 151/*
152 * get the rtti for the service 152 * get the rtti for the service
153 */ 153 */
154int OPimMainWindow::service() { 154int OPimMainWindow::service() {
155 if ( m_rtti == -1 ) 155 if ( m_rtti == -1 )
156 m_rtti = OPimResolver::self()->serviceId( m_service ); 156 m_rtti = OPimResolver::self()->serviceId( m_service );
157 157
158 return m_rtti; 158 return m_rtti;
159} 159}
160void OPimMainWindow::doAlarm( const QDateTime&, int ) { 160void OPimMainWindow::doAlarm( const QDateTime&, int ) {
161 161
162} 162}
163void OPimMainWindow::startAlarm(int count ) { 163void OPimMainWindow::startAlarm(int count ) {
164 m_alarmCount = count; 164 m_alarmCount = count;
165 m_playedCount = 0; 165 m_playedCount = 0;
166 Sound::soundAlarm(); 166 Sound::soundAlarm();
167 m_timerId = startTimer( 5000 ); 167 m_timerId = startTimer( 5000 );
168} 168}
169void OPimMainWindow::killAlarm() { 169void OPimMainWindow::killAlarm() {
170 killTimer( m_timerId ); 170 killTimer( m_timerId );
171} 171}
172void OPimMainWindow::timerEvent( QTimerEvent* e) { 172void OPimMainWindow::timerEvent( QTimerEvent* e) {
173 if ( m_playedCount <m_alarmCount ) { 173 if ( m_playedCount <m_alarmCount ) {
174 m_playedCount++; 174 m_playedCount++;
175 Sound::soundAlarm(); 175 Sound::soundAlarm();
176 }else { 176 }else {
177 killTimer( e->timerId() ); 177 killTimer( e->timerId() );
178 } 178 }
179} 179}
180 180
181} 181}
diff --git a/libopie2/opiepim/ui/opimrecurrencewidget.cpp b/libopie2/opiepim/ui/opimrecurrencewidget.cpp
index 569bdd5..90c1a5f 100644
--- a/libopie2/opiepim/ui/opimrecurrencewidget.cpp
+++ b/libopie2/opiepim/ui/opimrecurrencewidget.cpp
@@ -363,272 +363,272 @@ void OPimRecurrenceWidget::slotWeekLabel() {
363 list.append( dayLabel[i - 1] ); 363 list.append( dayLabel[i - 1] );
364 } 364 }
365 } 365 }
366 } 366 }
367 QStringList::Iterator itStr; 367 QStringList::Iterator itStr;
368 for ( i = 0, itStr = list.begin(); itStr != list.end(); ++itStr, i++ ) { 368 for ( i = 0, itStr = list.begin(); itStr != list.end(); ++itStr, i++ ) {
369 if ( i == 3 ) 369 if ( i == 3 )
370 bNeedCarriage = TRUE; 370 bNeedCarriage = TRUE;
371 else 371 else
372 bNeedCarriage = FALSE; 372 bNeedCarriage = FALSE;
373 if ( str.isNull() ) 373 if ( str.isNull() )
374 str = *itStr; 374 str = *itStr;
375 else if ( i == list.count() - 1 ) { 375 else if ( i == list.count() - 1 ) {
376 if ( i < 2 ) 376 if ( i < 2 )
377 str += tr(" and ") + *itStr; 377 str += tr(" and ") + *itStr;
378 else { 378 else {
379 if ( bNeedCarriage ) 379 if ( bNeedCarriage )
380 str += tr( ",\nand " ) + *itStr; 380 str += tr( ",\nand " ) + *itStr;
381 else 381 else
382 str += tr( ", and " ) + *itStr; 382 str += tr( ", and " ) + *itStr;
383 } 383 }
384 } else { 384 } else {
385 if ( bNeedCarriage ) 385 if ( bNeedCarriage )
386 str += ",\n" + *itStr; 386 str += ",\n" + *itStr;
387 else 387 else
388 str += ", " + *itStr; 388 str += ", " + *itStr;
389 } 389 }
390 } 390 }
391 str = str.prepend( tr("on ") ); 391 str = str.prepend( tr("on ") );
392 392
393 lblWeekVar->setText( str ); 393 lblWeekVar->setText( str );
394} 394}
395void OPimRecurrenceWidget::slotMonthLabel(int type) { 395void OPimRecurrenceWidget::slotMonthLabel(int type) {
396 QString str; 396 QString str;
397 if ( currInterval != Month || type > 1 ) 397 if ( currInterval != Month || type > 1 )
398 return; 398 return;
399 if ( type == 1 ) 399 if ( type == 1 )
400 str = strMonthDateTemplate.arg( numberPlacing(start.day()) ); 400 str = strMonthDateTemplate.arg( numberPlacing(start.day()) );
401 else 401 else
402 str = strMonthDayTemplate.arg( numberPlacing(week(start))) 402 str = strMonthDayTemplate.arg( numberPlacing(week(start)))
403 .arg( dayLabel[start.dayOfWeek() - 1] ); 403 .arg( dayLabel[start.dayOfWeek() - 1] );
404 lblRepeat->setText( str ); 404 lblRepeat->setText( str );
405} 405}
406void OPimRecurrenceWidget::slotChangeStartOfWeek( bool onMonday ) { 406void OPimRecurrenceWidget::slotChangeStartOfWeek( bool onMonday ) {
407 startWeekOnMonday = onMonday; 407 startWeekOnMonday = onMonday;
408 // we need to make this unintrusive as possible... 408 // we need to make this unintrusive as possible...
409 int saveSpin = spinFreq->value(); 409 int saveSpin = spinFreq->value();
410 char days = 0; 410 char days = 0;
411 int day; 411 int day;
412 QListIterator<QToolButton> itExtra( listExtra ); 412 QListIterator<QToolButton> itExtra( listExtra );
413 for ( day = 1; *itExtra; ++itExtra, day = day << 1 ) { 413 for ( day = 1; *itExtra; ++itExtra, day = day << 1 ) {
414 if ( (*itExtra)->isOn() ) { 414 if ( (*itExtra)->isOn() ) {
415 if ( !startWeekOnMonday ) 415 if ( !startWeekOnMonday )
416 days |= day; 416 days |= day;
417 else { 417 else {
418 if ( day == 1 ) 418 if ( day == 1 )
419 days |= OPimRecurrence::SUN; 419 days |= OPimRecurrence::SUN;
420 else 420 else
421 days |= day >> 1; 421 days |= day >> 1;
422 } 422 }
423 } 423 }
424 } 424 }
425 setupWeekly(); 425 setupWeekly();
426 spinFreq->setValue( saveSpin ); 426 spinFreq->setValue( saveSpin );
427 int buttons; 427 int buttons;
428 for ( day = 0x01, buttons = 0; buttons < 7; 428 for ( day = 0x01, buttons = 0; buttons < 7;
429 day = day << 1, buttons++ ) { 429 day = day << 1, buttons++ ) {
430 if ( days & day ) { 430 if ( days & day ) {
431 if ( startWeekOnMonday ) 431 if ( startWeekOnMonday )
432 fraExtra->setButton( buttons ); 432 fraExtra->setButton( buttons );
433 else { 433 else {
434 if ( buttons == 7 ) 434 if ( buttons == 7 )
435 fraExtra->setButton( 0 ); 435 fraExtra->setButton( 0 );
436 else 436 else
437 fraExtra->setButton( buttons + 1 ); 437 fraExtra->setButton( buttons + 1 );
438 } 438 }
439 } 439 }
440 } 440 }
441 slotWeekLabel(); 441 slotWeekLabel();
442} 442}
443void OPimRecurrenceWidget::setupNone() { 443void OPimRecurrenceWidget::setupNone() {
444 lblRepeat->setText( tr("No Repeat") ); 444 lblRepeat->setText( tr("No Repeat") );
445 lblVar1->hide(); 445 lblVar1->hide();
446 lblVar2->hide(); 446 lblVar2->hide();
447 hideExtras(); 447 hideExtras();
448 cmdEnd->hide(); 448 cmdEnd->hide();
449 lblFreq->hide(); 449 lblFreq->hide();
450 lblEvery->hide(); 450 lblEvery->hide();
451 lblFreq->hide(); 451 lblFreq->hide();
452 spinFreq->hide(); 452 spinFreq->hide();
453 lblEnd->hide(); 453 lblEnd->hide();
454 lblWeekVar->hide(); 454 lblWeekVar->hide();
455} 455}
456void OPimRecurrenceWidget::setupDaily() { 456void OPimRecurrenceWidget::setupDaily() {
457 hideExtras(); 457 hideExtras();
458 lblWeekVar->hide(); 458 lblWeekVar->hide();
459 spinFreq->setValue( 1 ); 459 spinFreq->setValue( 1 );
460 lblFreq->setText( tr("day(s)") ); 460 lblFreq->setText( tr("day(s)") );
461 lblVar2->show(); 461 lblVar2->show();
462 showRepeatStuff(); 462 showRepeatStuff();
463 lblRepeat->setText( strDayTemplate ); 463 lblRepeat->setText( strDayTemplate );
464 setupRepeatLabel( 1 ); 464 setupRepeatLabel( 1 );
465} 465}
466void OPimRecurrenceWidget::setupWeekly() { 466void OPimRecurrenceWidget::setupWeekly() {
467// reshow the buttons... 467// reshow the buttons...
468 fraExtra->setTitle( tr("Repeat On") ); 468 fraExtra->setTitle( tr("Repeat On") );
469 fraExtra->setExclusive( FALSE ); 469 fraExtra->setExclusive( FALSE );
470 fraExtra->show(); 470 fraExtra->show();
471 if ( startWeekOnMonday ) { 471 if ( startWeekOnMonday ) {
472 cmdExtra1->setText( tr("Mon") ); 472 cmdExtra1->setText( tr("Mon") );
473 cmdExtra2->setText( tr("Tue") ); 473 cmdExtra2->setText( tr("Tue") );
474 cmdExtra3->setText( tr("Wed") ); 474 cmdExtra3->setText( tr("Wed") );
475 cmdExtra4->setText( tr("Thu") ); 475 cmdExtra4->setText( tr("Thu") );
476 cmdExtra5->setText( tr("Fri") ); 476 cmdExtra5->setText( tr("Fri") );
477 cmdExtra6->setText( tr("Sat") ); 477 cmdExtra6->setText( tr("Sat") );
478 cmdExtra7->setText( tr("Sun") ); 478 cmdExtra7->setText( tr("Sun") );
479 } else { 479 } else {
480 cmdExtra1->setText( tr("Sun") ); 480 cmdExtra1->setText( tr("Sun") );
481 cmdExtra2->setText( tr("Mon") ); 481 cmdExtra2->setText( tr("Mon") );
482 cmdExtra3->setText( tr("Tue") ); 482 cmdExtra3->setText( tr("Tue") );
483 cmdExtra4->setText( tr("Wed") ); 483 cmdExtra4->setText( tr("Wed") );
484 cmdExtra5->setText( tr("Thu") ); 484 cmdExtra5->setText( tr("Thu") );
485 cmdExtra6->setText( tr("Fri") ); 485 cmdExtra6->setText( tr("Fri") );
486 cmdExtra7->setText( tr("Sat") ); 486 cmdExtra7->setText( tr("Sat") );
487 } 487 }
488 // I hope clustering these improve performance.... 488 // I hope clustering these improve performance....
489 cmdExtra1->setOn( FALSE ); 489 cmdExtra1->setOn( FALSE );
490 cmdExtra2->setOn( FALSE ); 490 cmdExtra2->setOn( FALSE );
491 cmdExtra3->setOn( FALSE ); 491 cmdExtra3->setOn( FALSE );
492 cmdExtra4->setOn( FALSE ); 492 cmdExtra4->setOn( FALSE );
493 cmdExtra5->setOn( FALSE ); 493 cmdExtra5->setOn( FALSE );
494 cmdExtra6->setOn( FALSE ); 494 cmdExtra6->setOn( FALSE );
495 cmdExtra7->setOn( FALSE ); 495 cmdExtra7->setOn( FALSE );
496 496
497 cmdExtra1->show(); 497 cmdExtra1->show();
498 cmdExtra2->show(); 498 cmdExtra2->show();
499 cmdExtra3->show(); 499 cmdExtra3->show();
500 cmdExtra4->show(); 500 cmdExtra4->show();
501 cmdExtra5->show(); 501 cmdExtra5->show();
502 cmdExtra6->show(); 502 cmdExtra6->show();
503 cmdExtra7->show(); 503 cmdExtra7->show();
504 504
505 lblWeekVar->show(); 505 lblWeekVar->show();
506 spinFreq->setValue( 1 ); 506 spinFreq->setValue( 1 );
507 // might as well set the day too... 507 // might as well set the day too...
508 if ( startWeekOnMonday ) { 508 if ( startWeekOnMonday ) {
509 fraExtra->setButton( start.dayOfWeek() - 1 ); 509 fraExtra->setButton( start.dayOfWeek() - 1 );
510 } else { 510 } else {
511 fraExtra->setButton( start.dayOfWeek() % 7 ); 511 fraExtra->setButton( start.dayOfWeek() % 7 );
512 } 512 }
513 lblFreq->setText( tr("week(s)") ); 513 lblFreq->setText( tr("week(s)") );
514 lblVar2->show(); 514 lblVar2->show();
515 showRepeatStuff(); 515 showRepeatStuff();
516 setupRepeatLabel( 1 ); 516 setupRepeatLabel( 1 );
517} 517}
518void OPimRecurrenceWidget::setupMonthly() { 518void OPimRecurrenceWidget::setupMonthly() {
519 hideExtras(); 519 hideExtras();
520 lblWeekVar->hide(); 520 lblWeekVar->hide();
521 fraExtra->setTitle( tr("Repeat By") ); 521 fraExtra->setTitle( tr("Repeat By") );
522 fraExtra->setExclusive( TRUE ); 522 fraExtra->setExclusive( TRUE );
523 fraExtra->show(); 523 fraExtra->show();
524 cmdExtra1->setText( tr("Day") ); 524 cmdExtra1->setText( tr("Day") );
525 cmdExtra1->show(); 525 cmdExtra1->show();
526 cmdExtra2->setText( tr("Date") ); 526 cmdExtra2->setText( tr("Date") );
527 cmdExtra2->show(); 527 cmdExtra2->show();
528 spinFreq->setValue( 1 ); 528 spinFreq->setValue( 1 );
529 lblFreq->setText( tr("month(s)") ); 529 lblFreq->setText( tr("month(s)") );
530 lblVar2->show(); 530 lblVar2->show();
531 showRepeatStuff(); 531 showRepeatStuff();
532 setupRepeatLabel( 1 ); 532 setupRepeatLabel( 1 );
533} 533}
534void OPimRecurrenceWidget::setupYearly() { 534void OPimRecurrenceWidget::setupYearly() {
535hideExtras(); 535hideExtras();
536 lblWeekVar->hide(); 536 lblWeekVar->hide();
537 spinFreq->setValue( 1 ); 537 spinFreq->setValue( 1 );
538 lblFreq->setText( tr("year(s)") ); 538 lblFreq->setText( tr("year(s)") );
539 lblFreq->show(); 539 lblFreq->show();
540 lblFreq->show(); 540 lblFreq->show();
541 showRepeatStuff(); 541 showRepeatStuff();
542 lblVar2->show(); 542 lblVar2->show();
543 QString strEvery = strYearTemplate.arg( start.monthName(start.month()) ).arg( numberPlacing(start.day()) ); 543 QString strEvery = strYearTemplate.arg( start.monthName(start.month()) ).arg( numberPlacing(start.day()) );
544 lblRepeat->setText( strEvery ); 544 lblRepeat->setText( strEvery );
545 setupRepeatLabel( 1 ); 545 setupRepeatLabel( 1 );
546 546
547} 547}
548void OPimRecurrenceWidget::init() { 548void OPimRecurrenceWidget::init() {
549 QPopupMenu *m1 = new QPopupMenu( this ); 549 QPopupMenu *m1 = new QPopupMenu( this );
550 repeatPicker = new DateBookMonth( m1, 0, TRUE ); 550 repeatPicker = new DateBookMonth( m1, 0, TRUE );
551 m1->insertItem( repeatPicker ); 551 m1->insertItem( repeatPicker );
552 cmdEnd->setPopup( m1 ); 552 cmdEnd->setPopup( m1 );
553 cmdEnd->setPopupDelay( 0 ); 553 cmdEnd->setPopupDelay( 0 );
554 554
555 QObject::connect( repeatPicker, SIGNAL(dateClicked(int, int, int)), 555 QObject::connect( repeatPicker, SIGNAL(dateClicked(int,int,int)),
556 this, SLOT(endDateChanged(int, int, int)) ); 556 this, SLOT(endDateChanged(int,int,int)) );
557 QObject::connect( qApp, SIGNAL(weekChanged(bool)), 557 QObject::connect( qApp, SIGNAL(weekChanged(bool)),
558 this, SLOT(slotChangeStartOfWeek(bool)) ); 558 this, SLOT(slotChangeStartOfWeek(bool)) );
559 559
560 listRTypeButtons.setAutoDelete( TRUE ); 560 listRTypeButtons.setAutoDelete( TRUE );
561 listRTypeButtons.append( cmdNone ); 561 listRTypeButtons.append( cmdNone );
562 listRTypeButtons.append( cmdDay ); 562 listRTypeButtons.append( cmdDay );
563 listRTypeButtons.append( cmdWeek ); 563 listRTypeButtons.append( cmdWeek );
564 listRTypeButtons.append( cmdMonth ); 564 listRTypeButtons.append( cmdMonth );
565 listRTypeButtons.append( cmdYear ); 565 listRTypeButtons.append( cmdYear );
566 566
567 listExtra.setAutoDelete( TRUE ); 567 listExtra.setAutoDelete( TRUE );
568 listExtra.append( cmdExtra1 ); 568 listExtra.append( cmdExtra1 );
569 listExtra.append( cmdExtra2 ); 569 listExtra.append( cmdExtra2 );
570 listExtra.append( cmdExtra3 ); 570 listExtra.append( cmdExtra3 );
571 listExtra.append( cmdExtra4 ); 571 listExtra.append( cmdExtra4 );
572 listExtra.append( cmdExtra5 ); 572 listExtra.append( cmdExtra5 );
573 listExtra.append( cmdExtra6 ); 573 listExtra.append( cmdExtra6 );
574 listExtra.append( cmdExtra7 ); 574 listExtra.append( cmdExtra7 );
575} 575}
576void OPimRecurrenceWidget::hideExtras() { 576void OPimRecurrenceWidget::hideExtras() {
577 // hide the extra buttons... 577 // hide the extra buttons...
578 fraExtra->hide(); 578 fraExtra->hide();
579 chkNoEnd->hide(); 579 chkNoEnd->hide();
580 QListIterator<QToolButton> it( listExtra ); 580 QListIterator<QToolButton> it( listExtra );
581 for ( ; *it; ++it ) { 581 for ( ; *it; ++it ) {
582 (*it)->hide(); 582 (*it)->hide();
583 (*it)->setOn( FALSE ); 583 (*it)->setOn( FALSE );
584 } 584 }
585} 585}
586void OPimRecurrenceWidget::showRepeatStuff() { 586void OPimRecurrenceWidget::showRepeatStuff() {
587 cmdEnd->show(); 587 cmdEnd->show();
588 chkNoEnd->show(); 588 chkNoEnd->show();
589 lblFreq->show(); 589 lblFreq->show();
590 lblEvery->show(); 590 lblEvery->show();
591 lblFreq->show(); 591 lblFreq->show();
592 spinFreq->show(); 592 spinFreq->show();
593 lblEnd->show(); 593 lblEnd->show();
594 lblRepeat->setText( tr("Every") ); 594 lblRepeat->setText( tr("Every") );
595} 595}
596 596
597 597
598static int week( const QDate &start ) 598static int week( const QDate &start )
599{ 599{
600 // figure out the week... 600 // figure out the week...
601 int stop = start.day(), 601 int stop = start.day(),
602 sentinel = start.dayOfWeek(), 602 sentinel = start.dayOfWeek(),
603 dayOfWeek = QDate( start.year(), start.month(), 1 ).dayOfWeek(), 603 dayOfWeek = QDate( start.year(), start.month(), 1 ).dayOfWeek(),
604 week = 1, 604 week = 1,
605 i; 605 i;
606 for ( i = 1; i < stop; i++ ) { 606 for ( i = 1; i < stop; i++ ) {
607 if ( dayOfWeek++ == sentinel ) 607 if ( dayOfWeek++ == sentinel )
608 week++; 608 week++;
609 if ( dayOfWeek > 7 ) 609 if ( dayOfWeek > 7 )
610 dayOfWeek = 0; 610 dayOfWeek = 0;
611 } 611 }
612 return week; 612 return week;
613} 613}
614 614
615static QString numberPlacing( int x ) 615static QString numberPlacing( int x )
616{ 616{
617 // I hope this works in other languages besides english... 617 // I hope this works in other languages besides english...
618 QString str = QString::number( x ); 618 QString str = QString::number( x );
619 switch ( x % 10 ) { 619 switch ( x % 10 ) {
620 case 1: 620 case 1:
621 str += QWidget::tr( "st" ); 621 str += QWidget::tr( "st" );
622 break; 622 break;
623 case 2: 623 case 2:
624 str += QWidget::tr( "nd" ); 624 str += QWidget::tr( "nd" );
625 break; 625 break;
626 case 3: 626 case 3:
627 str += QWidget::tr( "rd" ); 627 str += QWidget::tr( "rd" );
628 break; 628 break;
629 default: 629 default:
630 str += QWidget::tr( "th" ); 630 str += QWidget::tr( "th" );
631 break; 631 break;
632 } 632 }
633 return str; 633 return str;
634} 634}
diff --git a/libopie2/opieui/fileselector/ofiledialog.cpp b/libopie2/opieui/fileselector/ofiledialog.cpp
index 2a89c5d..e7daead 100644
--- a/libopie2/opieui/fileselector/ofiledialog.cpp
+++ b/libopie2/opieui/fileselector/ofiledialog.cpp
@@ -1,222 +1,222 @@
1/* 1/*
2               =. This file is part of the OPIE Project 2               =. This file is part of the OPIE Project
3             .=l. Copyright (C) Holger Freyther <zecke@handhelds.org> 3             .=l. Copyright (C) Holger Freyther <zecke@handhelds.org>
4           .>+-= 4           .>+-=
5 _;:,     .>    :=|. This library is free software; you can 5 _;:,     .>    :=|. This library is free software; you can
6.> <`_,   >  .   <= redistribute it and/or modify it under 6.> <`_,   >  .   <= redistribute it and/or modify it under
7:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 7:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
8.="- .-=="i,     .._ License as published by the Free Software 8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; either version 2 of the License, 9 - .   .-<_>     .<> Foundation; either version 2 of the License,
10     ._= =}       : or (at your option) any later version. 10     ._= =}       : or (at your option) any later version.
11    .%`+i>       _;_. 11    .%`+i>       _;_.
12    .i_,=:_.      -<s. This library is distributed in the hope that 12    .i_,=:_.      -<s. This library is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of 14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
17..}^=.=       =       ; Library General Public License for more 17..}^=.=       =       ; Library General Public License for more
18++=   -.     .`     .: details. 18++=   -.     .`     .: details.
19 :     =  ...= . :.=- 19 :     =  ...= . :.=-
20 -.   .:....=;==+<; You should have received a copy of the GNU 20 -.   .:....=;==+<; You should have received a copy of the GNU
21  -_. . .   )=.  = Library General Public License along with 21  -_. . .   )=.  = Library General Public License along with
22    --        :-=` this library; see the file COPYING.LIB. 22    --        :-=` this library; see the file COPYING.LIB.
23 If not, write to the Free Software Foundation, 23 If not, write to the Free Software Foundation,
24 Inc., 59 Temple Place - Suite 330, 24 Inc., 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 26
27*/ 27*/
28 28
29 29
30/* OPIE */ 30/* OPIE */
31#include <opie2/ofiledialog.h> 31#include <opie2/ofiledialog.h>
32#include <qpe/applnk.h> 32#include <qpe/applnk.h>
33#include <qpe/config.h> 33#include <qpe/config.h>
34#include <qpe/qpeapplication.h> 34#include <qpe/qpeapplication.h>
35 35
36/* QT */ 36/* QT */
37#include <qfileinfo.h> 37#include <qfileinfo.h>
38#include <qstring.h> 38#include <qstring.h>
39#include <qapplication.h> 39#include <qapplication.h>
40#include <qlayout.h> 40#include <qlayout.h>
41 41
42using namespace Opie; 42using namespace Opie;
43 43
44namespace 44namespace
45{ 45{
46/* 46/*
47 * helper functions to load the start dir 47 * helper functions to load the start dir
48 * and to save it 48 * and to save it
49 * helper to extract the dir out of a file name 49 * helper to extract the dir out of a file name
50 */ 50 */
51/** 51/**
52 * This method will use Config( argv[0] ); 52 * This method will use Config( argv[0] );
53 * @param key The group key used 53 * @param key The group key used
54 */ 54 */
55QString lastUsedDir( const QString& key ) 55QString lastUsedDir( const QString& key )
56{ 56{
57 if ( qApp->argc() < 1 ) 57 if ( qApp->argc() < 1 )
58 return QString::null; 58 return QString::null;
59 59
60 Config cfg( QFileInfo(qApp->argv()[0]).fileName() ); // appname 60 Config cfg( QFileInfo(qApp->argv()[0]).fileName() ); // appname
61 cfg.setGroup( key ); 61 cfg.setGroup( key );
62 return cfg.readEntry("LastDir", QPEApplication::documentDir() ); 62 return cfg.readEntry("LastDir", QPEApplication::documentDir() );
63} 63}
64 64
65void saveLastDir( const QString& key, const QString& file ) 65void saveLastDir( const QString& key, const QString& file )
66{ 66{
67 if ( qApp->argc() < 1 ) 67 if ( qApp->argc() < 1 )
68 return; 68 return;
69 69
70 Config cfg( QFileInfo(qApp->argv()[0]).fileName() ); 70 Config cfg( QFileInfo(qApp->argv()[0]).fileName() );
71 cfg.setGroup( key ); 71 cfg.setGroup( key );
72 QFileInfo inf( file ); 72 QFileInfo inf( file );
73 cfg.writeEntry("LastDir", inf.dirPath( true ) ); 73 cfg.writeEntry("LastDir", inf.dirPath( true ) );
74} 74}
75}; 75};
76 76
77/** 77/**
78 * This constructs a modal dialog 78 * This constructs a modal dialog
79 * 79 *
80 * @param caption The caption of the dialog 80 * @param caption The caption of the dialog
81 * @param wid The parent widget 81 * @param wid The parent widget
82 * @param mode The mode of the OFileSelector @see OFileSelector 82 * @param mode The mode of the OFileSelector @see OFileSelector
83 * @param selector The selector of the OFileSelector 83 * @param selector The selector of the OFileSelector
84 * @param dirName the dir or resource to start from 84 * @param dirName the dir or resource to start from
85 * @param fileName a proposed or existing filename 85 * @param fileName a proposed or existing filename
86 * @param mimetypes The mimeTypes 86 * @param mimetypes The mimeTypes
87 */ 87 */
88OFileDialog::OFileDialog(const QString &caption, 88OFileDialog::OFileDialog(const QString &caption,
89 QWidget *wid, int mode, int selector, 89 QWidget *wid, int mode, int selector,
90 const QString &dirName, 90 const QString &dirName,
91 const QString &fileName, 91 const QString &fileName,
92 const QMap<QString,QStringList>& mimetypes ) 92 const QMap<QString,QStringList>& mimetypes )
93 : QDialog( wid, "OFileDialog", true ) 93 : QDialog( wid, "OFileDialog", true )
94{ 94{
95 // QVBoxLayout *lay = new QVBoxLayout(this); 95 // QVBoxLayout *lay = new QVBoxLayout(this);
96 //showMaximized(); 96 //showMaximized();
97 QVBoxLayout *lay = new QVBoxLayout(this ); 97 QVBoxLayout *lay = new QVBoxLayout(this );
98 file = new OFileSelector(this , mode, selector, 98 file = new OFileSelector(this , mode, selector,
99 dirName, fileName, 99 dirName, fileName,
100 mimetypes ); 100 mimetypes );
101 lay->addWidget( file ); 101 lay->addWidget( file );
102 102
103 //lay->addWidget( file ); 103 //lay->addWidget( file );
104 //showFullScreen(); 104 //showFullScreen();
105 setCaption( caption.isEmpty() ? tr("FileDialog") : caption ); 105 setCaption( caption.isEmpty() ? tr("FileDialog") : caption );
106 connect(file, SIGNAL(fileSelected(const QString&) ), 106 connect(file, SIGNAL(fileSelected(const QString&) ),
107 this, SLOT(slotFileSelected(const QString&) ) ); 107 this, SLOT(slotFileSelected(const QString&) ) );
108 connect(file, SIGNAL(ok() ), 108 connect(file, SIGNAL(ok() ),
109 this, SLOT(slotSelectorOk()) ) ; 109 this, SLOT(slotSelectorOk()) ) ;
110 110
111 connect(file, SIGNAL(dirSelected(const QString&) ), this, SLOT(slotDirSelected(const QString&) ) ); 111 connect(file, SIGNAL(dirSelected(const QString&) ), this, SLOT(slotDirSelected(const QString&) ) );
112 112
113#if 0 113#if 0
114 connect(file, SIGNAL(dirSelected(const QString &) ), 114 connect(file, SIGNAL(dirSelected(const QString&) ),
115 this, SLOT(slotDirSelected(const QString &) ) ); 115 this, SLOT(slotDirSelected(const QString&) ) );
116#endif 116#endif
117} 117}
118/** 118/**
119 * @returns the mimetype of the selected 119 * @returns the mimetype of the selected
120 * currently it return QString::null 120 * currently it return QString::null
121 */ 121 */
122QString OFileDialog::mimetype()const 122QString OFileDialog::mimetype()const
123{ 123{
124 return QString::null; 124 return QString::null;
125} 125}
126 126
127/** 127/**
128 * @return the fileName 128 * @return the fileName
129 */ 129 */
130QString OFileDialog::fileName()const 130QString OFileDialog::fileName()const
131{ 131{
132 return file->selectedName(); 132 return file->selectedName();
133} 133}
134 134
135/** 135/**
136 * return a DocLnk to the current file 136 * return a DocLnk to the current file
137 */ 137 */
138DocLnk OFileDialog::selectedDocument()const 138DocLnk OFileDialog::selectedDocument()const
139{ 139{
140 return file->selectedDocument(); 140 return file->selectedDocument();
141} 141}
142 142
143/** 143/**
144 * This opens up a filedialog in Open mode 144 * This opens up a filedialog in Open mode
145 * 145 *
146 * @param selector the Selector Mode 146 * @param selector the Selector Mode
147 * @param startDir Where to start from 147 * @param startDir Where to start from
148 * @param file A proposed filename 148 * @param file A proposed filename
149 * @param mimes A list of MimeTypes 149 * @param mimes A list of MimeTypes
150 * @param wid the parent 150 * @param wid the parent
151 * @param caption of the dialog if QString::null tr("Open") will be used 151 * @param caption of the dialog if QString::null tr("Open") will be used
152 * @return the fileName or QString::null 152 * @return the fileName or QString::null
153 */ 153 */
154QString OFileDialog::getOpenFileName(int selector, 154QString OFileDialog::getOpenFileName(int selector,
155 const QString &_startDir, 155 const QString &_startDir,
156 const QString &file, 156 const QString &file,
157 const MimeTypes &mimes, 157 const MimeTypes &mimes,
158 QWidget *wid, 158 QWidget *wid,
159 const QString &caption ) 159 const QString &caption )
160{ 160{
161 QString ret; 161 QString ret;
162 QString startDir = _startDir; 162 QString startDir = _startDir;
163 if (startDir.isEmpty() ) 163 if (startDir.isEmpty() )
164 startDir = lastUsedDir( "FileDialog-OPEN" ); 164 startDir = lastUsedDir( "FileDialog-OPEN" );
165 165
166 166
167 OFileDialog dlg( caption.isEmpty() ? tr("Open") : caption, 167 OFileDialog dlg( caption.isEmpty() ? tr("Open") : caption,
168 wid, OFileSelector::Open, selector, startDir, file, mimes); 168 wid, OFileSelector::Open, selector, startDir, file, mimes);
169 dlg.showMaximized(); 169 dlg.showMaximized();
170 if( dlg.exec() ) 170 if( dlg.exec() )
171 { 171 {
172 ret = dlg.fileName(); 172 ret = dlg.fileName();
173 saveLastDir( "FileDialog-OPEN", ret ); 173 saveLastDir( "FileDialog-OPEN", ret );
174 } 174 }
175 175
176 return ret; 176 return ret;
177} 177}
178 178
179/** 179/**
180 * This opens up a file dialog in save mode 180 * This opens up a file dialog in save mode
181 * @see getOpenFileName 181 * @see getOpenFileName
182 */ 182 */
183QString OFileDialog::getSaveFileName(int selector, 183QString OFileDialog::getSaveFileName(int selector,
184 const QString &_startDir, 184 const QString &_startDir,
185 const QString &file, 185 const QString &file,
186 const MimeTypes &mimes, 186 const MimeTypes &mimes,
187 QWidget *wid, 187 QWidget *wid,
188 const QString &caption ) 188 const QString &caption )
189{ 189{
190 QString ret; 190 QString ret;
191 QString startDir = _startDir; 191 QString startDir = _startDir;
192 if (startDir.isEmpty() ) 192 if (startDir.isEmpty() )
193 startDir = lastUsedDir( "FileDialog-SAVE" ); 193 startDir = lastUsedDir( "FileDialog-SAVE" );
194 194
195 OFileDialog dlg( caption.isEmpty() ? tr("Save") : caption, 195 OFileDialog dlg( caption.isEmpty() ? tr("Save") : caption,
196 wid, OFileSelector::Save, selector, startDir, file, mimes); 196 wid, OFileSelector::Save, selector, startDir, file, mimes);
197 dlg.showMaximized(); 197 dlg.showMaximized();
198 if( dlg.exec() ) 198 if( dlg.exec() )
199 { 199 {
200 ret = dlg.fileName(); 200 ret = dlg.fileName();
201 saveLastDir( "FileDialog-SAVE", ret ); 201 saveLastDir( "FileDialog-SAVE", ret );
202 } 202 }
203 203
204 return ret; 204 return ret;
205} 205}
206 206
207void OFileDialog::slotFileSelected(const QString & ) 207void OFileDialog::slotFileSelected(const QString & )
208{ 208{
209 accept(); 209 accept();
210} 210}
211 211
212void OFileDialog::slotSelectorOk( ) 212void OFileDialog::slotSelectorOk( )
213{ 213{
214 accept(); 214 accept();
215} 215}
216 216
217void OFileDialog::slotDirSelected(const QString &dir ) 217void OFileDialog::slotDirSelected(const QString &dir )
218{ 218{
219 setCaption( dir ); 219 setCaption( dir );
220 // if mode 220 // if mode
221 //accept(); 221 //accept();
222} 222}
diff --git a/libopie2/opieui/fileselector/ofileselector.cpp b/libopie2/opieui/fileselector/ofileselector.cpp
index 600daff..15cadd4 100644
--- a/libopie2/opieui/fileselector/ofileselector.cpp
+++ b/libopie2/opieui/fileselector/ofileselector.cpp
@@ -21,700 +21,700 @@
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/* hacky but we need to get FileSelector::filter */ 29/* hacky but we need to get FileSelector::filter */
30#define private public 30#define private public
31#include <qpe/fileselector.h> 31#include <qpe/fileselector.h>
32#undef private 32#undef private
33 33
34#include "ofileselector_p.h" 34#include "ofileselector_p.h"
35 35
36/* OPIE */ 36/* OPIE */
37#include <opie2/ofileselector.h> 37#include <opie2/ofileselector.h>
38 38
39#include <qpe/qpeapplication.h> 39#include <qpe/qpeapplication.h>
40#include <qpe/mimetype.h> 40#include <qpe/mimetype.h>
41#include <qpe/resource.h> 41#include <qpe/resource.h>
42#include <qpe/storage.h> 42#include <qpe/storage.h>
43 43
44/* QT */ 44/* QT */
45#include <qcombobox.h> 45#include <qcombobox.h>
46#include <qdir.h> 46#include <qdir.h>
47#include <qhbox.h> 47#include <qhbox.h>
48#include <qheader.h> 48#include <qheader.h>
49#include <qlabel.h> 49#include <qlabel.h>
50#include <qlayout.h> 50#include <qlayout.h>
51#include <qlineedit.h> 51#include <qlineedit.h>
52#include <qlistview.h> 52#include <qlistview.h>
53#include <qpopupmenu.h> 53#include <qpopupmenu.h>
54#include <qwidgetstack.h> 54#include <qwidgetstack.h>
55#include <qregexp.h> 55#include <qregexp.h>
56#include <qobjectlist.h> 56#include <qobjectlist.h>
57 57
58using namespace Opie; 58using namespace Opie;
59 59
60OFileViewInterface::OFileViewInterface( OFileSelector* selector ) 60OFileViewInterface::OFileViewInterface( OFileSelector* selector )
61 : m_selector( selector ) 61 : m_selector( selector )
62{} 62{}
63 63
64OFileViewInterface::~OFileViewInterface() 64OFileViewInterface::~OFileViewInterface()
65{} 65{}
66 66
67QString OFileViewInterface::name()const 67QString OFileViewInterface::name()const
68{ 68{
69 return m_name; 69 return m_name;
70} 70}
71 71
72void OFileViewInterface::setName( const QString& name ) 72void OFileViewInterface::setName( const QString& name )
73{ 73{
74 m_name = name; 74 m_name = name;
75} 75}
76 76
77OFileSelector* OFileViewInterface::selector()const 77OFileSelector* OFileViewInterface::selector()const
78{ 78{
79 return m_selector; 79 return m_selector;
80} 80}
81 81
82DocLnk OFileViewInterface::selectedDocument()const 82DocLnk OFileViewInterface::selectedDocument()const
83{ 83{
84 return DocLnk( selectedName() ); 84 return DocLnk( selectedName() );
85} 85}
86 86
87bool OFileViewInterface::showNew()const 87bool OFileViewInterface::showNew()const
88{ 88{
89 return selector()->showNew(); 89 return selector()->showNew();
90} 90}
91 91
92bool OFileViewInterface::showClose()const 92bool OFileViewInterface::showClose()const
93{ 93{
94 return selector()->showClose(); 94 return selector()->showClose();
95} 95}
96 96
97MimeTypes OFileViewInterface::mimeTypes()const 97MimeTypes OFileViewInterface::mimeTypes()const
98{ 98{
99 return selector()->mimeTypes(); 99 return selector()->mimeTypes();
100} 100}
101 101
102QStringList OFileViewInterface::currentMimeType()const 102QStringList OFileViewInterface::currentMimeType()const
103{ 103{
104 return selector()->currentMimeType(); 104 return selector()->currentMimeType();
105} 105}
106 106
107void OFileViewInterface::activate( const QString& ) 107void OFileViewInterface::activate( const QString& )
108{ 108{
109 // not implemented here 109 // not implemented here
110} 110}
111 111
112void OFileViewInterface::ok() 112void OFileViewInterface::ok()
113{ 113{
114 emit selector()->ok(); 114 emit selector()->ok();
115} 115}
116 116
117void OFileViewInterface::cancel() 117void OFileViewInterface::cancel()
118{ 118{
119 emit selector()->cancel(); 119 emit selector()->cancel();
120} 120}
121 121
122void OFileViewInterface::closeMe() 122void OFileViewInterface::closeMe()
123{ 123{
124 emit selector()->closeMe(); 124 emit selector()->closeMe();
125} 125}
126 126
127void OFileViewInterface::fileSelected( const QString& str) 127void OFileViewInterface::fileSelected( const QString& str)
128{ 128{
129 emit selector()->fileSelected( str); 129 emit selector()->fileSelected( str);
130} 130}
131 131
132void OFileViewInterface::fileSelected( const DocLnk& lnk) 132void OFileViewInterface::fileSelected( const DocLnk& lnk)
133{ 133{
134 emit selector()->fileSelected( lnk ); 134 emit selector()->fileSelected( lnk );
135} 135}
136 136
137void OFileViewInterface::setCurrentFileName( const QString& str ) 137void OFileViewInterface::setCurrentFileName( const QString& str )
138{ 138{
139 selector()->m_lneEdit->setText( str ); 139 selector()->m_lneEdit->setText( str );
140} 140}
141 141
142QString OFileViewInterface::currentFileName()const 142QString OFileViewInterface::currentFileName()const
143{ 143{
144 return selector()->m_lneEdit->text(); 144 return selector()->m_lneEdit->text();
145} 145}
146 146
147QString OFileViewInterface::startDirectory()const 147QString OFileViewInterface::startDirectory()const
148{ 148{
149 return selector()->m_startDir; 149 return selector()->m_startDir;
150} 150}
151 151
152ODocumentFileView::ODocumentFileView( OFileSelector* selector ) 152ODocumentFileView::ODocumentFileView( OFileSelector* selector )
153 :OFileViewInterface( selector ) 153 :OFileViewInterface( selector )
154{ 154{
155 m_selector = 0; 155 m_selector = 0;
156 setName( QObject::tr("Documents") ); 156 setName( QObject::tr("Documents") );
157} 157}
158 158
159ODocumentFileView::~ODocumentFileView() 159ODocumentFileView::~ODocumentFileView()
160{ 160{
161} 161}
162 162
163QString ODocumentFileView::selectedName()const 163QString ODocumentFileView::selectedName()const
164{ 164{
165 if (!m_selector) 165 if (!m_selector)
166 return QString::null; 166 return QString::null;
167 167
168 return m_selector->selectedDocument().file(); 168 return m_selector->selectedDocument().file();
169} 169}
170 170
171QString ODocumentFileView::selectedPath()const 171QString ODocumentFileView::selectedPath()const
172{ 172{
173 return QPEApplication::documentDir(); 173 return QPEApplication::documentDir();
174} 174}
175 175
176QString ODocumentFileView::directory()const 176QString ODocumentFileView::directory()const
177{ 177{
178 return selectedPath(); 178 return selectedPath();
179} 179}
180 180
181void ODocumentFileView::reread() 181void ODocumentFileView::reread()
182{ 182{
183 if (!m_selector) 183 if (!m_selector)
184 return; 184 return;
185 185
186 m_selector->setNewVisible( showNew() ); 186 m_selector->setNewVisible( showNew() );
187 m_selector->setCloseVisible( showClose() ); 187 m_selector->setCloseVisible( showClose() );
188 m_selector->filter = currentMimeType().join(";"); 188 m_selector->filter = currentMimeType().join(";");
189 m_selector->reread(); 189 m_selector->reread();
190} 190}
191 191
192int ODocumentFileView::fileCount()const 192int ODocumentFileView::fileCount()const
193{ 193{
194 if (!m_selector) 194 if (!m_selector)
195 return -1; 195 return -1;
196 196
197 return m_selector->fileCount(); 197 return m_selector->fileCount();
198} 198}
199 199
200DocLnk ODocumentFileView::selectedDocument()const 200DocLnk ODocumentFileView::selectedDocument()const
201{ 201{
202 if (!m_selector) 202 if (!m_selector)
203 return DocLnk(); 203 return DocLnk();
204 204
205 return m_selector->selectedDocument(); 205 return m_selector->selectedDocument();
206} 206}
207 207
208QWidget* ODocumentFileView::widget( QWidget* parent ) 208QWidget* ODocumentFileView::widget( QWidget* parent )
209{ 209{
210 if (!m_selector ) 210 if (!m_selector )
211 { 211 {
212 m_selector = new FileSelector(currentMimeType().join(";"), parent, "fileselector", showNew(), showClose() ); 212 m_selector = new FileSelector(currentMimeType().join(";"), parent, "fileselector", showNew(), showClose() );
213 QObject::connect(m_selector, SIGNAL(fileSelected( const DocLnk& ) ), 213 QObject::connect(m_selector, SIGNAL(fileSelected(const DocLnk&) ),
214 selector(), SLOT(slotDocLnkBridge(const DocLnk&) ) ); 214 selector(), SLOT(slotDocLnkBridge(const DocLnk&) ) );
215 QObject::connect(m_selector, SIGNAL(closeMe() ), 215 QObject::connect(m_selector, SIGNAL(closeMe() ),
216 selector(), SIGNAL(closeMe() ) ); 216 selector(), SIGNAL(closeMe() ) );
217 QObject::connect(m_selector, SIGNAL(newSelected(const DocLnk& ) ), 217 QObject::connect(m_selector, SIGNAL(newSelected(const DocLnk&) ),
218 selector(), SIGNAL(newSelected(const DocLnk& ) ) ); 218 selector(), SIGNAL(newSelected(const DocLnk&) ) );
219 } 219 }
220 220
221 return m_selector; 221 return m_selector;
222} 222}
223 223
224/* 224/*
225 * This is the file system view used 225 * This is the file system view used
226 * we use a QListView + QListViewItems for it 226 * we use a QListView + QListViewItems for it
227 */ 227 */
228 228
229OFileSelectorItem::OFileSelectorItem( QListView* view, const QPixmap& pixmap, 229OFileSelectorItem::OFileSelectorItem( QListView* view, const QPixmap& pixmap,
230 const QString& path, const QString& date, 230 const QString& path, const QString& date,
231 const QString& size, const QString& dir, 231 const QString& size, const QString& dir,
232 bool isLocked, bool isDir ) 232 bool isLocked, bool isDir )
233 : QListViewItem( view ) 233 : QListViewItem( view )
234{ 234{
235 setPixmap(0, pixmap ); 235 setPixmap(0, pixmap );
236 setText(1, path ); 236 setText(1, path );
237 setText(2, size ); 237 setText(2, size );
238 setText(3, date ); 238 setText(3, date );
239 m_isDir = isDir; 239 m_isDir = isDir;
240 m_dir = dir; 240 m_dir = dir;
241 m_locked = isLocked; 241 m_locked = isLocked;
242} 242}
243 243
244OFileSelectorItem::~OFileSelectorItem() 244OFileSelectorItem::~OFileSelectorItem()
245{ 245{
246} 246}
247 247
248bool OFileSelectorItem::isLocked()const 248bool OFileSelectorItem::isLocked()const
249{ 249{
250 return m_locked; 250 return m_locked;
251} 251}
252 252
253QString OFileSelectorItem::directory()const 253QString OFileSelectorItem::directory()const
254{ 254{
255 return m_dir; 255 return m_dir;
256} 256}
257 257
258bool OFileSelectorItem::isDir()const 258bool OFileSelectorItem::isDir()const
259{ 259{
260 return m_isDir; 260 return m_isDir;
261} 261}
262 262
263QString OFileSelectorItem::path()const 263QString OFileSelectorItem::path()const
264{ 264{
265 return text( 1 ); 265 return text( 1 );
266} 266}
267 267
268QString OFileSelectorItem::key( int id, bool )const 268QString OFileSelectorItem::key( int id, bool )const
269{ 269{
270 QString ke; 270 QString ke;
271 if( id == 0 || id == 1 ) 271 if( id == 0 || id == 1 )
272 { // name 272 { // name
273 if( m_isDir ) 273 if( m_isDir )
274 { 274 {
275 ke.append("0" ); 275 ke.append("0" );
276 ke.append( text(1) ); 276 ke.append( text(1) );
277 } 277 }
278 else 278 else
279 { 279 {
280 ke.append("1" ); 280 ke.append("1" );
281 ke.append( text(1) ); 281 ke.append( text(1) );
282 } 282 }
283 return ke; 283 return ke;
284 } 284 }
285 else 285 else
286 return text( id ); 286 return text( id );
287 287
288} 288}
289 289
290OFileViewFileListView::OFileViewFileListView( QWidget* parent, const QString& startDir, OFileSelector* sel) 290OFileViewFileListView::OFileViewFileListView( QWidget* parent, const QString& startDir, OFileSelector* sel)
291 :QWidget( parent ), m_sel( sel ) 291 :QWidget( parent ), m_sel( sel )
292{ 292{
293 m_all = false; 293 m_all = false;
294 QVBoxLayout* lay = new QVBoxLayout( this ); 294 QVBoxLayout* lay = new QVBoxLayout( this );
295 m_currentDir = startDir; 295 m_currentDir = startDir;
296 296
297 /* 297 /*
298 * now we add a special bar 298 * now we add a special bar
299 * One Button For Up 299 * One Button For Up
300 * Home 300 * Home
301 * Doc 301 * Doc
302 * And a dropdown menu with FileSystems 302 * And a dropdown menu with FileSystems
303 * FUTURE: one to change dir with lineedit 303 * FUTURE: one to change dir with lineedit
304 * Bookmarks 304 * Bookmarks
305 * Create Dir 305 * Create Dir
306 */ 306 */
307 QHBox* box = new QHBox(this ); 307 QHBox* box = new QHBox(this );
308 box->setBackgroundMode( PaletteButton ); 308 box->setBackgroundMode( PaletteButton );
309 box->setSpacing( 0 ); 309 box->setSpacing( 0 );
310 310
311 QToolButton *btn = new QToolButton( box ); 311 QToolButton *btn = new QToolButton( box );
312 btn->setIconSet( Resource::loadIconSet("up") ); 312 btn->setIconSet( Resource::loadIconSet("up") );
313 connect(btn, SIGNAL(clicked() ), 313 connect(btn, SIGNAL(clicked() ),
314 this, SLOT( cdUP() ) ); 314 this, SLOT( cdUP() ) );
315 315
316 btn = new QToolButton( box ); 316 btn = new QToolButton( box );
317 btn->setIconSet( Resource::loadIconSet("home") ); 317 btn->setIconSet( Resource::loadIconSet("home") );
318 connect(btn, SIGNAL(clicked() ), 318 connect(btn, SIGNAL(clicked() ),
319 this, SLOT( cdHome() ) ); 319 this, SLOT( cdHome() ) );
320 320
321 btn = new QToolButton( box ); 321 btn = new QToolButton( box );
322 btn->setIconSet( Resource::loadIconSet("DocsIcon") ); 322 btn->setIconSet( Resource::loadIconSet("DocsIcon") );
323 connect(btn, SIGNAL(clicked() ), 323 connect(btn, SIGNAL(clicked() ),
324 this, SLOT(cdDoc() ) ); 324 this, SLOT(cdDoc() ) );
325 325
326 m_btnNew = new QToolButton( box ); 326 m_btnNew = new QToolButton( box );
327 m_btnNew->setIconSet( Resource::loadIconSet("new") ); 327 m_btnNew->setIconSet( Resource::loadIconSet("new") );
328 connect(m_btnNew, SIGNAL(clicked() ), 328 connect(m_btnNew, SIGNAL(clicked() ),
329 this, SLOT(slotNew() ) ); 329 this, SLOT(slotNew() ) );
330 330
331 331
332 m_btnClose = new QToolButton( box ); 332 m_btnClose = new QToolButton( box );
333 m_btnClose->setIconSet( Resource::loadIconSet("close") ); 333 m_btnClose->setIconSet( Resource::loadIconSet("close") );
334 connect(m_btnClose, SIGNAL(clicked() ), 334 connect(m_btnClose, SIGNAL(clicked() ),
335 selector(), SIGNAL(closeMe() ) ); 335 selector(), SIGNAL(closeMe() ) );
336 336
337 btn = new QToolButton( box ); 337 btn = new QToolButton( box );
338 btn->setIconSet( Resource::loadIconSet("cardmon/pcmcia") ); 338 btn->setIconSet( Resource::loadIconSet("cardmon/pcmcia") );
339 339
340 /* let's fill device parts */ 340 /* let's fill device parts */
341 QPopupMenu* pop = new QPopupMenu(this); 341 QPopupMenu* pop = new QPopupMenu(this);
342 connect(pop, SIGNAL( activated(int) ), 342 connect(pop, SIGNAL( activated(int) ),
343 this, SLOT(slotFSActivated(int) ) ); 343 this, SLOT(slotFSActivated(int) ) );
344 344
345 StorageInfo storage; 345 StorageInfo storage;
346 const QList<FileSystem> &fs = storage.fileSystems(); 346 const QList<FileSystem> &fs = storage.fileSystems();
347 QListIterator<FileSystem> it(fs); 347 QListIterator<FileSystem> it(fs);
348 for ( ; it.current(); ++it ) 348 for ( ; it.current(); ++it )
349 { 349 {
350 const QString disk = (*it)->name(); 350 const QString disk = (*it)->name();
351 const QString path = (*it)->path(); 351 const QString path = (*it)->path();
352 m_dev.insert( disk, path ); 352 m_dev.insert( disk, path );
353 pop->insertItem( disk ); 353 pop->insertItem( disk );
354 } 354 }
355 m_fsPop = pop; 355 m_fsPop = pop;
356 356
357 357
358 btn->setPopup( pop ); 358 btn->setPopup( pop );
359 359
360 lay->addWidget( box ); 360 lay->addWidget( box );
361 361
362 m_view = new QListView( this ); 362 m_view = new QListView( this );
363 363
364 m_view->installEventFilter(this); 364 m_view->installEventFilter(this);
365 365
366 QPEApplication::setStylusOperation( m_view->viewport(), 366 QPEApplication::setStylusOperation( m_view->viewport(),
367 QPEApplication::RightOnHold); 367 QPEApplication::RightOnHold);
368 m_view->addColumn(" " ); 368 m_view->addColumn(" " );
369 m_view->addColumn(tr("Name"), 135 ); 369 m_view->addColumn(tr("Name"), 135 );
370 m_view->addColumn(tr("Size"), -1 ); 370 m_view->addColumn(tr("Size"), -1 );
371 m_view->addColumn(tr("Date"), 60 ); 371 m_view->addColumn(tr("Date"), 60 );
372 m_view->addColumn(tr("Mime Type"), -1 ); 372 m_view->addColumn(tr("Mime Type"), -1 );
373 373
374 374
375 m_view->setSorting( 1 ); 375 m_view->setSorting( 1 );
376 m_view->setAllColumnsShowFocus( TRUE ); 376 m_view->setAllColumnsShowFocus( TRUE );
377 377
378 lay->addWidget( m_view, 1000 ); 378 lay->addWidget( m_view, 1000 );
379 connectSlots(); 379 connectSlots();
380} 380}
381 381
382OFileViewFileListView::~OFileViewFileListView() 382OFileViewFileListView::~OFileViewFileListView()
383{ 383{
384} 384}
385 385
386void OFileViewFileListView::slotNew() 386void OFileViewFileListView::slotNew()
387{ 387{
388 DocLnk lnk; 388 DocLnk lnk;
389 emit selector()->newSelected( lnk ); 389 emit selector()->newSelected( lnk );
390} 390}
391 391
392OFileSelectorItem* OFileViewFileListView::currentItem()const 392OFileSelectorItem* OFileViewFileListView::currentItem()const
393{ 393{
394 QListViewItem* item = m_view->currentItem(); 394 QListViewItem* item = m_view->currentItem();
395 if (!item ) 395 if (!item )
396 return 0l; 396 return 0l;
397 397
398 return static_cast<OFileSelectorItem*>(item); 398 return static_cast<OFileSelectorItem*>(item);
399} 399}
400 400
401void OFileViewFileListView::reread( bool all ) 401void OFileViewFileListView::reread( bool all )
402{ 402{
403 m_view->clear(); 403 m_view->clear();
404 404
405 if (selector()->showClose() ) 405 if (selector()->showClose() )
406 m_btnClose->show(); 406 m_btnClose->show();
407 else 407 else
408 m_btnClose->hide(); 408 m_btnClose->hide();
409 409
410 if (selector()->showNew() ) 410 if (selector()->showNew() )
411 m_btnNew->show(); 411 m_btnNew->show();
412 else 412 else
413 m_btnNew->hide(); 413 m_btnNew->hide();
414 414
415 m_mimes = selector()->currentMimeType(); 415 m_mimes = selector()->currentMimeType();
416 m_all = all; 416 m_all = all;
417 417
418 QDir dir( m_currentDir ); 418 QDir dir( m_currentDir );
419 if (!dir.exists() ) 419 if (!dir.exists() )
420 return; 420 return;
421 421
422 dir.setSorting( QDir::Name | QDir::DirsFirst | QDir::Reversed ); 422 dir.setSorting( QDir::Name | QDir::DirsFirst | QDir::Reversed );
423 int filter; 423 int filter;
424 if (m_all ) 424 if (m_all )
425 filter = QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All; 425 filter = QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All;
426 else 426 else
427 filter = QDir::Files | QDir::Dirs | QDir::All; 427 filter = QDir::Files | QDir::Dirs | QDir::All;
428 dir.setFilter( filter ); 428 dir.setFilter( filter );
429 429
430 // now go through all files 430 // now go through all files
431 const QFileInfoList *list = dir.entryInfoList(); 431 const QFileInfoList *list = dir.entryInfoList();
432 if (!list) 432 if (!list)
433 { 433 {
434 cdUP(); 434 cdUP();
435 return; 435 return;
436 } 436 }
437 437
438 QFileInfoListIterator it( *list ); 438 QFileInfoListIterator it( *list );
439 QFileInfo *fi; 439 QFileInfo *fi;
440 while( (fi=it.current() ) ) 440 while( (fi=it.current() ) )
441 { 441 {
442 if( fi->fileName() == QString::fromLatin1("..") || fi->fileName() == QString::fromLatin1(".") ) 442 if( fi->fileName() == QString::fromLatin1("..") || fi->fileName() == QString::fromLatin1(".") )
443 { 443 {
444 ++it; 444 ++it;
445 continue; 445 continue;
446 } 446 }
447 447
448 /* 448 /*
449 * It is a symlink we try to resolve it now but don't let us attack by DOS 449 * It is a symlink we try to resolve it now but don't let us attack by DOS
450 * 450 *
451 */ 451 */
452 if( fi->isSymLink() ) 452 if( fi->isSymLink() )
453 { 453 {
454 QString file = fi->dirPath( true ) + "/" + fi->readLink(); 454 QString file = fi->dirPath( true ) + "/" + fi->readLink();
455 for( int i = 0; i<=4; i++) 455 for( int i = 0; i<=4; i++)
456 { // 5 tries to prevent dos 456 { // 5 tries to prevent dos
457 QFileInfo info( file ); 457 QFileInfo info( file );
458 if( !info.exists() ) 458 if( !info.exists() )
459 { 459 {
460 addSymlink( fi, TRUE ); 460 addSymlink( fi, TRUE );
461 break; 461 break;
462 } 462 }
463 else if( info.isDir() ) 463 else if( info.isDir() )
464 { 464 {
465 addDir( fi, TRUE ); 465 addDir( fi, TRUE );
466 break; 466 break;
467 } 467 }
468 else if( info.isFile() ) 468 else if( info.isFile() )
469 { 469 {
470 addFile( fi, TRUE ); 470 addFile( fi, TRUE );
471 break; 471 break;
472 } 472 }
473 else if( info.isSymLink() ) 473 else if( info.isSymLink() )
474 { 474 {
475 file = info.dirPath(true ) + "/" + info.readLink() ; 475 file = info.dirPath(true ) + "/" + info.readLink() ;
476 break; 476 break;
477 } 477 }
478 else if( i == 4) 478 else if( i == 4)
479 { // couldn't resolve symlink add it as symlink 479 { // couldn't resolve symlink add it as symlink
480 addSymlink( fi ); 480 addSymlink( fi );
481 } 481 }
482 } // off for loop for symlink resolving 482 } // off for loop for symlink resolving
483 } 483 }
484 else if( fi->isDir() ) 484 else if( fi->isDir() )
485 addDir( fi ); 485 addDir( fi );
486 else if( fi->isFile() ) 486 else if( fi->isFile() )
487 addFile( fi ); 487 addFile( fi );
488 488
489 ++it; 489 ++it;
490 } // of while loop 490 } // of while loop
491 m_view->sort(); 491 m_view->sort();
492 492
493} 493}
494int OFileViewFileListView::fileCount()const 494int OFileViewFileListView::fileCount()const
495{ 495{
496 return m_view->childCount(); 496 return m_view->childCount();
497} 497}
498 498
499QString OFileViewFileListView::currentDir()const 499QString OFileViewFileListView::currentDir()const
500{ 500{
501 return m_currentDir; 501 return m_currentDir;
502} 502}
503 503
504OFileSelector* OFileViewFileListView::selector() 504OFileSelector* OFileViewFileListView::selector()
505{ 505{
506 return m_sel; 506 return m_sel;
507} 507}
508 508
509bool OFileViewFileListView::eventFilter (QObject *o, QEvent *e) 509bool OFileViewFileListView::eventFilter (QObject *o, QEvent *e)
510{ 510{
511 if ( e->type() == QEvent::KeyPress ) 511 if ( e->type() == QEvent::KeyPress )
512 { 512 {
513 QKeyEvent *k = (QKeyEvent *)e; 513 QKeyEvent *k = (QKeyEvent *)e;
514 if ( (k->key()==Key_Enter) || (k->key()==Key_Return)) 514 if ( (k->key()==Key_Enter) || (k->key()==Key_Return))
515 { 515 {
516 slotClicked( Qt::LeftButton,m_view->currentItem(),QPoint(0,0),0); 516 slotClicked( Qt::LeftButton,m_view->currentItem(),QPoint(0,0),0);
517 return true; 517 return true;
518 } 518 }
519 } 519 }
520 return false; 520 return false;
521} 521}
522 522
523void OFileViewFileListView::connectSlots() 523void OFileViewFileListView::connectSlots()
524{ 524{
525 connect(m_view, SIGNAL(clicked(QListViewItem*) ), 525 connect(m_view, SIGNAL(clicked(QListViewItem*) ),
526 this, SLOT(slotCurrentChanged(QListViewItem*) ) ); 526 this, SLOT(slotCurrentChanged(QListViewItem*) ) );
527 connect(m_view, SIGNAL(mouseButtonClicked(int, QListViewItem*, const QPoint&, int ) ), 527 connect(m_view, SIGNAL(mouseButtonClicked(int,QListViewItem*,const QPoint&,int) ),
528 this, SLOT(slotClicked(int, QListViewItem*, const QPoint&, int ) ) ); 528 this, SLOT(slotClicked(int,QListViewItem*,const QPoint&,int) ) );
529} 529}
530 530
531void OFileViewFileListView::slotCurrentChanged( QListViewItem* item) 531void OFileViewFileListView::slotCurrentChanged( QListViewItem* item)
532{ 532{
533 if (!item) 533 if (!item)
534 return; 534 return;
535#if 0 535#if 0
536 536
537 OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item); 537 OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item);
538 538
539 if (!sel->isDir() ) 539 if (!sel->isDir() )
540 { 540 {
541 selector()->m_lneEdit->setText( sel->text(1) ); 541 selector()->m_lneEdit->setText( sel->text(1) );
542 // if in fileselector mode we will emit selected 542 // if in fileselector mode we will emit selected
543 if ( selector()->mode() == OFileSelector::FileSelector ) 543 if ( selector()->mode() == OFileSelector::FileSelector )
544 { 544 {
545 qWarning("slot Current Changed"); 545 qWarning("slot Current Changed");
546 QStringList str = QStringList::split("->", sel->text(1) ); 546 QStringList str = QStringList::split("->", sel->text(1) );
547 QString path = sel->directory() + "/" + str[0].stripWhiteSpace(); 547 QString path = sel->directory() + "/" + str[0].stripWhiteSpace();
548 emit selector()->fileSelected( path ); 548 emit selector()->fileSelected( path );
549 DocLnk lnk( path ); 549 DocLnk lnk( path );
550 emit selector()->fileSelected( lnk ); 550 emit selector()->fileSelected( lnk );
551 } 551 }
552 } 552 }
553#endif 553#endif
554} 554}
555 555
556void OFileViewFileListView::slotClicked(int button , QListViewItem* item, const QPoint&, int ) 556void OFileViewFileListView::slotClicked(int button , QListViewItem* item, const QPoint&, int )
557{ 557{
558 if (!item || ( button != Qt::LeftButton) ) 558 if (!item || ( button != Qt::LeftButton) )
559 return; 559 return;
560 560
561 OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item); 561 OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item);
562 if (!sel->isLocked() ) 562 if (!sel->isLocked() )
563 { 563 {
564 QStringList str = QStringList::split("->", sel->text(1) ); 564 QStringList str = QStringList::split("->", sel->text(1) );
565 if (sel->isDir() ) 565 if (sel->isDir() )
566 { 566 {
567 m_currentDir = sel->directory() + "/" + str[0].stripWhiteSpace(); 567 m_currentDir = sel->directory() + "/" + str[0].stripWhiteSpace();
568 emit selector()->dirSelected( m_currentDir ); 568 emit selector()->dirSelected( m_currentDir );
569 reread( m_all ); 569 reread( m_all );
570 } 570 }
571 else 571 else
572 { // file 572 { // file
573 qWarning("slot Clicked"); 573 qWarning("slot Clicked");
574 selector()->m_lneEdit->setText( str[0].stripWhiteSpace() ); 574 selector()->m_lneEdit->setText( str[0].stripWhiteSpace() );
575 QString path = sel->directory() + "/" + str[0].stripWhiteSpace(); 575 QString path = sel->directory() + "/" + str[0].stripWhiteSpace();
576 emit selector()->fileSelected( path ); 576 emit selector()->fileSelected( path );
577 DocLnk lnk( path ); 577 DocLnk lnk( path );
578 emit selector()->fileSelected( lnk ); 578 emit selector()->fileSelected( lnk );
579 } 579 }
580 } // not locked 580 } // not locked
581} 581}
582 582
583void OFileViewFileListView::addFile( QFileInfo* info, bool symlink ) 583void OFileViewFileListView::addFile( QFileInfo* info, bool symlink )
584{ 584{
585 MimeType type( info->absFilePath() ); 585 MimeType type( info->absFilePath() );
586 if (!compliesMime( type.id() ) ) 586 if (!compliesMime( type.id() ) )
587 return; 587 return;
588 588
589 QPixmap pix = type.pixmap(); 589 QPixmap pix = type.pixmap();
590 QString dir, name; bool locked; 590 QString dir, name; bool locked;
591 if ( pix.isNull() ) 591 if ( pix.isNull() )
592 { 592 {
593 QWMatrix matrix; 593 QWMatrix matrix;
594 QPixmap pixer(Resource::loadPixmap("UnknownDocument") ); 594 QPixmap pixer(Resource::loadPixmap("UnknownDocument") );
595 matrix.scale( .4, .4 ); 595 matrix.scale( .4, .4 );
596 pix = pixer.xForm( matrix ); 596 pix = pixer.xForm( matrix );
597 } 597 }
598 dir = info->dirPath( true ); 598 dir = info->dirPath( true );
599 locked = false; 599 locked = false;
600 if ( symlink ) 600 if ( symlink )
601 name = info->fileName() + " -> " + info->dirPath() + "/" + info->readLink(); 601 name = info->fileName() + " -> " + info->dirPath() + "/" + info->readLink();
602 else 602 else
603 { 603 {
604 name = info->fileName(); 604 name = info->fileName();
605 if ( ( (selector()->mode() == OFileSelector::Open)&& !info->isReadable() ) || 605 if ( ( (selector()->mode() == OFileSelector::Open)&& !info->isReadable() ) ||
606 ( (selector()->mode() == OFileSelector::Save)&& !info->isWritable() ) ) 606 ( (selector()->mode() == OFileSelector::Save)&& !info->isWritable() ) )
607 { 607 {
608 locked = true; pix = Resource::loadPixmap("locked"); 608 locked = true; pix = Resource::loadPixmap("locked");
609 } 609 }
610 } 610 }
611 (void)new OFileSelectorItem( m_view, pix, name, 611 (void)new OFileSelectorItem( m_view, pix, name,
612 info->lastModified().toString(), QString::number( info->size() ), 612 info->lastModified().toString(), QString::number( info->size() ),
613 dir, locked ); 613 dir, locked );
614} 614}
615 615
616void OFileViewFileListView::addDir( QFileInfo* info, bool symlink ) 616void OFileViewFileListView::addDir( QFileInfo* info, bool symlink )
617{ 617{
618 bool locked = false; QString name; QPixmap pix; 618 bool locked = false; QString name; QPixmap pix;
619 619
620 if ( ( ( selector()->mode() == OFileSelector::Open ) && !info->isReadable() ) || 620 if ( ( ( selector()->mode() == OFileSelector::Open ) && !info->isReadable() ) ||
621 ( ( selector()->mode() == OFileSelector::Save ) && !info->isWritable() ) ) 621 ( ( selector()->mode() == OFileSelector::Save ) && !info->isWritable() ) )
622 { 622 {
623 locked = true; 623 locked = true;
624 if ( symlink ) 624 if ( symlink )
625 pix = Resource::loadPixmap( "opie/symlink" ); 625 pix = Resource::loadPixmap( "opie/symlink" );
626 else 626 else
627 pix = Resource::loadPixmap( "lockedfolder" ); 627 pix = Resource::loadPixmap( "lockedfolder" );
628 } 628 }
629 else 629 else
630 pix = symlink ? Resource::loadPixmap( "opie/symlink") : Resource::loadPixmap("folder"); 630 pix = symlink ? Resource::loadPixmap( "opie/symlink") : Resource::loadPixmap("folder");
631 631
632 name = symlink ? info->fileName() + " -> " + info->dirPath(true) + "/" + info->readLink() : 632 name = symlink ? info->fileName() + " -> " + info->dirPath(true) + "/" + info->readLink() :
633 info->fileName(); 633 info->fileName();
634 634
635 (void)new OFileSelectorItem( m_view, pix, name, 635 (void)new OFileSelectorItem( m_view, pix, name,
636 info->lastModified().toString(), 636 info->lastModified().toString(),
637 QString::number( info->size() ), 637 QString::number( info->size() ),
638 info->dirPath( true ), locked, true ); 638 info->dirPath( true ), locked, true );
639 639
640 640
641} 641}
642 642
643void OFileViewFileListView::addSymlink( QFileInfo* , bool ) 643void OFileViewFileListView::addSymlink( QFileInfo* , bool )
644{ 644{
645} 645}
646 646
647void OFileViewFileListView::cdUP() 647void OFileViewFileListView::cdUP()
648{ 648{
649 QDir dir( m_currentDir ); 649 QDir dir( m_currentDir );
650 dir.cdUp(); 650 dir.cdUp();
651 651
652 if (!dir.exists() ) 652 if (!dir.exists() )
653 m_currentDir = "/"; 653 m_currentDir = "/";
654 else 654 else
655 m_currentDir = dir.absPath(); 655 m_currentDir = dir.absPath();
656 656
657 emit selector()->dirSelected( m_currentDir ); 657 emit selector()->dirSelected( m_currentDir );
658 reread( m_all ); 658 reread( m_all );
659} 659}
660 660
661void OFileViewFileListView::cdHome() 661void OFileViewFileListView::cdHome()
662{ 662{
663 m_currentDir = QDir::homeDirPath(); 663 m_currentDir = QDir::homeDirPath();
664 emit selector()->dirSelected( m_currentDir ); 664 emit selector()->dirSelected( m_currentDir );
665 reread( m_all ); 665 reread( m_all );
666} 666}
667 667
668void OFileViewFileListView::cdDoc() 668void OFileViewFileListView::cdDoc()
669{ 669{
670 m_currentDir = QPEApplication::documentDir(); 670 m_currentDir = QPEApplication::documentDir();
671 emit selector()->dirSelected( m_currentDir ); 671 emit selector()->dirSelected( m_currentDir );
672 reread( m_all ); 672 reread( m_all );
673} 673}
674 674
675void OFileViewFileListView::changeDir( const QString& dir ) 675void OFileViewFileListView::changeDir( const QString& dir )
676{ 676{
677 m_currentDir = dir; 677 m_currentDir = dir;
678 emit selector()->dirSelected( m_currentDir ); 678 emit selector()->dirSelected( m_currentDir );
679 reread( m_all ); 679 reread( m_all );
680} 680}
681 681
682void OFileViewFileListView::slotFSActivated( int id ) 682void OFileViewFileListView::slotFSActivated( int id )
683{ 683{
684 changeDir ( m_dev[m_fsPop->text(id)] ); 684 changeDir ( m_dev[m_fsPop->text(id)] );
685} 685}
686 686
687/* check if the mimetype in mime 687/* check if the mimetype in mime
688 * complies with the one which is current 688 * complies with the one which is current
689 */ 689 */
690/* 690/*
691 * We've the mimetype of the file 691 * We've the mimetype of the file
692 * We need to get the stringlist of the current mimetype 692 * We need to get the stringlist of the current mimetype
693 * 693 *
694 * mime = image@slashjpeg 694 * mime = image@slashjpeg
695 * QStringList = 'image@slash*' 695 * QStringList = 'image@slash*'
696 * or QStringList = image/jpeg;image/png;application/x-ogg 696 * or QStringList = image/jpeg;image/png;application/x-ogg
697 * or QStringList = application/x-ogg;image@slash*; 697 * or QStringList = application/x-ogg;image@slash*;
698 * with all these mime filters it should get acceptes 698 * with all these mime filters it should get acceptes
699 * to do so we need to look if mime is contained inside 699 * to do so we need to look if mime is contained inside
700 * the stringlist 700 * the stringlist
701 * if it's contained return true 701 * if it's contained return true
702 * if not ( I'm no RegExp expert at all ) we'll look if a '@slash*' 702 * if not ( I'm no RegExp expert at all ) we'll look if a '@slash*'
703 * is contained in the mimefilter and then we will 703 * is contained in the mimefilter and then we will
704 * look if both are equal until the '/' 704 * look if both are equal until the '/'
705 */ 705 */
706 706
707bool OFileViewFileListView::compliesMime( const QString& str) 707bool OFileViewFileListView::compliesMime( const QString& str)
708{ 708{
709 if (str.isEmpty() || m_mimes.isEmpty() || str.stripWhiteSpace().isEmpty() ) 709 if (str.isEmpty() || m_mimes.isEmpty() || str.stripWhiteSpace().isEmpty() )
710 return true; 710 return true;
711 711
712 for (QStringList::Iterator it = m_mimes.begin(); it != m_mimes.end(); ++it ) 712 for (QStringList::Iterator it = m_mimes.begin(); it != m_mimes.end(); ++it )
713 { 713 {
714 QRegExp reg( (*it) ); 714 QRegExp reg( (*it) );
715 reg.setWildcard( true ); 715 reg.setWildcard( true );
716 if ( str.find( reg ) != -1 ) 716 if ( str.find( reg ) != -1 )
717 return true; 717 return true;
718 718
719 } 719 }
720 return false; 720 return false;
@@ -790,377 +790,377 @@ void OFileViewFileSystem::reread()
790} 790}
791 791
792int OFileViewFileSystem::fileCount()const 792int OFileViewFileSystem::fileCount()const
793{ 793{
794 if (!m_view ) 794 if (!m_view )
795 return -1; 795 return -1;
796 return m_view->fileCount(); 796 return m_view->fileCount();
797} 797}
798 798
799QWidget* OFileViewFileSystem::widget( QWidget* parent ) 799QWidget* OFileViewFileSystem::widget( QWidget* parent )
800{ 800{
801 if (!m_view ) 801 if (!m_view )
802 { 802 {
803 m_view = new OFileViewFileListView( parent, startDirectory(), selector() ); 803 m_view = new OFileViewFileListView( parent, startDirectory(), selector() );
804 } 804 }
805 return m_view; 805 return m_view;
806} 806}
807 807
808void OFileViewFileSystem::activate( const QString& str) 808void OFileViewFileSystem::activate( const QString& str)
809{ 809{
810 m_all = (str != QObject::tr("Files") ); 810 m_all = (str != QObject::tr("Files") );
811} 811}
812 812
813/* Selector */ 813/* Selector */
814/** 814/**
815 * @short new and complete c'tor 815 * @short new and complete c'tor
816 * 816 *
817 * Create a OFileSelector to let the user select a file. It can 817 * Create a OFileSelector to let the user select a file. It can
818 * either be used to open a file, select a save name in a dir or 818 * either be used to open a file, select a save name in a dir or
819 * as a dropin for the FileSelector. 819 * as a dropin for the FileSelector.
820 * 820 *
821 * <pre> 821 * <pre>
822 * QMap<QString, QStringList> mimeTypes; 822 * QMap<QString, QStringList> mimeTypes;
823 * QStringList types; 823 * QStringList types;
824 * types << "text@slash* "; 824 * types << "text@slash* ";
825 * types << "audio@slash*"; 825 * types << "audio@slash*";
826 * mimeTypes.insert( tr("Audio and Text"), types ); 826 * mimeTypes.insert( tr("Audio and Text"), types );
827 * mimeTypes.insert( tr("All"), "*@slash*); 827 * mimeTypes.insert( tr("All"), "*@slash*);
828 * 828 *
829 * now you could create your fileselector 829 * now you could create your fileselector
830 * </pre> 830 * </pre>
831 * 831 *
832 * 832 *
833 * @param parent the parent of this widget 833 * @param parent the parent of this widget
834 * @param mode The mode from the enum Mode (Open,Save,FILESELECTOR) 834 * @param mode The mode from the enum Mode (Open,Save,FILESELECTOR)
835 * @param sel The selector to be used 835 * @param sel The selector to be used
836 * @param dirName The name of the dir to start int 836 * @param dirName The name of the dir to start int
837 * @param fileName The fileName placed in the fileselector lineedit 837 * @param fileName The fileName placed in the fileselector lineedit
838 * @param mimetypes The MimeType map of used mimetypes 838 * @param mimetypes The MimeType map of used mimetypes
839 * @param showNew Show a New Button. Most likely to be used in the FileSelector view. 839 * @param showNew Show a New Button. Most likely to be used in the FileSelector view.
840 * @param showClose Show a Close Button. Most likely to be used in FileSelector view. 840 * @param showClose Show a Close Button. Most likely to be used in FileSelector view.
841 * 841 *
842 */ 842 */
843OFileSelector::OFileSelector( QWidget* parent, int mode, int sel, 843OFileSelector::OFileSelector( QWidget* parent, int mode, int sel,
844 const QString& dirName, const QString& fileName, 844 const QString& dirName, const QString& fileName,
845 const MimeTypes& mimetypes, 845 const MimeTypes& mimetypes,
846 bool showNew, bool showClose) 846 bool showNew, bool showClose)
847 :QWidget( parent, "OFileSelector" ) 847 :QWidget( parent, "OFileSelector" )
848{ 848{
849 m_current = 0; 849 m_current = 0;
850 m_shNew = showNew; 850 m_shNew = showNew;
851 m_shClose = showClose; 851 m_shClose = showClose;
852 m_mimeType = mimetypes; 852 m_mimeType = mimetypes;
853 m_startDir = dirName; 853 m_startDir = dirName;
854 854
855 m_mode = mode; 855 m_mode = mode;
856 m_selector = sel; 856 m_selector = sel;
857 857
858 initUI(); 858 initUI();
859 m_lneEdit->setText( fileName ); 859 m_lneEdit->setText( fileName );
860 initMime(); 860 initMime();
861 initViews(); 861 initViews();
862 862
863 QString str; 863 QString str;
864 switch ( m_selector ) 864 switch ( m_selector )
865 { 865 {
866 default: 866 default:
867 case Normal: 867 case Normal:
868 str = QObject::tr("Documents"); 868 str = QObject::tr("Documents");
869 m_cmbView->setCurrentItem( 0 ); 869 m_cmbView->setCurrentItem( 0 );
870 break; 870 break;
871 case Extended: 871 case Extended:
872 str = QObject::tr("Files"); 872 str = QObject::tr("Files");
873 m_cmbView->setCurrentItem( 1 ); 873 m_cmbView->setCurrentItem( 1 );
874 break; 874 break;
875 case ExtendedAll: 875 case ExtendedAll:
876 str = QObject::tr("All Files"); 876 str = QObject::tr("All Files");
877 m_cmbView->setCurrentItem( 2 ); 877 m_cmbView->setCurrentItem( 2 );
878 break; 878 break;
879 } 879 }
880 slotViewChange( str ); 880 slotViewChange( str );
881 881
882} 882}
883 883
884 884
885/** 885/**
886 * This a convience c'tor to just substitute the use of FileSelector 886 * This a convience c'tor to just substitute the use of FileSelector
887 */ 887 */
888OFileSelector::OFileSelector( const QString& mimeFilter, QWidget* parent, const char* name, 888OFileSelector::OFileSelector( const QString& mimeFilter, QWidget* parent, const char* name,
889 bool showNew, bool showClose ) 889 bool showNew, bool showClose )
890 : QWidget( parent, name ) 890 : QWidget( parent, name )
891{ 891{
892 m_current = 0; 892 m_current = 0;
893 m_shNew = showNew; 893 m_shNew = showNew;
894 m_shClose = showClose; 894 m_shClose = showClose;
895 m_startDir = QPEApplication::documentDir(); 895 m_startDir = QPEApplication::documentDir();
896 896
897 if (!mimeFilter.isEmpty() ) 897 if (!mimeFilter.isEmpty() )
898 m_mimeType.insert(mimeFilter, QStringList::split(";", mimeFilter ) ); 898 m_mimeType.insert(mimeFilter, QStringList::split(";", mimeFilter ) );
899 899
900 m_mode = OFileSelector::FileSelector; 900 m_mode = OFileSelector::FileSelector;
901 m_selector = OFileSelector::Normal; 901 m_selector = OFileSelector::Normal;
902 902
903 initUI(); 903 initUI();
904 initMime(); 904 initMime();
905 initViews(); 905 initViews();
906 m_cmbView->setCurrentItem( 0 ); 906 m_cmbView->setCurrentItem( 0 );
907 slotViewChange( QObject::tr("Documents") ); 907 slotViewChange( QObject::tr("Documents") );
908} 908}
909 909
910/* 910/*
911 * INIT UI will set up the basic GUI 911 * INIT UI will set up the basic GUI
912 * Layout: Simple VBoxLayout 912 * Layout: Simple VBoxLayout
913 * On top a WidgetStack containing the Views... 913 * On top a WidgetStack containing the Views...
914 * - List View 914 * - List View
915 * - Document View 915 * - Document View
916 * Below we will have a Label + LineEdit 916 * Below we will have a Label + LineEdit
917 * Below we will have two ComoBoxes one for choosing the view one for 917 * Below we will have two ComoBoxes one for choosing the view one for
918 * choosing the mimetype 918 * choosing the mimetype
919 */ 919 */
920void OFileSelector::initUI() 920void OFileSelector::initUI()
921{ 921{
922 QVBoxLayout* lay = new QVBoxLayout( this ); 922 QVBoxLayout* lay = new QVBoxLayout( this );
923 923
924 m_stack = new QWidgetStack( this ); 924 m_stack = new QWidgetStack( this );
925 lay->addWidget( m_stack, 1000 ); 925 lay->addWidget( m_stack, 1000 );
926 926
927 m_nameBox = new QHBox( this ); 927 m_nameBox = new QHBox( this );
928 (void)new QLabel( tr("Name:"), m_nameBox ); 928 (void)new QLabel( tr("Name:"), m_nameBox );
929 m_lneEdit = new QLineEdit( m_nameBox ); 929 m_lneEdit = new QLineEdit( m_nameBox );
930 m_lneEdit ->installEventFilter(this); 930 m_lneEdit ->installEventFilter(this);
931 lay->addWidget( m_nameBox ); 931 lay->addWidget( m_nameBox );
932 932
933 m_cmbBox = new QHBox( this ); 933 m_cmbBox = new QHBox( this );
934 m_cmbView = new QComboBox( m_cmbBox ); 934 m_cmbView = new QComboBox( m_cmbBox );
935 m_cmbMime = new QComboBox( m_cmbBox ); 935 m_cmbMime = new QComboBox( m_cmbBox );
936 lay->addWidget( m_cmbBox ); 936 lay->addWidget( m_cmbBox );
937} 937}
938 938
939/* 939/*
940 * This will make sure that the return key in the name edit causes dialogs to close 940 * This will make sure that the return key in the name edit causes dialogs to close
941 */ 941 */
942 942
943bool OFileSelector::eventFilter (QObject *o, QEvent *e) 943bool OFileSelector::eventFilter (QObject *o, QEvent *e)
944{ 944{
945 if ( e->type() == QEvent::KeyPress ) 945 if ( e->type() == QEvent::KeyPress )
946 { 946 {
947 QKeyEvent *k = (QKeyEvent *)e; 947 QKeyEvent *k = (QKeyEvent *)e;
948 if ( (k->key()==Key_Enter) || (k->key()==Key_Return)) 948 if ( (k->key()==Key_Enter) || (k->key()==Key_Return))
949 { 949 {
950 emit ok(); 950 emit ok();
951 return true; 951 return true;
952 } 952 }
953 } 953 }
954 return false; 954 return false;
955} 955}
956 956
957/* 957/*
958 * This will insert the MimeTypes into the Combo Box 958 * This will insert the MimeTypes into the Combo Box
959 * And also connect the changed signal 959 * And also connect the changed signal
960 * 960 *
961 * AutoMimeTyping is disabled for now. It used to reparse a dir and then set available mimetypes 961 * AutoMimeTyping is disabled for now. It used to reparse a dir and then set available mimetypes
962 */ 962 */
963void OFileSelector::initMime() 963void OFileSelector::initMime()
964{ 964{
965 MimeTypes::Iterator it; 965 MimeTypes::Iterator it;
966 for ( it = m_mimeType.begin(); it != m_mimeType.end(); ++it ) 966 for ( it = m_mimeType.begin(); it != m_mimeType.end(); ++it )
967 { 967 {
968 m_cmbMime->insertItem( it.key() ); 968 m_cmbMime->insertItem( it.key() );
969 } 969 }
970 m_cmbMime->setCurrentItem( 0 ); 970 m_cmbMime->setCurrentItem( 0 );
971 971
972 connect( m_cmbMime, SIGNAL(activated(int) ), 972 connect( m_cmbMime, SIGNAL(activated(int) ),
973 this, SLOT(slotMimeTypeChanged() ) ); 973 this, SLOT(slotMimeTypeChanged() ) );
974 974
975} 975}
976 976
977void OFileSelector::initViews() 977void OFileSelector::initViews()
978{ 978{
979 m_cmbView->insertItem( QObject::tr("Documents") ); 979 m_cmbView->insertItem( QObject::tr("Documents") );
980 m_cmbView->insertItem( QObject::tr("Files") ); 980 m_cmbView->insertItem( QObject::tr("Files") );
981 m_cmbView->insertItem( QObject::tr("All Files") ); 981 m_cmbView->insertItem( QObject::tr("All Files") );
982 connect(m_cmbView, SIGNAL(activated( const QString& ) ), 982 connect(m_cmbView, SIGNAL(activated(const QString&) ),
983 this, SLOT(slotViewChange( const QString& ) ) ); 983 this, SLOT(slotViewChange(const QString&) ) );
984 984
985 985
986 m_views.insert( QObject::tr("Documents"), new ODocumentFileView(this) ); 986 m_views.insert( QObject::tr("Documents"), new ODocumentFileView(this) );
987 987
988 /* see above why add both */ 988 /* see above why add both */
989 OFileViewInterface* in = new OFileViewFileSystem( this ); 989 OFileViewInterface* in = new OFileViewFileSystem( this );
990 m_views.insert( QObject::tr("Files"), in ); 990 m_views.insert( QObject::tr("Files"), in );
991 m_views.insert( QObject::tr("All Files"), in ); 991 m_views.insert( QObject::tr("All Files"), in );
992} 992}
993 993
994/** 994/**
995 * d'tor 995 * d'tor
996 */ 996 */
997OFileSelector::~OFileSelector() 997OFileSelector::~OFileSelector()
998{ 998{
999} 999}
1000 1000
1001 1001
1002 1002
1003/** 1003/**
1004 * Convience function for the fileselector 1004 * Convience function for the fileselector
1005 * make sure to delete the DocLnk 1005 * make sure to delete the DocLnk
1006 * 1006 *
1007 * @see DocLnk 1007 * @see DocLnk
1008 * @todo remove in ODP 1008 * @todo remove in ODP
1009 */ 1009 */
1010const DocLnk* OFileSelector::selected() 1010const DocLnk* OFileSelector::selected()
1011{ 1011{
1012 DocLnk* lnk = new DocLnk( currentView()->selectedDocument() ); 1012 DocLnk* lnk = new DocLnk( currentView()->selectedDocument() );
1013 return lnk; 1013 return lnk;
1014} 1014}
1015 1015
1016/** 1016/**
1017 * 1017 *
1018 * @return the name of the selected file 1018 * @return the name of the selected file
1019 */ 1019 */
1020QString OFileSelector::selectedName()const 1020QString OFileSelector::selectedName()const
1021{ 1021{
1022 return currentView()->selectedName(); 1022 return currentView()->selectedName();
1023} 1023}
1024 1024
1025 1025
1026/** 1026/**
1027 * @return the selected path 1027 * @return the selected path
1028 */ 1028 */
1029QString OFileSelector::selectedPath()const 1029QString OFileSelector::selectedPath()const
1030{ 1030{
1031 return currentView()->selectedPath(); 1031 return currentView()->selectedPath();
1032} 1032}
1033 1033
1034/** 1034/**
1035 * @return the directory name 1035 * @return the directory name
1036 */ 1036 */
1037QString OFileSelector::directory()const 1037QString OFileSelector::directory()const
1038{ 1038{
1039 return currentView()->directory(); 1039 return currentView()->directory();
1040} 1040}
1041 1041
1042/** 1042/**
1043 * @return a DocLnk for the selected document 1043 * @return a DocLnk for the selected document
1044 */ 1044 */
1045DocLnk OFileSelector::selectedDocument()const 1045DocLnk OFileSelector::selectedDocument()const
1046{ 1046{
1047 return currentView()->selectedDocument(); 1047 return currentView()->selectedDocument();
1048} 1048}
1049 1049
1050/** 1050/**
1051 * @return the number of items for the current view 1051 * @return the number of items for the current view
1052 */ 1052 */
1053int OFileSelector::fileCount()const 1053int OFileSelector::fileCount()const
1054{ 1054{
1055 return currentView()->fileCount(); 1055 return currentView()->fileCount();
1056} 1056}
1057 1057
1058/** 1058/**
1059 * @return reparse the file content 1059 * @return reparse the file content
1060 */ 1060 */
1061void OFileSelector::reread() 1061void OFileSelector::reread()
1062{ 1062{
1063 return currentView()->reread(); 1063 return currentView()->reread();
1064} 1064}
1065 1065
1066OFileViewInterface* OFileSelector::currentView()const 1066OFileViewInterface* OFileSelector::currentView()const
1067{ 1067{
1068 return m_current; 1068 return m_current;
1069} 1069}
1070 1070
1071bool OFileSelector::showNew()const 1071bool OFileSelector::showNew()const
1072{ 1072{
1073 return m_shNew; 1073 return m_shNew;
1074} 1074}
1075 1075
1076bool OFileSelector::showClose()const 1076bool OFileSelector::showClose()const
1077{ 1077{
1078 return m_shClose; 1078 return m_shClose;
1079} 1079}
1080 1080
1081MimeTypes OFileSelector::mimeTypes()const 1081MimeTypes OFileSelector::mimeTypes()const
1082{ 1082{
1083 return m_mimeType; 1083 return m_mimeType;
1084} 1084}
1085 1085
1086/** 1086/**
1087 * @return the Mode of the OFileSelector 1087 * @return the Mode of the OFileSelector
1088 */ 1088 */
1089int OFileSelector::mode()const 1089int OFileSelector::mode()const
1090{ 1090{
1091 return m_mode; 1091 return m_mode;
1092} 1092}
1093 1093
1094 1094
1095/** 1095/**
1096 * @return the Selector of the OFileSelector 1096 * @return the Selector of the OFileSelector
1097 */ 1097 */
1098int OFileSelector::selector()const 1098int OFileSelector::selector()const
1099{ 1099{
1100 return m_selector; 1100 return m_selector;
1101} 1101}
1102 1102
1103QStringList OFileSelector::currentMimeType()const 1103QStringList OFileSelector::currentMimeType()const
1104{ 1104{
1105 return m_mimeType[m_cmbMime->currentText()]; 1105 return m_mimeType[m_cmbMime->currentText()];
1106} 1106}
1107 1107
1108void OFileSelector::slotMimeTypeChanged() 1108void OFileSelector::slotMimeTypeChanged()
1109{ 1109{
1110 reread(); 1110 reread();
1111} 1111}
1112 1112
1113void OFileSelector::slotDocLnkBridge( const DocLnk& lnk) 1113void OFileSelector::slotDocLnkBridge( const DocLnk& lnk)
1114{ 1114{
1115 m_lneEdit->setText( lnk.name() ); 1115 m_lneEdit->setText( lnk.name() );
1116 emit fileSelected( lnk ); 1116 emit fileSelected( lnk );
1117 emit fileSelected( lnk.name() ); 1117 emit fileSelected( lnk.name() );
1118} 1118}
1119 1119
1120void OFileSelector::slotFileBridge( const QString& str) 1120void OFileSelector::slotFileBridge( const QString& str)
1121{ 1121{
1122 DocLnk lnk( str ); 1122 DocLnk lnk( str );
1123 emit fileSelected( lnk ); 1123 emit fileSelected( lnk );
1124} 1124}
1125 1125
1126void OFileSelector::slotViewChange( const QString& view ) 1126void OFileSelector::slotViewChange( const QString& view )
1127{ 1127{
1128 OFileViewInterface* interface = m_views[view]; 1128 OFileViewInterface* interface = m_views[view];
1129 if (!interface) 1129 if (!interface)
1130 return; 1130 return;
1131 1131
1132 interface->activate( view ); 1132 interface->activate( view );
1133 if (m_current) 1133 if (m_current)
1134 m_stack->removeWidget( m_current->widget( m_stack ) ); 1134 m_stack->removeWidget( m_current->widget( m_stack ) );
1135 1135
1136 static int id = 1; 1136 static int id = 1;
1137 1137
1138 m_stack->addWidget( interface->widget(m_stack), id ); 1138 m_stack->addWidget( interface->widget(m_stack), id );
1139 m_stack->raiseWidget( id ); 1139 m_stack->raiseWidget( id );
1140 1140
1141 interface->reread(); 1141 interface->reread();
1142 m_current = interface; 1142 m_current = interface;
1143 1143
1144 id++; 1144 id++;
1145} 1145}
1146 1146
1147void OFileSelector::setNewVisible( bool b ) 1147void OFileSelector::setNewVisible( bool b )
1148{ 1148{
1149 m_shNew = b; 1149 m_shNew = b;
1150 currentView()->reread(); 1150 currentView()->reread();
1151} 1151}
1152 1152
1153void OFileSelector::setCloseVisible( bool b ) 1153void OFileSelector::setCloseVisible( bool b )
1154{ 1154{
1155 m_shClose = b; 1155 m_shClose = b;
1156 currentView()->reread(); 1156 currentView()->reread();
1157} 1157}
1158 1158
1159void OFileSelector::setNameVisible( bool b ) 1159void OFileSelector::setNameVisible( bool b )
1160{ 1160{
1161 if ( b ) 1161 if ( b )
1162 m_nameBox->show(); 1162 m_nameBox->show();
1163 else 1163 else
1164 m_nameBox->hide(); 1164 m_nameBox->hide();
1165} 1165}
1166 1166
diff --git a/libopie2/opieui/ofontselector.cpp b/libopie2/opieui/ofontselector.cpp
index 49ddeb6..f93781f 100644
--- a/libopie2/opieui/ofontselector.cpp
+++ b/libopie2/opieui/ofontselector.cpp
@@ -1,341 +1,341 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) Robert Griebl <sandman@handhelds.org> 3 Copyright (C) Robert Griebl <sandman@handhelds.org>
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org> 4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 .=l. 5 .=l.
6           .>+-= 6           .>+-=
7 _;:,     .>    :=|. This program is free software; you can 7 _;:,     .>    :=|. This program is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under 8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
10.="- .-=="i,     .._ License as published by the Free Software 10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License, 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version. 12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_. 13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This program is distributed in the hope that 14    .i_,=:_.      -<s. This program is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of 16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more 19..}^=.=       =       ; Library General Public License for more
20++=   -.     .`     .: details. 20++=   -.     .`     .: details.
21 :     =  ...= . :.=- 21 :     =  ...= . :.=-
22 -.   .:....=;==+<; You should have received a copy of the GNU 22 -.   .:....=;==+<; You should have received a copy of the GNU
23  -_. . .   )=.  = Library General Public License along with 23  -_. . .   )=.  = Library General Public License along with
24    --        :-=` this library; see the file COPYING.LIB. 24    --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29 29
30/* OPIE */ 30/* OPIE */
31#include <opie2/ofontselector.h> 31#include <opie2/ofontselector.h>
32#include <qpe/fontdatabase.h> 32#include <qpe/fontdatabase.h>
33 33
34/* QT */ 34/* QT */
35#include <qlayout.h> 35#include <qlayout.h>
36#include <qlistbox.h> 36#include <qlistbox.h>
37#include <qcombobox.h> 37#include <qcombobox.h>
38#include <qlabel.h> 38#include <qlabel.h>
39#include <qmultilineedit.h> 39#include <qmultilineedit.h>
40 40
41using namespace Opie; 41using namespace Opie;
42 42
43namespace Opie 43namespace Opie
44{ 44{
45 45
46class OFontSelectorPrivate 46class OFontSelectorPrivate
47{ 47{
48public: 48public:
49 QListBox * m_font_family_list; 49 QListBox * m_font_family_list;
50 QComboBox * m_font_style_list; 50 QComboBox * m_font_style_list;
51 QComboBox * m_font_size_list; 51 QComboBox * m_font_size_list;
52 QMultiLineEdit *m_preview; 52 QMultiLineEdit *m_preview;
53 53
54 bool m_pointbug : 1; 54 bool m_pointbug : 1;
55 55
56 FontDatabase m_fdb; 56 FontDatabase m_fdb;
57}; 57};
58 58
59}; 59};
60 60
61namespace 61namespace
62{ 62{
63 63
64class FontListItem : public QListBoxText 64class FontListItem : public QListBoxText
65{ 65{
66public: 66public:
67 FontListItem ( const QString &t, const QStringList &styles, const QValueList<int> &sizes ) : QListBoxText() 67 FontListItem ( const QString &t, const QStringList &styles, const QValueList<int> &sizes ) : QListBoxText()
68 { 68 {
69 m_name = t; 69 m_name = t;
70 m_styles = styles; 70 m_styles = styles;
71 m_sizes = sizes; 71 m_sizes = sizes;
72 72
73 QString str = t; 73 QString str = t;
74 str [0] = str [0]. upper(); 74 str [0] = str [0]. upper();
75 setText ( str ); 75 setText ( str );
76 } 76 }
77 77
78 QString family() const 78 QString family() const
79 { 79 {
80 return m_name; 80 return m_name;
81 } 81 }
82 82
83 const QStringList &styles() const 83 const QStringList &styles() const
84 { 84 {
85 return m_styles; 85 return m_styles;
86 } 86 }
87 87
88 const QValueList<int> &sizes() const 88 const QValueList<int> &sizes() const
89 { 89 {
90 return m_sizes; 90 return m_sizes;
91 } 91 }
92 92
93private: 93private:
94 QStringList m_styles; 94 QStringList m_styles;
95 QValueList<int> m_sizes; 95 QValueList<int> m_sizes;
96 QString m_name; 96 QString m_name;
97}; 97};
98 98
99 99
100static int findItemCB( QComboBox *box, const QString &str ) 100static int findItemCB( QComboBox *box, const QString &str )
101{ 101{
102 for ( int i = 0; i < box->count(); i++ ) 102 for ( int i = 0; i < box->count(); i++ )
103 { 103 {
104 if ( box->text ( i ) == str ) 104 if ( box->text ( i ) == str )
105 return i; 105 return i;
106 } 106 }
107 return -1; 107 return -1;
108} 108}
109 109
110} 110}
111/* static same as anon. namespace */ 111/* static same as anon. namespace */
112static int qt_version() 112static int qt_version()
113{ 113{
114 const char *qver = qVersion(); 114 const char *qver = qVersion();
115 115
116 return ( qver [0] - '0' ) * 100 + ( qver [2] - '0' ) * 10 + ( qver [4] - '0' ); 116 return ( qver [0] - '0' ) * 100 + ( qver [2] - '0' ) * 10 + ( qver [4] - '0' );
117} 117}
118 118
119/** 119/**
120 * Constructs the Selector object 120 * Constructs the Selector object
121 * @param withpreview If a font preview should be given 121 * @param withpreview If a font preview should be given
122 * @param parent The parent of the Font Selector 122 * @param parent The parent of the Font Selector
123 * @param name The name of the object 123 * @param name The name of the object
124 * @param fl WidgetFlags 124 * @param fl WidgetFlags
125 */ 125 */
126OFontSelector::OFontSelector( bool withpreview, QWidget *parent, const char *name, WFlags fl ) : QWidget ( parent, name, fl ) 126OFontSelector::OFontSelector( bool withpreview, QWidget *parent, const char *name, WFlags fl ) : QWidget ( parent, name, fl )
127{ 127{
128 d = new OFontSelectorPrivate(); 128 d = new OFontSelectorPrivate();
129 129
130 QGridLayout *gridLayout = new QGridLayout( this, 0, 0, 4, 4 ); 130 QGridLayout *gridLayout = new QGridLayout( this, 0, 0, 4, 4 );
131 gridLayout->setRowStretch( 4, 10 ); 131 gridLayout->setRowStretch( 4, 10 );
132 132
133 d->m_font_family_list = new QListBox( this, "FontListBox" ); 133 d->m_font_family_list = new QListBox( this, "FontListBox" );
134 gridLayout->addMultiCellWidget( d->m_font_family_list, 0, 4, 0, 0 ); 134 gridLayout->addMultiCellWidget( d->m_font_family_list, 0, 4, 0, 0 );
135 connect( d->m_font_family_list, SIGNAL( highlighted( int ) ), this, SLOT( fontFamilyClicked( int ) ) ); 135 connect( d->m_font_family_list, SIGNAL( highlighted(int) ), this, SLOT( fontFamilyClicked(int) ) );
136 136
137 QLabel *label = new QLabel( tr( "Style" ), this ); 137 QLabel *label = new QLabel( tr( "Style" ), this );
138 gridLayout->addWidget( label, 0, 1 ); 138 gridLayout->addWidget( label, 0, 1 );
139 139
140 d->m_font_style_list = new QComboBox( this, "StyleListBox" ); 140 d->m_font_style_list = new QComboBox( this, "StyleListBox" );
141 connect( d->m_font_style_list, SIGNAL( activated( int ) ), this, SLOT( fontStyleClicked( int ) ) ); 141 connect( d->m_font_style_list, SIGNAL( activated(int) ), this, SLOT( fontStyleClicked(int) ) );
142 gridLayout->addWidget( d->m_font_style_list, 1, 1 ); 142 gridLayout->addWidget( d->m_font_style_list, 1, 1 );
143 143
144 label = new QLabel( tr( "Size" ), this ); 144 label = new QLabel( tr( "Size" ), this );
145 gridLayout->addWidget( label, 2, 1 ); 145 gridLayout->addWidget( label, 2, 1 );
146 146
147 d->m_font_size_list = new QComboBox( this, "SizeListBox" ); 147 d->m_font_size_list = new QComboBox( this, "SizeListBox" );
148 connect( d->m_font_size_list, SIGNAL( activated( int ) ), 148 connect( d->m_font_size_list, SIGNAL( activated(int) ),
149 this, SLOT( fontSizeClicked( int ) ) ); 149 this, SLOT( fontSizeClicked(int) ) );
150 gridLayout->addWidget( d->m_font_size_list, 3, 1 ); 150 gridLayout->addWidget( d->m_font_size_list, 3, 1 );
151 151
152 d->m_pointbug = ( qt_version() <= 233 ); 152 d->m_pointbug = ( qt_version() <= 233 );
153 153
154 if ( withpreview ) 154 if ( withpreview )
155 { 155 {
156 d->m_preview = new QMultiLineEdit ( this, "Preview" ); 156 d->m_preview = new QMultiLineEdit ( this, "Preview" );
157 d->m_preview->setAlignment ( AlignCenter ); 157 d->m_preview->setAlignment ( AlignCenter );
158 d->m_preview->setWordWrap ( QMultiLineEdit::WidgetWidth ); 158 d->m_preview->setWordWrap ( QMultiLineEdit::WidgetWidth );
159 d->m_preview->setMargin ( 3 ); 159 d->m_preview->setMargin ( 3 );
160 d->m_preview->setText ( tr( "The Quick Brown Fox Jumps Over The Lazy Dog" )); 160 d->m_preview->setText ( tr( "The Quick Brown Fox Jumps Over The Lazy Dog" ));
161 gridLayout->addRowSpacing ( 5, 4 ); 161 gridLayout->addRowSpacing ( 5, 4 );
162 gridLayout->addMultiCellWidget ( d->m_preview, 6, 6, 0, 1 ); 162 gridLayout->addMultiCellWidget ( d->m_preview, 6, 6, 0, 1 );
163 gridLayout->setRowStretch ( 6, 5 ); 163 gridLayout->setRowStretch ( 6, 5 );
164 } 164 }
165 else 165 else
166 d->m_preview = 0; 166 d->m_preview = 0;
167 167
168 loadFonts ( d->m_font_family_list ); 168 loadFonts ( d->m_font_family_list );
169} 169}
170 170
171OFontSelector::~OFontSelector() 171OFontSelector::~OFontSelector()
172{ 172{
173 delete d; 173 delete d;
174} 174}
175 175
176/** 176/**
177 * This methods tries to set the font 177 * This methods tries to set the font
178 * @param f The wishes font 178 * @param f The wishes font
179 * @return success or failure 179 * @return success or failure
180 */ 180 */
181bool OFontSelector::setSelectedFont ( const QFont &f ) 181bool OFontSelector::setSelectedFont ( const QFont &f )
182{ 182{
183 return setSelectedFont ( f. family(), d->m_fdb. styleString ( f ), f. pointSize(), QFont::encodingName ( f. charSet())); 183 return setSelectedFont ( f. family(), d->m_fdb. styleString ( f ), f. pointSize(), QFont::encodingName ( f. charSet()));
184} 184}
185 185
186 186
187/** 187/**
188 * This is an overloaded method @see setSelectedFont 188 * This is an overloaded method @see setSelectedFont
189 * @param familyStr The family of the font 189 * @param familyStr The family of the font
190 * @param styleStr The style of the font 190 * @param styleStr The style of the font
191 * @param sizeVal The size of font 191 * @param sizeVal The size of font
192 * @param charset The charset to be used. Will be deprecated by QT3 192 * @param charset The charset to be used. Will be deprecated by QT3
193 */ 193 */
194bool OFontSelector::setSelectedFont( const QString &familyStr, const QString &styleStr, int sizeVal, const QString & charset ) 194bool OFontSelector::setSelectedFont( const QString &familyStr, const QString &styleStr, int sizeVal, const QString & charset )
195{ 195{
196 QString sizeStr = QString::number ( sizeVal ); 196 QString sizeStr = QString::number ( sizeVal );
197 197
198 QListBoxItem *family = d->m_font_family_list->findItem ( familyStr ); 198 QListBoxItem *family = d->m_font_family_list->findItem ( familyStr );
199 if ( !family ) 199 if ( !family )
200 family = d->m_font_family_list->findItem ( "Helvetica" ); 200 family = d->m_font_family_list->findItem ( "Helvetica" );
201 if ( !family ) 201 if ( !family )
202 family = d->m_font_family_list->firstItem(); 202 family = d->m_font_family_list->firstItem();
203 d->m_font_family_list->setCurrentItem ( family ); 203 d->m_font_family_list->setCurrentItem ( family );
204 fontFamilyClicked ( d->m_font_family_list->index ( family )); 204 fontFamilyClicked ( d->m_font_family_list->index ( family ));
205 205
206 int style = findItemCB ( d->m_font_style_list, styleStr ); 206 int style = findItemCB ( d->m_font_style_list, styleStr );
207 if ( style < 0 ) 207 if ( style < 0 )
208 style = findItemCB ( d->m_font_style_list, "Regular" ); 208 style = findItemCB ( d->m_font_style_list, "Regular" );
209 if ( style < 0 && d->m_font_style_list->count() > 0 ) 209 if ( style < 0 && d->m_font_style_list->count() > 0 )
210 style = 0; 210 style = 0;
211 d->m_font_style_list->setCurrentItem ( style ); 211 d->m_font_style_list->setCurrentItem ( style );
212 fontStyleClicked ( style ); 212 fontStyleClicked ( style );
213 213
214 int size = findItemCB ( d->m_font_size_list, sizeStr ); 214 int size = findItemCB ( d->m_font_size_list, sizeStr );
215 if ( size < 0 ) 215 if ( size < 0 )
216 size = findItemCB ( d->m_font_size_list, "10" ); 216 size = findItemCB ( d->m_font_size_list, "10" );
217 if ( size < 0 && d->m_font_size_list->count() > 0 ) 217 if ( size < 0 && d->m_font_size_list->count() > 0 )
218 size = 0; 218 size = 0;
219 d->m_font_size_list->setCurrentItem ( size ); 219 d->m_font_size_list->setCurrentItem ( size );
220 fontSizeClicked ( size ); 220 fontSizeClicked ( size );
221 221
222 return (( family ) && ( style >= 0 ) && ( size >= 0 )); 222 return (( family ) && ( style >= 0 ) && ( size >= 0 ));
223} 223}
224 224
225/** 225/**
226 * This method returns the name, style and size of the currently selected 226 * This method returns the name, style and size of the currently selected
227 * font or false if no font is selected 227 * font or false if no font is selected
228 * @param family The font family will be written there 228 * @param family The font family will be written there
229 * @param style The style will be written there 229 * @param style The style will be written there
230 * @param size The size will be written there 230 * @param size The size will be written there
231 * @return success or failure 231 * @return success or failure
232 */ 232 */
233bool OFontSelector::selectedFont ( QString &family, QString &style, int &size ) 233bool OFontSelector::selectedFont ( QString &family, QString &style, int &size )
234{ 234{
235 QString dummy; 235 QString dummy;
236 return selectedFont ( family, style, size, dummy ); 236 return selectedFont ( family, style, size, dummy );
237} 237}
238 238
239 239
240/** 240/**
241 * This method does return the font family or QString::null if there is 241 * This method does return the font family or QString::null if there is
242 * no font item selected 242 * no font item selected
243 * @return the font family 243 * @return the font family
244 */ 244 */
245QString OFontSelector::fontFamily() const 245QString OFontSelector::fontFamily() const
246{ 246{
247 FontListItem *fli = (FontListItem *) d->m_font_family_list->item ( d->m_font_family_list->currentItem()); 247 FontListItem *fli = (FontListItem *) d->m_font_family_list->item ( d->m_font_family_list->currentItem());
248 248
249 return fli ? fli->family() : QString::null; 249 return fli ? fli->family() : QString::null;
250} 250}
251 251
252/** 252/**
253 * This method will return the style of the font or QString::null 253 * This method will return the style of the font or QString::null
254 * @return the style of the font 254 * @return the style of the font
255 */ 255 */
256QString OFontSelector::fontStyle() const 256QString OFontSelector::fontStyle() const
257{ 257{
258 FontListItem *fli = (FontListItem *) d->m_font_family_list->item ( d->m_font_family_list->currentItem()); 258 FontListItem *fli = (FontListItem *) d->m_font_family_list->item ( d->m_font_family_list->currentItem());
259 int fst = d->m_font_style_list->currentItem(); 259 int fst = d->m_font_style_list->currentItem();
260 260
261 return ( fli && fst >= 0 ) ? fli->styles() [fst] : QString::null; 261 return ( fli && fst >= 0 ) ? fli->styles() [fst] : QString::null;
262} 262}
263 263
264/** 264/**
265 * This method will return the font size or 10 if no font size is available 265 * This method will return the font size or 10 if no font size is available
266 */ 266 */
267int OFontSelector::fontSize() const 267int OFontSelector::fontSize() const
268{ 268{
269 FontListItem *fli = (FontListItem *) d->m_font_family_list->item ( d->m_font_family_list->currentItem()); 269 FontListItem *fli = (FontListItem *) d->m_font_family_list->item ( d->m_font_family_list->currentItem());
270 int fsi = d->m_font_size_list->currentItem(); 270 int fsi = d->m_font_size_list->currentItem();
271 271
272 return ( fli && fsi >= 0 ) ? fli->sizes() [fsi] : 10; 272 return ( fli && fsi >= 0 ) ? fli->sizes() [fsi] : 10;
273} 273}
274 274
275/** 275/**
276 * returns the charset of the font or QString::null 276 * returns the charset of the font or QString::null
277 */ 277 */
278QString OFontSelector::fontCharSet() const 278QString OFontSelector::fontCharSet() const
279{ 279{
280 FontListItem *fli = (FontListItem *) d->m_font_family_list->item ( d->m_font_family_list->currentItem()); 280 FontListItem *fli = (FontListItem *) d->m_font_family_list->item ( d->m_font_family_list->currentItem());
281 281
282 return fli ? d->m_fdb. charSets ( fli->family()) [0] : QString::null; 282 return fli ? d->m_fdb. charSets ( fli->family()) [0] : QString::null;
283} 283}
284 284
285/** 285/**
286 * Overloaded member function see above 286 * Overloaded member function see above
287 * @see selectedFont 287 * @see selectedFont
288 */ 288 */
289bool OFontSelector::selectedFont ( QString &family, QString &style, int &size, QString &charset ) 289bool OFontSelector::selectedFont ( QString &family, QString &style, int &size, QString &charset )
290{ 290{
291 int ffa = d->m_font_family_list->currentItem(); 291 int ffa = d->m_font_family_list->currentItem();
292 int fst = d->m_font_style_list->currentItem(); 292 int fst = d->m_font_style_list->currentItem();
293 int fsi = d->m_font_size_list->currentItem(); 293 int fsi = d->m_font_size_list->currentItem();
294 294
295 FontListItem *fli = (FontListItem *) d->m_font_family_list->item ( ffa ); 295 FontListItem *fli = (FontListItem *) d->m_font_family_list->item ( ffa );
296 296
297 if ( fli ) 297 if ( fli )
298 { 298 {
299 family = fli->family(); 299 family = fli->family();
300 style = fst >= 0 ? fli->styles() [fst] : QString::null; 300 style = fst >= 0 ? fli->styles() [fst] : QString::null;
301 size = fsi >= 0 ? fli->sizes() [fsi] : 10; 301 size = fsi >= 0 ? fli->sizes() [fsi] : 10;
302 charset = d->m_fdb. charSets ( fli->family()) [0]; 302 charset = d->m_fdb. charSets ( fli->family()) [0];
303 303
304 return true; 304 return true;
305 } 305 }
306 else 306 else
307 return false; 307 return false;
308} 308}
309 309
310void OFontSelector::loadFonts ( QListBox *list ) 310void OFontSelector::loadFonts ( QListBox *list )
311{ 311{
312 QStringList f = d->m_fdb. families(); 312 QStringList f = d->m_fdb. families();
313 313
314 for ( QStringList::ConstIterator it = f. begin(); it != f. end(); ++it ) 314 for ( QStringList::ConstIterator it = f. begin(); it != f. end(); ++it )
315 { 315 {
316 QValueList <int> ps = d->m_fdb. pointSizes ( *it ); 316 QValueList <int> ps = d->m_fdb. pointSizes ( *it );
317 317
318 if ( d->m_pointbug ) 318 if ( d->m_pointbug )
319 { 319 {
320 for ( QValueList <int>::Iterator it = ps. begin(); it != ps. end(); it++ ) 320 for ( QValueList <int>::Iterator it = ps. begin(); it != ps. end(); it++ )
321 *it /= 10; 321 *it /= 10;
322 } 322 }
323 323
324 list->insertItem ( new FontListItem ( *it, d->m_fdb. styles ( *it ), ps )); 324 list->insertItem ( new FontListItem ( *it, d->m_fdb. styles ( *it ), ps ));
325 } 325 }
326} 326}
327 327
328void OFontSelector::fontFamilyClicked ( int index ) 328void OFontSelector::fontFamilyClicked ( int index )
329{ 329{
330 QString oldstyle = d->m_font_style_list->currentText(); 330 QString oldstyle = d->m_font_style_list->currentText();
331 QString oldsize = d->m_font_size_list->currentText(); 331 QString oldsize = d->m_font_size_list->currentText();
332 332
333 FontListItem *fli = (FontListItem *) d->m_font_family_list->item ( index ); 333 FontListItem *fli = (FontListItem *) d->m_font_family_list->item ( index );
334 334
335 d->m_font_style_list->clear(); 335 d->m_font_style_list->clear();
336 d->m_font_style_list->insertStringList ( fli->styles()); 336 d->m_font_style_list->insertStringList ( fli->styles());
337 d->m_font_style_list->setEnabled ( !fli->styles(). isEmpty()); 337 d->m_font_style_list->setEnabled ( !fli->styles(). isEmpty());
338 338
339 int i; 339 int i;
340 340
341 i = findItemCB ( d->m_font_style_list, oldstyle ); 341 i = findItemCB ( d->m_font_style_list, oldstyle );
diff --git a/libopie2/opieui/otabwidget.cpp b/libopie2/opieui/otabwidget.cpp
index ec6af9d..f47c90b 100644
--- a/libopie2/opieui/otabwidget.cpp
+++ b/libopie2/opieui/otabwidget.cpp
@@ -1,273 +1,273 @@
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 <opie2/otabwidget.h> 32#include <opie2/otabwidget.h>
33 33
34/* OPIE */ 34/* OPIE */
35#include <qpe/applnk.h> 35#include <qpe/applnk.h>
36#include <qpe/config.h> 36#include <qpe/config.h>
37#include <qpe/resource.h> 37#include <qpe/resource.h>
38#include <opie2/otabbar.h> 38#include <opie2/otabbar.h>
39 39
40/* QT */ 40/* QT */
41#include <qcombobox.h> 41#include <qcombobox.h>
42#include <qwidgetstack.h> 42#include <qwidgetstack.h>
43 43
44using namespace Opie; 44using namespace Opie;
45 45
46OTabWidget::OTabWidget( QWidget *parent, const char *name, TabStyle s, TabPosition p ) 46OTabWidget::OTabWidget( QWidget *parent, const char *name, TabStyle s, TabPosition p )
47 : QWidget( parent, name ) 47 : QWidget( parent, name )
48{ 48{
49 if ( s == Global ) 49 if ( s == Global )
50 { 50 {
51 Config config( "qpe" ); 51 Config config( "qpe" );
52 config.setGroup( "Appearance" ); 52 config.setGroup( "Appearance" );
53 s = ( TabStyle ) config.readNumEntry( "TabStyle", (int) IconTab ); 53 s = ( TabStyle ) config.readNumEntry( "TabStyle", (int) IconTab );
54 if ( s <= Global || s > IconList) 54 if ( s <= Global || s > IconList)
55 { 55 {
56 s = IconTab; 56 s = IconTab;
57 } 57 }
58 QString pos = config.readEntry( "TabPosition", "Top"); 58 QString pos = config.readEntry( "TabPosition", "Top");
59 if ( pos == "Bottom" ) 59 if ( pos == "Bottom" )
60 { 60 {
61 p = Bottom; 61 p = Bottom;
62 } 62 }
63 else 63 else
64 { 64 {
65 p = Top; 65 p = Top;
66 } 66 }
67 } 67 }
68 68
69 widgetStack = new QWidgetStack( this, "widgetstack" ); 69 widgetStack = new QWidgetStack( this, "widgetstack" );
70 widgetStack->setFrameStyle( QFrame::NoFrame ); 70 widgetStack->setFrameStyle( QFrame::NoFrame );
71 widgetStack->setLineWidth( style().defaultFrameWidth() ); 71 widgetStack->setLineWidth( style().defaultFrameWidth() );
72 72
73 tabBarStack = new QWidgetStack( this, "tabbarstack" ); 73 tabBarStack = new QWidgetStack( this, "tabbarstack" );
74 74
75 tabBar = new OTabBar( tabBarStack, "tabbar" ); 75 tabBar = new OTabBar( tabBarStack, "tabbar" );
76 tabBarStack->addWidget( tabBar, 0 ); 76 tabBarStack->addWidget( tabBar, 0 );
77 connect( tabBar, SIGNAL( selected( int ) ), this, SLOT( slotTabBarSelected( int ) ) ); 77 connect( tabBar, SIGNAL( selected(int) ), this, SLOT( slotTabBarSelected(int) ) );
78 78
79 tabList = new QComboBox( false, tabBarStack, "tablist" ); 79 tabList = new QComboBox( false, tabBarStack, "tablist" );
80 tabBarStack->addWidget( tabList, 1 ); 80 tabBarStack->addWidget( tabList, 1 );
81 connect( tabList, SIGNAL( activated( int ) ), this, SLOT( slotTabListSelected( int ) ) ); 81 connect( tabList, SIGNAL( activated(int) ), this, SLOT( slotTabListSelected(int) ) );
82 82
83 tabBarPosition = p; 83 tabBarPosition = p;
84 setTabStyle( s ); 84 setTabStyle( s );
85 setTabPosition( p ); 85 setTabPosition( p );
86 86
87 currTab= 0x0; 87 currTab= 0x0;
88} 88}
89 89
90OTabWidget::~OTabWidget() 90OTabWidget::~OTabWidget()
91{} 91{}
92 92
93void OTabWidget::addTab( QWidget *child, const QString &icon, const QString &label ) 93void OTabWidget::addTab( QWidget *child, const QString &icon, const QString &label )
94{ 94{
95 QPixmap iconset = loadSmooth( icon ); 95 QPixmap iconset = loadSmooth( icon );
96 96
97 QTab *tab = new QTab(); 97 QTab *tab = new QTab();
98 if ( tabBarStyle == IconTab ) 98 if ( tabBarStyle == IconTab )
99 { 99 {
100 tab->label = QString::null; 100 tab->label = QString::null;
101 } 101 }
102 else 102 else
103 { 103 {
104 tab->label = label; 104 tab->label = label;
105 } 105 }
106 if ( tabBarStyle == IconTab || tabBarStyle == IconList ) 106 if ( tabBarStyle == IconTab || tabBarStyle == IconList )
107 { 107 {
108 tab->iconset = new QIconSet( iconset ); 108 tab->iconset = new QIconSet( iconset );
109 } 109 }
110 int tabid = tabBar->addTab( tab ); 110 int tabid = tabBar->addTab( tab );
111 111
112 if ( tabBarStyle == IconTab || tabBarStyle == IconList ) 112 if ( tabBarStyle == IconTab || tabBarStyle == IconList )
113 { 113 {
114 tabList->insertItem( iconset, label, -1 ); 114 tabList->insertItem( iconset, label, -1 );
115 } 115 }
116 else 116 else
117 { 117 {
118 tabList->insertItem( label ); 118 tabList->insertItem( label );
119 } 119 }
120 120
121 widgetStack->addWidget( child, tabid ); 121 widgetStack->addWidget( child, tabid );
122 widgetStack->raiseWidget( child ); 122 widgetStack->raiseWidget( child );
123 widgetStack->setFrameStyle( QFrame::StyledPanel | QFrame::Raised ); 123 widgetStack->setFrameStyle( QFrame::StyledPanel | QFrame::Raised );
124 124
125 OTabInfo *tabinfo = new OTabInfo( tabid, child, icon, label ); 125 OTabInfo *tabinfo = new OTabInfo( tabid, child, icon, label );
126 tabs.append( tabinfo ); 126 tabs.append( tabinfo );
127 selectTab( tabinfo ); 127 selectTab( tabinfo );
128} 128}
129 129
130void OTabWidget::removePage( QWidget *childwidget ) 130void OTabWidget::removePage( QWidget *childwidget )
131{ 131{
132 if ( childwidget ) 132 if ( childwidget )
133 { 133 {
134 OTabInfo *tab = tabs.first(); 134 OTabInfo *tab = tabs.first();
135 while ( tab && tab->control() != childwidget ) 135 while ( tab && tab->control() != childwidget )
136 { 136 {
137 tab = tabs.next(); 137 tab = tabs.next();
138 } 138 }
139 if ( tab && tab->control() == childwidget ) 139 if ( tab && tab->control() == childwidget )
140 { 140 {
141 tabBar->setTabEnabled( tab->id(), FALSE ); 141 tabBar->setTabEnabled( tab->id(), FALSE );
142 tabBar->removeTab( tabBar->tab( tab->id() ) ); 142 tabBar->removeTab( tabBar->tab( tab->id() ) );
143 int i = 0; 143 int i = 0;
144 while ( i < tabList->count() && tabList->text( i ) != tab->label() ) 144 while ( i < tabList->count() && tabList->text( i ) != tab->label() )
145 { 145 {
146 i++; 146 i++;
147 } 147 }
148 if ( tabList->text( i ) == tab->label() ) 148 if ( tabList->text( i ) == tab->label() )
149 { 149 {
150 tabList->removeItem( i ); 150 tabList->removeItem( i );
151 } 151 }
152 widgetStack->removeWidget( childwidget ); 152 widgetStack->removeWidget( childwidget );
153 tabs.remove( tab ); 153 tabs.remove( tab );
154 delete tab; 154 delete tab;
155 currTab = tabs.current(); 155 currTab = tabs.current();
156 if ( !currTab ) 156 if ( !currTab )
157 { 157 {
158 widgetStack->setFrameStyle( QFrame::NoFrame ); 158 widgetStack->setFrameStyle( QFrame::NoFrame );
159 } 159 }
160 160
161 setUpLayout(); 161 setUpLayout();
162 } 162 }
163 } 163 }
164} 164}
165 165
166void OTabWidget::changeTab( QWidget *widget, const QString &iconset, const QString &label) 166void OTabWidget::changeTab( QWidget *widget, const QString &iconset, const QString &label)
167{ 167{
168 OTabInfo *currtab = tabs.first(); 168 OTabInfo *currtab = tabs.first();
169 while ( currtab && currtab->control() != widget ) 169 while ( currtab && currtab->control() != widget )
170 { 170 {
171 currtab = tabs.next(); 171 currtab = tabs.next();
172 } 172 }
173 if ( currtab && currtab->control() == widget ) 173 if ( currtab && currtab->control() == widget )
174 { 174 {
175 QTab *tab = tabBar->tab( currtab->id() ); 175 QTab *tab = tabBar->tab( currtab->id() );
176 QPixmap icon( loadSmooth( iconset ) ); 176 QPixmap icon( loadSmooth( iconset ) );
177 tab->setText( label ); 177 tab->setText( label );
178 if ( tabBarStyle == IconTab ) 178 if ( tabBarStyle == IconTab )
179 tab->setIconSet( icon ); 179 tab->setIconSet( icon );
180 int i = 0; 180 int i = 0;
181 while ( i < tabList->count() && tabList->text( i ) != currtab->label() ) 181 while ( i < tabList->count() && tabList->text( i ) != currtab->label() )
182 { 182 {
183 i++; 183 i++;
184 } 184 }
185 if ( i < tabList->count() && tabList->text( i ) == currtab->label() ) 185 if ( i < tabList->count() && tabList->text( i ) == currtab->label() )
186 { 186 {
187 if ( tabBarStyle == IconTab || tabBarStyle == IconList ) 187 if ( tabBarStyle == IconTab || tabBarStyle == IconList )
188 { 188 {
189 tabList->changeItem( icon, label, i ); 189 tabList->changeItem( icon, label, i );
190 } 190 }
191 else 191 else
192 { 192 {
193 tabList->changeItem( label, i ); 193 tabList->changeItem( label, i );
194 } 194 }
195 } 195 }
196 currtab->setLabel( label ); 196 currtab->setLabel( label );
197 currtab->setIcon( iconset ); 197 currtab->setIcon( iconset );
198 } 198 }
199 setUpLayout(); 199 setUpLayout();
200} 200}
201 201
202void OTabWidget::setCurrentTab( QWidget *childwidget ) 202void OTabWidget::setCurrentTab( QWidget *childwidget )
203{ 203{
204 OTabInfo *currtab = tabs.first(); 204 OTabInfo *currtab = tabs.first();
205 while ( currtab && currtab->control() != childwidget ) 205 while ( currtab && currtab->control() != childwidget )
206 { 206 {
207 currtab = tabs.next(); 207 currtab = tabs.next();
208 } 208 }
209 if ( currtab && currtab->control() == childwidget ) 209 if ( currtab && currtab->control() == childwidget )
210 { 210 {
211 selectTab( currtab ); 211 selectTab( currtab );
212 } 212 }
213} 213}
214 214
215void OTabWidget::setCurrentTab( const QString &tabname ) 215void OTabWidget::setCurrentTab( const QString &tabname )
216{ 216{
217 OTabInfo *newtab = tabs.first(); 217 OTabInfo *newtab = tabs.first();
218 while ( newtab && newtab->label() != tabname ) 218 while ( newtab && newtab->label() != tabname )
219 { 219 {
220 newtab = tabs.next(); 220 newtab = tabs.next();
221 } 221 }
222 if ( newtab && newtab->label() == tabname ) 222 if ( newtab && newtab->label() == tabname )
223 { 223 {
224 selectTab( newtab ); 224 selectTab( newtab );
225 } 225 }
226} 226}
227 227
228void OTabWidget::setCurrentTab(int tabindex) 228void OTabWidget::setCurrentTab(int tabindex)
229{ 229{
230 OTabInfo *newtab = tabs.first(); 230 OTabInfo *newtab = tabs.first();
231 while ( newtab && newtab->id() != tabindex ) 231 while ( newtab && newtab->id() != tabindex )
232 { 232 {
233 newtab = tabs.next(); 233 newtab = tabs.next();
234 } 234 }
235 if ( newtab && newtab->id() == tabindex ) 235 if ( newtab && newtab->id() == tabindex )
236 { 236 {
237 selectTab( newtab ); 237 selectTab( newtab );
238 } 238 }
239} 239}
240 240
241 241
242OTabWidget::TabStyle OTabWidget::tabStyle() const 242OTabWidget::TabStyle OTabWidget::tabStyle() const
243{ 243{
244 return tabBarStyle; 244 return tabBarStyle;
245} 245}
246 246
247void OTabWidget::setTabStyle( TabStyle s ) 247void OTabWidget::setTabStyle( TabStyle s )
248{ 248{
249 tabBarStyle = s; 249 tabBarStyle = s;
250 if ( tabBarStyle == TextTab || tabBarStyle == IconTab ) 250 if ( tabBarStyle == TextTab || tabBarStyle == IconTab )
251 { 251 {
252 QTab *currtab; 252 QTab *currtab;
253 for ( OTabInfo *tabinfo = tabs.first(); tabinfo; tabinfo = tabs.next() ) 253 for ( OTabInfo *tabinfo = tabs.first(); tabinfo; tabinfo = tabs.next() )
254 { 254 {
255 currtab = tabBar->tab( tabinfo->id() ); 255 currtab = tabBar->tab( tabinfo->id() );
256 if ( tabBarStyle == IconTab ) 256 if ( tabBarStyle == IconTab )
257 { 257 {
258 currtab->iconset = new QIconSet( loadSmooth( tabinfo->icon() ) ); 258 currtab->iconset = new QIconSet( loadSmooth( tabinfo->icon() ) );
259 if ( tabinfo == currTab ) 259 if ( tabinfo == currTab )
260 currtab->setText( tabinfo->label() ); 260 currtab->setText( tabinfo->label() );
261 else 261 else
262 currtab->setText( QString::null ); 262 currtab->setText( QString::null );
263 } 263 }
264 else 264 else
265 { 265 {
266 currtab->iconset = 0x0; 266 currtab->iconset = 0x0;
267 currtab->setText( tabinfo->label() ); 267 currtab->setText( tabinfo->label() );
268 } 268 }
269 } 269 }
270 tabBarStack->raiseWidget( tabBar ); 270 tabBarStack->raiseWidget( tabBar );
271 } 271 }
272 else if ( tabBarStyle == TextList || tabBarStyle == IconList ) 272 else if ( tabBarStyle == TextList || tabBarStyle == IconList )
273 { 273 {
diff --git a/libopie2/opieui/otimepicker.cpp b/libopie2/opieui/otimepicker.cpp
index d4712a4..66f9ce0 100644
--- a/libopie2/opieui/otimepicker.cpp
+++ b/libopie2/opieui/otimepicker.cpp
@@ -32,261 +32,261 @@
32#include <qlineedit.h> 32#include <qlineedit.h>
33 33
34/* OPIE */ 34/* OPIE */
35#include <opie2/otimepicker.h> 35#include <opie2/otimepicker.h>
36 36
37using namespace Opie; 37using namespace Opie;
38 38
39/** 39/**
40 * Constructs the widget 40 * Constructs the widget
41 * @param parent The parent of the OTimePicker 41 * @param parent The parent of the OTimePicker
42 * @param name The name of the object 42 * @param name The name of the object
43 * @param fl Window Flags 43 * @param fl Window Flags
44 */ 44 */
45OTimePicker::OTimePicker(QWidget* parent, const char* name, Qt::WFlags fl) 45OTimePicker::OTimePicker(QWidget* parent, const char* name, Qt::WFlags fl)
46 :QWidget(parent,name,fl) 46 :QWidget(parent,name,fl)
47{ 47{
48 QVBoxLayout *vbox=new QVBoxLayout(this); 48 QVBoxLayout *vbox=new QVBoxLayout(this);
49 49
50 OClickableLabel *r; 50 OClickableLabel *r;
51 QString s; 51 QString s;
52 52
53 // Hour Row 53 // Hour Row
54 QWidget *row=new QWidget(this); 54 QWidget *row=new QWidget(this);
55 QHBoxLayout *l=new QHBoxLayout(row); 55 QHBoxLayout *l=new QHBoxLayout(row);
56 vbox->addWidget(row); 56 vbox->addWidget(row);
57 57
58 for (int i=0; i<24; i++) 58 for (int i=0; i<24; i++)
59 { 59 {
60 r=new OClickableLabel(row); 60 r=new OClickableLabel(row);
61 hourLst.append(r); 61 hourLst.append(r);
62 s.sprintf("%.2d",i); 62 s.sprintf("%.2d",i);
63 r->setText(s); 63 r->setText(s);
64 r->setToggleButton(true); 64 r->setToggleButton(true);
65 r->setAlignment(AlignHCenter | AlignVCenter); 65 r->setAlignment(AlignHCenter | AlignVCenter);
66 l->addWidget(r); 66 l->addWidget(r);
67 connect(r, SIGNAL(toggled(bool)), 67 connect(r, SIGNAL(toggled(bool)),
68 this, SLOT(slotHour(bool))); 68 this, SLOT(slotHour(bool)));
69 69
70 if (i==11) 70 if (i==11)
71 { // Second row 71 { // Second row
72 row=new QWidget(this); 72 row=new QWidget(this);
73 l=new QHBoxLayout(row); 73 l=new QHBoxLayout(row);
74 vbox->addWidget(row); 74 vbox->addWidget(row);
75 } 75 }
76 } 76 }
77 77
78 // Minute Row 78 // Minute Row
79 row=new QWidget(this); 79 row=new QWidget(this);
80 l=new QHBoxLayout(row); 80 l=new QHBoxLayout(row);
81 vbox->addWidget(row); 81 vbox->addWidget(row);
82 82
83 for (int i=0; i<60; i+=5) 83 for (int i=0; i<60; i+=5)
84 { 84 {
85 r=new OClickableLabel(row); 85 r=new OClickableLabel(row);
86 minuteLst.append(r); 86 minuteLst.append(r);
87 s.sprintf("%.2d",i); 87 s.sprintf("%.2d",i);
88 r->setText(s); 88 r->setText(s);
89 r->setToggleButton(true); 89 r->setToggleButton(true);
90 r->setAlignment(AlignHCenter | AlignVCenter); 90 r->setAlignment(AlignHCenter | AlignVCenter);
91 l->addWidget(r); 91 l->addWidget(r);
92 connect(r, SIGNAL(toggled(bool)), 92 connect(r, SIGNAL(toggled(bool)),
93 this, SLOT(slotMinute(bool))); 93 this, SLOT(slotMinute(bool)));
94 } 94 }
95} 95}
96 96
97/** 97/**
98 * This method return the current time 98 * This method return the current time
99 * @return the time 99 * @return the time
100 */ 100 */
101QTime OTimePicker::time()const 101QTime OTimePicker::time()const
102{ 102{
103 return tm; 103 return tm;
104} 104}
105 105
106void OTimePicker::slotHour(bool b) 106void OTimePicker::slotHour(bool b)
107{ 107{
108 108
109 OClickableLabel *r = (OClickableLabel *) sender(); 109 OClickableLabel *r = (OClickableLabel *) sender();
110 110
111 if (b) 111 if (b)
112 { 112 {
113 QValueListIterator<OClickableLabel *> it; 113 QValueListIterator<OClickableLabel *> it;
114 for (it=hourLst.begin(); it!=hourLst.end(); it++) 114 for (it=hourLst.begin(); it!=hourLst.end(); it++)
115 { 115 {
116 if (*it != r) (*it)->setOn(false); 116 if (*it != r) (*it)->setOn(false);
117 else tm.setHMS((*it)->text().toInt(), tm.minute(), 0); 117 else tm.setHMS((*it)->text().toInt(), tm.minute(), 0);
118 } 118 }
119 emit timeChanged(tm); 119 emit timeChanged(tm);
120 } 120 }
121 else 121 else
122 { 122 {
123 r->setOn(true); 123 r->setOn(true);
124 } 124 }
125 125
126} 126}
127 127
128void OTimePicker::slotMinute(bool b) 128void OTimePicker::slotMinute(bool b)
129{ 129{
130 130
131 OClickableLabel *r = (OClickableLabel *) sender(); 131 OClickableLabel *r = (OClickableLabel *) sender();
132 132
133 if (b) 133 if (b)
134 { 134 {
135 QValueListIterator<OClickableLabel *> it; 135 QValueListIterator<OClickableLabel *> it;
136 for (it=minuteLst.begin(); it!=minuteLst.end(); it++) 136 for (it=minuteLst.begin(); it!=minuteLst.end(); it++)
137 { 137 {
138 if (*it != r) (*it)->setOn(false); 138 if (*it != r) (*it)->setOn(false);
139 else tm.setHMS(tm.hour(),(*it)->text().toInt(), 0); 139 else tm.setHMS(tm.hour(),(*it)->text().toInt(), 0);
140 } 140 }
141 emit timeChanged(tm); 141 emit timeChanged(tm);
142 } 142 }
143 else 143 else
144 { 144 {
145 r->setOn(true); 145 r->setOn(true);
146 } 146 }
147 147
148} 148}
149 149
150/** 150/**
151 * Method to set the time. No signal gets emitted during this method call 151 * Method to set the time. No signal gets emitted during this method call
152 * Minutes must be within 5 minutes step starting at 0 ( 0,5,10,15,20... ) 152 * Minutes must be within 5 minutes step starting at 0 ( 0,5,10,15,20... )
153 * @param t The time to be set 153 * @param t The time to be set
154 */ 154 */
155void OTimePicker::setTime( const QTime& t) 155void OTimePicker::setTime( const QTime& t)
156{ 156{
157 setTime( t.hour(), t.minute() ); 157 setTime( t.hour(), t.minute() );
158} 158}
159 159
160/** 160/**
161 * Method to set the time. No signal gets emitted during this method call 161 * Method to set the time. No signal gets emitted during this method call
162 * @param h The hour 162 * @param h The hour
163 * @param m The minute. Minutes need to set by 5 minute steps 163 * @param m The minute. Minutes need to set by 5 minute steps
164 */ 164 */
165void OTimePicker::setTime( int h, int m ) 165void OTimePicker::setTime( int h, int m )
166{ 166{
167 setHour(h); 167 setHour(h);
168 setMinute(m); 168 setMinute(m);
169} 169}
170 170
171/* 171/*
172 * FIXME round minutes to the 5 minute arrangement -zecke 172 * FIXME round minutes to the 5 minute arrangement -zecke
173 */ 173 */
174/** 174/**
175 * Method to set the minutes 175 * Method to set the minutes
176 * @param m minutes 176 * @param m minutes
177 */ 177 */
178void OTimePicker::setMinute(int m) 178void OTimePicker::setMinute(int m)
179{ 179{
180 180
181 QString minute; 181 QString minute;
182 minute.sprintf("%.2d",m); 182 minute.sprintf("%.2d",m);
183 183
184 QValueListIterator<OClickableLabel *> it; 184 QValueListIterator<OClickableLabel *> it;
185 for (it=minuteLst.begin(); it!=minuteLst.end(); it++) 185 for (it=minuteLst.begin(); it!=minuteLst.end(); it++)
186 { 186 {
187 if ((*it)->text() == minute) (*it)->setOn(true); 187 if ((*it)->text() == minute) (*it)->setOn(true);
188 else (*it)->setOn(false); 188 else (*it)->setOn(false);
189 } 189 }
190 190
191 tm.setHMS(tm.hour(),m,0); 191 tm.setHMS(tm.hour(),m,0);
192} 192}
193 193
194/** 194/**
195 * Method to set the hour 195 * Method to set the hour
196 */ 196 */
197void OTimePicker::setHour(int h) 197void OTimePicker::setHour(int h)
198{ 198{
199 199
200 QString hour; 200 QString hour;
201 hour.sprintf("%.2d",h); 201 hour.sprintf("%.2d",h);
202 202
203 QValueListIterator<OClickableLabel *> it; 203 QValueListIterator<OClickableLabel *> it;
204 for (it=hourLst.begin(); it!=hourLst.end(); it++) 204 for (it=hourLst.begin(); it!=hourLst.end(); it++)
205 { 205 {
206 if ((*it)->text() == hour) (*it)->setOn(true); 206 if ((*it)->text() == hour) (*it)->setOn(true);
207 else (*it)->setOn(false); 207 else (*it)->setOn(false);
208 } 208 }
209 tm.setHMS(h,tm.minute(),0); 209 tm.setHMS(h,tm.minute(),0);
210} 210}
211 211
212 212
213/** 213/**
214 * This is a modal Dialog. 214 * This is a modal Dialog.
215 * 215 *
216 * @param parent The parent widget 216 * @param parent The parent widget
217 * @param name The name of the object 217 * @param name The name of the object
218 * @param fl Possible window flags 218 * @param fl Possible window flags
219 */ 219 */
220OTimePickerDialog::OTimePickerDialog ( QWidget* parent, const char* name, WFlags fl ) 220OTimePickerDialog::OTimePickerDialog ( QWidget* parent, const char* name, WFlags fl )
221 : OTimePickerDialogBase (parent , name, true , fl) 221 : OTimePickerDialogBase (parent , name, true , fl)
222{ 222{
223 223
224 connect ( m_timePicker, SIGNAL( timeChanged( const QTime& ) ), 224 connect ( m_timePicker, SIGNAL( timeChanged(const QTime&) ),
225 this, SLOT( setTime ( const QTime& ) ) ); 225 this, SLOT( setTime(const QTime&) ) );
226 connect ( minuteField, SIGNAL( textChanged ( const QString& ) ), 226 connect ( minuteField, SIGNAL( textChanged(const QString&) ),
227 this, SLOT ( setMinute ( const QString& ) ) ); 227 this, SLOT ( setMinute(const QString&) ) );
228 connect ( hourField, SIGNAL( textChanged ( const QString& ) ), 228 connect ( hourField, SIGNAL( textChanged(const QString&) ),
229 this, SLOT ( setHour ( const QString& ) ) ); 229 this, SLOT ( setHour(const QString&) ) );
230 230
231} 231}
232 232
233/** 233/**
234 * @return the time 234 * @return the time
235 */ 235 */
236QTime OTimePickerDialog::time()const 236QTime OTimePickerDialog::time()const
237{ 237{
238 return m_time; 238 return m_time;
239} 239}
240 240
241/** 241/**
242 * Set the time to time 242 * Set the time to time
243 * @param time The time to be set 243 * @param time The time to be set
244 */ 244 */
245void OTimePickerDialog::setTime( const QTime& time ) 245void OTimePickerDialog::setTime( const QTime& time )
246{ 246{
247 m_time = time; 247 m_time = time;
248 248
249 m_timePicker->setHour ( time.hour() ); 249 m_timePicker->setHour ( time.hour() );
250 m_timePicker->setMinute( time.minute() ); 250 m_timePicker->setMinute( time.minute() );
251 251
252 // Set Textfields 252 // Set Textfields
253 if ( time.hour() < 10 ) 253 if ( time.hour() < 10 )
254 hourField->setText( "0" + QString::number( time.hour() ) ); 254 hourField->setText( "0" + QString::number( time.hour() ) );
255 else 255 else
256 hourField->setText( QString::number( time.hour() ) ); 256 hourField->setText( QString::number( time.hour() ) );
257 257
258 if ( time.minute() < 10 ) 258 if ( time.minute() < 10 )
259 minuteField->setText( "0" + QString::number( time.minute() ) ); 259 minuteField->setText( "0" + QString::number( time.minute() ) );
260 else 260 else
261 minuteField->setText( QString::number( time.minute() ) ); 261 minuteField->setText( QString::number( time.minute() ) );
262 262
263} 263}
264 264
265/** 265/**
266 * This method takes the current minute and tries to set hour 266 * This method takes the current minute and tries to set hour
267 * to hour. This succeeds if the resulting date is valid 267 * to hour. This succeeds if the resulting date is valid
268 * @param hour The hour as a string 268 * @param hour The hour as a string
269 */ 269 */
270void OTimePickerDialog::setHour ( const QString& hour ) 270void OTimePickerDialog::setHour ( const QString& hour )
271{ 271{
272 if ( QTime::isValid ( hour.toInt(), m_time.minute() , 00 ) ) 272 if ( QTime::isValid ( hour.toInt(), m_time.minute() , 00 ) )
273 { 273 {
274 m_time.setHMS ( hour.toInt(), m_time.minute() , 00 ); 274 m_time.setHMS ( hour.toInt(), m_time.minute() , 00 );
275 setTime ( m_time ); 275 setTime ( m_time );
276 } 276 }
277 277
278} 278}
279 279
280/** 280/**
281 * Method to set a new minute. It tries to convert the string to int and 281 * Method to set a new minute. It tries to convert the string to int and
282 * if the resulting date is valid a new date is set. 282 * if the resulting date is valid a new date is set.
283 * @see setHour 283 * @see setHour
284 */ 284 */
285void OTimePickerDialog::setMinute ( const QString& minute ) 285void OTimePickerDialog::setMinute ( const QString& minute )
286{ 286{
287 if ( QTime::isValid ( m_time.hour(), minute.toInt(), 00 ) ) 287 if ( QTime::isValid ( m_time.hour(), minute.toInt(), 00 ) )
288 { 288 {
289 m_time.setHMS ( m_time.hour(), minute.toInt(), 00 ); 289 m_time.setHMS ( m_time.hour(), minute.toInt(), 00 );
290 setTime ( m_time ); 290 setTime ( m_time );
291 } 291 }
292} 292}
diff --git a/libopie2/opieui/oversatileview.cpp b/libopie2/opieui/oversatileview.cpp
index 8839456..78154b7 100644
--- a/libopie2/opieui/oversatileview.cpp
+++ b/libopie2/opieui/oversatileview.cpp
@@ -1,410 +1,410 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3 3
4 =. (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> 4 =. (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
5 .=l. 5 .=l.
6           .>+-= 6           .>+-=
7 _;:,     .>    :=|. This program is free software; you can 7 _;:,     .>    :=|. This program is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under 8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
10.="- .-=="i,     .._ License as published by the Free Software 10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License, 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version. 12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_. 13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This program is distributed in the hope that 14    .i_,=:_.      -<s. This program is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of 16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more 19..}^=.=       =       ; Library General Public License for more
20++=   -.     .`     .: details. 20++=   -.     .`     .: details.
21 :     =  ...= . :.=- 21 :     =  ...= . :.=-
22 -.   .:....=;==+<; You should have received a copy of the GNU 22 -.   .:....=;==+<; You should have received a copy of the GNU
23  -_. . .   )=.  = Library General Public License along with 23  -_. . .   )=.  = Library General Public License along with
24    --        :-=` this library; see the file COPYING.LIB. 24    --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28 28
29*/ 29*/
30 30
31/* OPIE */ 31/* OPIE */
32 32
33#include <opie2/odebug.h> 33#include <opie2/odebug.h>
34#include <opie2/oversatileview.h> 34#include <opie2/oversatileview.h>
35#include <opie2/oversatileviewitem.h> 35#include <opie2/oversatileviewitem.h>
36#include <opie2/olistview.h> 36#include <opie2/olistview.h>
37 37
38/* QT */ 38/* QT */
39 39
40#include <qaction.h> 40#include <qaction.h>
41#include <qpopupmenu.h> 41#include <qpopupmenu.h>
42 42
43/* XPM */ 43/* XPM */
44static const char * view_icon_xpm[] = { 44static const char * view_icon_xpm[] = {
45"16 16 16 1", 45"16 16 16 1",
46 " c None", 46 " c None",
47 ".c #87BD88", 47 ".c #87BD88",
48 "+c #8BBE8B", 48 "+c #8BBE8B",
49 "@c #81BA81", 49 "@c #81BA81",
50 "#c #6DAF6D", 50 "#c #6DAF6D",
51 "$c #87BD87", 51 "$c #87BD87",
52 "%c #FCFDFC", 52 "%c #FCFDFC",
53 "&c #AED0AE", 53 "&c #AED0AE",
54 "*c #4E9C4C", 54 "*c #4E9C4C",
55 "=c #91BD91", 55 "=c #91BD91",
56 "-c #72B172", 56 "-c #72B172",
57 ";c #448643", 57 ";c #448643",
58 ">c #519F50", 58 ">c #519F50",
59 ",c #499247", 59 ",c #499247",
60 "'c #356A35", 60 "'c #356A35",
61 ")c #686868", 61 ")c #686868",
62" ", 62" ",
63" .+@# .+@# ", 63" .+@# .+@# ",
64" $%&* $%&* ", 64" $%&* $%&* ",
65" @=-; @=-; ", 65" @=-; @=-; ",
66" #>,' #>,' ", 66" #>,' #>,' ",
67" ", 67" ",
68" )))))) )))))) ", 68" )))))) )))))) ",
69" ", 69" ",
70" ", 70" ",
71" .+@# .+@# ", 71" .+@# .+@# ",
72" $%&* $%&* ", 72" $%&* $%&* ",
73" @=-; @=-; ", 73" @=-; @=-; ",
74" #>,' #>,' ", 74" #>,' #>,' ",
75" ", 75" ",
76" )))))) )))))) ", 76" )))))) )))))) ",
77" "}; 77" "};
78 78
79/* XPM */ 79/* XPM */
80static const char * view_tree_xpm[] = { 80static const char * view_tree_xpm[] = {
81"16 16 17 1", 81"16 16 17 1",
82 " c None", 82 " c None",
83 ".c #3A3A3A", 83 ".c #3A3A3A",
84 "+c #87BD88", 84 "+c #87BD88",
85 "@c #8BBE8B", 85 "@c #8BBE8B",
86 "#c #81BA81", 86 "#c #81BA81",
87 "$c #6DAF6D", 87 "$c #6DAF6D",
88 "%c #87BD87", 88 "%c #87BD87",
89 "&c #FCFDFC", 89 "&c #FCFDFC",
90 "*c #AED0AE", 90 "*c #AED0AE",
91 "=c #4E9C4C", 91 "=c #4E9C4C",
92 "-c #91BD91", 92 "-c #91BD91",
93 ";c #72B172", 93 ";c #72B172",
94 ">c #448643", 94 ">c #448643",
95 ",c #686868", 95 ",c #686868",
96 "'c #519F50", 96 "'c #519F50",
97 ")c #499247", 97 ")c #499247",
98 "!c #356A35", 98 "!c #356A35",
99" . ", 99" . ",
100" . ", 100" . ",
101" . +@#$ ", 101" . +@#$ ",
102" . %&*= ", 102" . %&*= ",
103" .. #-;> ,, ,,,", 103" .. #-;> ,, ,,,",
104" . $')! ", 104" . $')! ",
105" . ", 105" . ",
106" . ", 106" . ",
107" . ", 107" . ",
108" . +@#$ ", 108" . +@#$ ",
109" . %&*= ", 109" . %&*= ",
110" .. #-;> ,, ,,,", 110" .. #-;> ,, ,,,",
111" $')! ", 111" $')! ",
112" ", 112" ",
113" ", 113" ",
114" "}; 114" "};
115 115
116OVersatileView::OVersatileView( QWidget* parent, const char* name, int mode ) 116OVersatileView::OVersatileView( QWidget* parent, const char* name, int mode )
117 :QWidgetStack( parent, name ), 117 :QWidgetStack( parent, name ),
118 _viewmode( mode ), _warningpolicy( None ), 118 _viewmode( mode ), _warningpolicy( None ),
119 _treeleaf(), _treeopened(), _treeclosed(), 119 _treeleaf(), _treeopened(), _treeclosed(),
120 _iconleaf(), _iconopened(), _iconclosed() 120 _iconleaf(), _iconopened(), _iconclosed()
121{ 121{
122 // 122 //
123 // Create child widgets and set some reasonable default styles 123 // Create child widgets and set some reasonable default styles
124 // 124 //
125 125
126 _listview = new OListView( this, "oversatileview embedded listview" ); 126 _listview = new OListView( this, "oversatileview embedded listview" );
127 _iconview = new QIconView( this, "oversatileview embedded iconview" ); 127 _iconview = new QIconView( this, "oversatileview embedded iconview" );
128 128
129 _listview->setAllColumnsShowFocus( true ); 129 _listview->setAllColumnsShowFocus( true );
130 _listview->setRootIsDecorated( true ); 130 _listview->setRootIsDecorated( true );
131 _listview->setShowSortIndicator( true ); 131 _listview->setShowSortIndicator( true );
132 _iconview->setGridX( 90 ); 132 _iconview->setGridX( 90 );
133 _iconview->setGridY( 42 ); 133 _iconview->setGridY( 42 );
134 _iconview->setAutoArrange( true ); 134 _iconview->setAutoArrange( true );
135 135
136 #ifdef QWS // TODO: Let this depend on current geometry (rotation) 136 #ifdef QWS // TODO: Let this depend on current geometry (rotation)
137 _iconview->setArrangement( QIconView::TopToBottom ); 137 _iconview->setArrangement( QIconView::TopToBottom );
138 #else 138 #else
139 _iconview->setArrangement( QIconView::LeftToRight ); 139 _iconview->setArrangement( QIconView::LeftToRight );
140 #endif 140 #endif
141 141
142 _iconview->setResizeMode( QIconView::Adjust ); 142 _iconview->setResizeMode( QIconView::Adjust );
143 143
144 // qt-embedded: map stylus right on hold to right button press 144 // qt-embedded: map stylus right on hold to right button press
145 145
146 #ifdef QWS 146 #ifdef QWS
147 ( (QPEApplication*) qApp)->setStylusOperation( _iconview->viewport(), QPEApplication::RightOnHold ); 147 ( (QPEApplication*) qApp)->setStylusOperation( _iconview->viewport(), QPEApplication::RightOnHold );
148 ( (QPEApplication*) qApp)->setStylusOperation( _listview->viewport(), QPEApplication::RightOnHold ); 148 ( (QPEApplication*) qApp)->setStylusOperation( _listview->viewport(), QPEApplication::RightOnHold );
149 #endif 149 #endif
150 150
151 setViewMode( mode ); // TODO: Read last style from config 151 setViewMode( mode ); // TODO: Read last style from config
152 // setSynchronization( true ); // TODO: Implement this 152 // setSynchronization( true ); // TODO: Implement this
153 153
154 // create context menu allowing to switch between the views 154 // create context menu allowing to switch between the views
155 155
156 _contextmenu = new QPopupMenu( 0, "oversatileview contextmenu" ); 156 _contextmenu = new QPopupMenu( 0, "oversatileview contextmenu" );
157 _contextmenu->setCaption( "Style" ); 157 _contextmenu->setCaption( "Style" );
158 _contextmenu->setCheckable( true ); 158 _contextmenu->setCheckable( true );
159 QActionGroup* ag = new QActionGroup( _contextmenu, "style option group" ); 159 QActionGroup* ag = new QActionGroup( _contextmenu, "style option group" );
160 QAction* a1 = new QAction( "View Items in Icon Style", QIconSet( QPixmap( view_icon_xpm ) ), 160 QAction* a1 = new QAction( "View Items in Icon Style", QIconSet( QPixmap( view_icon_xpm ) ),
161 "View Icons", 0, ag, "viewicon action", true ); 161 "View Icons", 0, ag, "viewicon action", true );
162 QAction* a2 = new QAction( "View Items in Tree Style", QIconSet( QPixmap( view_tree_xpm ) ), 162 QAction* a2 = new QAction( "View Items in Tree Style", QIconSet( QPixmap( view_tree_xpm ) ),
163 "View Tree", 0, ag, "viewtree action", true ); 163 "View Tree", 0, ag, "viewtree action", true );
164 ag->addTo( _contextmenu ); 164 ag->addTo( _contextmenu );
165 if ( mode == Icons ) 165 if ( mode == Icons )
166 a1->setOn( true ); 166 a1->setOn( true );
167 else if ( mode == Tree ) 167 else if ( mode == Tree )
168 a2->setOn( true ); 168 a2->setOn( true );
169 connect( a1, SIGNAL( activated() ), this, SLOT( setIconViewMode() ) ); 169 connect( a1, SIGNAL( activated() ), this, SLOT( setIconViewMode() ) );
170 connect( a2, SIGNAL( activated() ), this, SLOT( setTreeViewMode() ) ); 170 connect( a2, SIGNAL( activated() ), this, SLOT( setTreeViewMode() ) );
171 171
172 #if (QT_VERSION >= 0x030000) 172 #if (QT_VERSION >= 0x030000)
173 connect( _listview, SIGNAL( contextMenuRequested( QListViewItem*, const QPoint&, int ) ), this, SLOT( contextMenuRequested( QListViewItem*, const QPoint&, int ) ) ); 173 connect( _listview, SIGNAL( contextMenuRequested(QListViewItem*,const QPoint&,int) ), this, SLOT( contextMenuRequested(QListViewItem*,const QPoint&,int) ) );
174 connect( _iconview, SIGNAL( contextMenuRequested( QIconViewItem*, const QPoint& ) ), this, SLOT( contextMenuRequested( QIconViewItem*, const QPoint& ) ) ); 174 connect( _iconview, SIGNAL( contextMenuRequested(QIconViewItem*,const QPoint&) ), this, SLOT( contextMenuRequested(QIconViewItem*,const QPoint&) ) );
175 #else 175 #else
176 connect( _listview, SIGNAL( rightButtonPressed( QListViewItem*, const QPoint&, int ) ), this, SLOT( contextMenuRequested( QListViewItem*, const QPoint&, int ) ) ); 176 connect( _listview, SIGNAL( rightButtonPressed(QListViewItem*,const QPoint&,int) ), this, SLOT( contextMenuRequested(QListViewItem*,const QPoint&,int) ) );
177 connect( _iconview, SIGNAL( rightButtonPressed( QIconViewItem*, const QPoint& ) ), this, SLOT( contextMenuRequested( QIconViewItem*, const QPoint& ) ) ); 177 connect( _iconview, SIGNAL( rightButtonPressed(QIconViewItem*,const QPoint&) ), this, SLOT( contextMenuRequested(QIconViewItem*,const QPoint&) ) );
178 #endif 178 #endif
179 179
180 // 180 //
181 // signal forwarders 181 // signal forwarders
182 // 182 //
183 // unfortunately we can't short-circuit all the QListView and QIconView signals 183 // unfortunately we can't short-circuit all the QListView and QIconView signals
184 // to OVersatileView signals, because the signal/slot mechanism doesn't allow 184 // to OVersatileView signals, because the signal/slot mechanism doesn't allow
185 // type-conversion :-( 185 // type-conversion :-(
186 186
187 // common signals for listview 187 // common signals for listview
188 188
189 connect( _listview, SIGNAL( selectionChanged() ), this, SIGNAL( selectionChanged() ) ); 189 connect( _listview, SIGNAL( selectionChanged() ), this, SIGNAL( selectionChanged() ) );
190 connect( _listview, SIGNAL( selectionChanged( QListViewItem * ) ), this, SLOT( selectionChanged( QListViewItem * ) ) ); 190 connect( _listview, SIGNAL( selectionChanged(QListViewItem*) ), this, SLOT( selectionChanged(QListViewItem*) ) );
191 connect( _listview, SIGNAL( currentChanged( QListViewItem * ) ), this, SLOT( currentChanged( QListViewItem * ) ) ); 191 connect( _listview, SIGNAL( currentChanged(QListViewItem*) ), this, SLOT( currentChanged(QListViewItem*) ) );
192 connect( _listview, SIGNAL( clicked( QListViewItem * ) ), this, SLOT( clicked( QListViewItem * ) ) ); 192 connect( _listview, SIGNAL( clicked(QListViewItem*) ), this, SLOT( clicked(QListViewItem*) ) );
193 connect( _listview, SIGNAL( pressed( QListViewItem * ) ), this, SLOT( pressed( QListViewItem * ) ) ); 193 connect( _listview, SIGNAL( pressed(QListViewItem*) ), this, SLOT( pressed(QListViewItem*) ) );
194 194
195 connect( _listview, SIGNAL( doubleClicked( QListViewItem * ) ), this, SLOT( doubleClicked( QListViewItem * ) ) ); 195 connect( _listview, SIGNAL( doubleClicked(QListViewItem*) ), this, SLOT( doubleClicked(QListViewItem*) ) );
196 connect( _listview, SIGNAL( returnPressed( QListViewItem * ) ), this, SLOT( returnPressed( QListViewItem * ) ) ); 196 connect( _listview, SIGNAL( returnPressed(QListViewItem*) ), this, SLOT( returnPressed(QListViewItem*) ) );
197 197
198 connect( _listview, SIGNAL( onItem( QListViewItem * ) ), this, SLOT( onItem( QListViewItem * ) ) ); 198 connect( _listview, SIGNAL( onItem(QListViewItem*) ), this, SLOT( onItem(QListViewItem*) ) );
199 connect( _listview, SIGNAL( onViewport() ), this, SIGNAL( onViewport() ) ); 199 connect( _listview, SIGNAL( onViewport() ), this, SIGNAL( onViewport() ) );
200 200
201 // common signals for iconview 201 // common signals for iconview
202 202
203 connect( _iconview, SIGNAL( selectionChanged() ), this, SIGNAL( selectionChanged() ) ); 203 connect( _iconview, SIGNAL( selectionChanged() ), this, SIGNAL( selectionChanged() ) );
204 connect( _iconview, SIGNAL( selectionChanged( QIconViewItem * ) ), this, SLOT( selectionChanged( QIconViewItem * ) ) ); 204 connect( _iconview, SIGNAL( selectionChanged(QIconViewItem*) ), this, SLOT( selectionChanged(QIconViewItem*) ) );
205 connect( _iconview, SIGNAL( currentChanged( QIconViewItem * ) ), this, SLOT( currentChanged( QIconViewItem * ) ) ); 205 connect( _iconview, SIGNAL( currentChanged(QIconViewItem*) ), this, SLOT( currentChanged(QIconViewItem*) ) );
206 connect( _iconview, SIGNAL( clicked( QIconViewItem * ) ), this, SLOT( clicked( QIconViewItem * ) ) ); 206 connect( _iconview, SIGNAL( clicked(QIconViewItem*) ), this, SLOT( clicked(QIconViewItem*) ) );
207 connect( _iconview, SIGNAL( pressed( QIconViewItem * ) ), this, SLOT( pressed( QIconViewItem * ) ) ); 207 connect( _iconview, SIGNAL( pressed(QIconViewItem*) ), this, SLOT( pressed(QIconViewItem*) ) );
208 208
209 connect( _iconview, SIGNAL( doubleClicked( QIconViewItem * ) ), this, SLOT( doubleClicked( QIconViewItem * ) ) ); 209 connect( _iconview, SIGNAL( doubleClicked(QIconViewItem*) ), this, SLOT( doubleClicked(QIconViewItem*) ) );
210 connect( _iconview, SIGNAL( returnPressed( QIconViewItem * ) ), this, SLOT( returnPressed( QIconViewItem * ) ) ); 210 connect( _iconview, SIGNAL( returnPressed(QIconViewItem*) ), this, SLOT( returnPressed(QIconViewItem*) ) );
211 211
212 connect( _iconview, SIGNAL( onItem( QIconViewItem * ) ), this, SLOT( onItem( QIconViewItem * ) ) ); 212 connect( _iconview, SIGNAL( onItem(QIconViewItem*) ), this, SLOT( onItem(QIconViewItem*) ) );
213 connect( _iconview, SIGNAL( onViewport() ), this, SIGNAL( onViewport() ) ); 213 connect( _iconview, SIGNAL( onViewport() ), this, SIGNAL( onViewport() ) );
214 214
215 // listview only signals 215 // listview only signals
216 216
217 connect( _listview, SIGNAL( expanded( QListViewItem * ) ), this, SLOT( expanded( QListViewItem * ) ) ); 217 connect( _listview, SIGNAL( expanded(QListViewItem*) ), this, SLOT( expanded(QListViewItem*) ) );
218 connect( _listview, SIGNAL( collapsed( QListViewItem * ) ), this, SLOT( collapsed( QListViewItem * ) ) ); 218 connect( _listview, SIGNAL( collapsed(QListViewItem*) ), this, SLOT( collapsed(QListViewItem*) ) );
219 219
220 // iconview only signals 220 // iconview only signals
221 221
222 connect( _iconview, SIGNAL( moved() ), this, SIGNAL( moved() ) ); 222 connect( _iconview, SIGNAL( moved() ), this, SIGNAL( moved() ) );
223} 223}
224 224
225OVersatileView::~OVersatileView() 225OVersatileView::~OVersatileView()
226{ 226{
227} 227}
228 228
229QPopupMenu* OVersatileView::contextMenu() const 229QPopupMenu* OVersatileView::contextMenu() const
230{ 230{
231 return _contextmenu; 231 return _contextmenu;
232} 232}
233 233
234void OVersatileView::contextMenuRequested( QListViewItem* item, const QPoint& pos, int col ) 234void OVersatileView::contextMenuRequested( QListViewItem* item, const QPoint& pos, int col )
235{ 235{
236 // can't use QObject::inherits here, because ListViewItems, beit Q, O or K, 236 // can't use QObject::inherits here, because ListViewItems, beit Q, O or K,
237 // do not inherit from QObject - assuming here the programmer is 237 // do not inherit from QObject - assuming here the programmer is
238 // disciplined enough to only add OVersatileViewItems to an OVersatileView 238 // disciplined enough to only add OVersatileViewItems to an OVersatileView
239 popupContextMenu( static_cast<OVersatileViewItem*>( item ), pos, col ); 239 popupContextMenu( static_cast<OVersatileViewItem*>( item ), pos, col );
240} 240}
241 241
242void OVersatileView::contextMenuRequested( QIconViewItem* item, const QPoint& pos ) 242void OVersatileView::contextMenuRequested( QIconViewItem* item, const QPoint& pos )
243{ 243{
244 // see above 244 // see above
245 popupContextMenu( static_cast<OVersatileViewItem*>( item ), pos, -1 ); 245 popupContextMenu( static_cast<OVersatileViewItem*>( item ), pos, -1 );
246} 246}
247 247
248void OVersatileView::popupContextMenu( OVersatileViewItem* item, const QPoint& pos, int col ) 248void OVersatileView::popupContextMenu( OVersatileViewItem* item, const QPoint& pos, int col )
249{ 249{
250 if ( !item ) 250 if ( !item )
251 _contextmenu->exec( pos ); 251 _contextmenu->exec( pos );
252 else 252 else
253 emit( contextMenuRequested( item, pos, col ) ); 253 emit( contextMenuRequested( item, pos, col ) );
254} 254}
255 255
256void OVersatileView::setSynchronization( bool sync ) 256void OVersatileView::setSynchronization( bool sync )
257{ 257{
258 _synchronization = sync; 258 _synchronization = sync;
259} 259}
260 260
261bool OVersatileView::synchronization() 261bool OVersatileView::synchronization()
262{ 262{
263 return _synchronization; 263 return _synchronization;
264} 264}
265 265
266void OVersatileView::setDefaultPixmaps( int mode, QPixmap& leaf, QPixmap& opened, QPixmap& closed ) 266void OVersatileView::setDefaultPixmaps( int mode, QPixmap& leaf, QPixmap& opened, QPixmap& closed )
267{ 267{
268 if ( mode == Tree ) 268 if ( mode == Tree )
269 { 269 {
270 _treeleaf = leaf; 270 _treeleaf = leaf;
271 _treeopened = opened; 271 _treeopened = opened;
272 _treeclosed = closed; 272 _treeclosed = closed;
273 } 273 }
274 else if ( mode == Icons ) 274 else if ( mode == Icons )
275 { 275 {
276 _iconleaf = leaf; 276 _iconleaf = leaf;
277 _iconopened = opened; 277 _iconopened = opened;
278 _iconclosed = closed; 278 _iconclosed = closed;
279 } 279 }
280 else 280 else
281 { 281 {
282 odebug << "OVersatileView::setDefaultPixmaps(): invalid mode" << oendl; 282 odebug << "OVersatileView::setDefaultPixmaps(): invalid mode" << oendl;
283 } 283 }
284} 284}
285 285
286QIconView* OVersatileView::iconView() const 286QIconView* OVersatileView::iconView() const
287{ 287{
288 return _iconview; 288 return _iconview;
289} 289}
290 290
291OListView* OVersatileView::listView() const 291OListView* OVersatileView::listView() const
292{ 292{
293 return _listview; 293 return _listview;
294} 294}
295 295
296void OVersatileView::setViewMode( int mode ) 296void OVersatileView::setViewMode( int mode )
297{ 297{
298 if ( mode == Tree ) 298 if ( mode == Tree )
299 { 299 {
300 _viewmode = mode; 300 _viewmode = mode;
301 raiseWidget( _listview ); 301 raiseWidget( _listview );
302 } 302 }
303 else if ( mode == Icons ) 303 else if ( mode == Icons )
304 { 304 {
305 _viewmode = mode; 305 _viewmode = mode;
306 raiseWidget( _iconview ); 306 raiseWidget( _iconview );
307 } 307 }
308 else 308 else
309 { 309 {
310 odebug << "OVersatileView::setViewMode(): invalid mode" << oendl; 310 odebug << "OVersatileView::setViewMode(): invalid mode" << oendl;
311 } 311 }
312} 312}
313 313
314void OVersatileView::setIconViewMode() 314void OVersatileView::setIconViewMode()
315{ 315{
316 setViewMode( Icons ); 316 setViewMode( Icons );
317} 317}
318 318
319void OVersatileView::setTreeViewMode() 319void OVersatileView::setTreeViewMode()
320{ 320{
321 setViewMode( Tree ); 321 setViewMode( Tree );
322} 322}
323 323
324bool OVersatileView::isValidViewMode( int mode ) const 324bool OVersatileView::isValidViewMode( int mode ) const
325{ 325{
326 switch ( _warningpolicy ) 326 switch ( _warningpolicy )
327 { 327 {
328 case OVersatileView::None: 328 case OVersatileView::None:
329 { 329 {
330 return true; 330 return true;
331 } 331 }
332 case OVersatileView::Warn: 332 case OVersatileView::Warn:
333 { 333 {
334 if ( _viewmode != mode ) 334 if ( _viewmode != mode )
335 { 335 {
336 odebug << "OVersatileView::isValidViewMode(): Requested operation not valid in current mode." << oendl; 336 odebug << "OVersatileView::isValidViewMode(): Requested operation not valid in current mode." << oendl;
337 return true; 337 return true;
338 } 338 }
339 } 339 }
340 case OVersatileView::WarnReturn: 340 case OVersatileView::WarnReturn:
341 { 341 {
342 if ( _viewmode != mode ) 342 if ( _viewmode != mode )
343 { 343 {
344 odebug << "OVersatileView::isValidViewMode(): Requested operation not valid in current mode." << oendl; 344 odebug << "OVersatileView::isValidViewMode(): Requested operation not valid in current mode." << oendl;
345 return false; 345 return false;
346 } 346 }
347 } 347 }
348 default: 348 default:
349 { 349 {
350 owarn << "OVersatileView::isValidViewMode(): Inconsistent object state!" << oendl; 350 owarn << "OVersatileView::isValidViewMode(): Inconsistent object state!" << oendl;
351 return true; 351 return true;
352 } 352 }
353 } 353 }
354} 354}
355void OVersatileView::setWarningPolicy( int policy ) const 355void OVersatileView::setWarningPolicy( int policy ) const
356{ 356{
357 _warningpolicy = policy; 357 _warningpolicy = policy;
358} 358}
359bool OVersatileView::warningPolicy() const 359bool OVersatileView::warningPolicy() const
360{ 360{
361 return _warningpolicy; 361 return _warningpolicy;
362} 362}
363//==============================================================================================// 363//==============================================================================================//
364// Stupid Signal forwarders... 364// Stupid Signal forwarders...
365// Folks, this is why I like python with its dynamic typing: 365// Folks, this is why I like python with its dynamic typing:
366// I can code the following dozens of lines C++ in four Python lines... 366// I can code the following dozens of lines C++ in four Python lines...
367//==============================================================================================// 367//==============================================================================================//
368 368
369void OVersatileView::selectionChanged( QListViewItem * item ) 369void OVersatileView::selectionChanged( QListViewItem * item )
370{ 370{
371 emit( selectionChanged( static_cast<OVersatileViewItem*>( item ) ) ); 371 emit( selectionChanged( static_cast<OVersatileViewItem*>( item ) ) );
372} 372}
373 373
374void OVersatileView::selectionChanged( QIconViewItem * item ) 374void OVersatileView::selectionChanged( QIconViewItem * item )
375{ 375{
376 emit( selectionChanged( static_cast<OVersatileViewItem*>( item ) ) ); 376 emit( selectionChanged( static_cast<OVersatileViewItem*>( item ) ) );
377} 377}
378 378
379void OVersatileView::currentChanged( QListViewItem * item ) 379void OVersatileView::currentChanged( QListViewItem * item )
380{ 380{
381 emit( currentChanged( static_cast<OVersatileViewItem*>( item ) ) ); 381 emit( currentChanged( static_cast<OVersatileViewItem*>( item ) ) );
382} 382}
383 383
384void OVersatileView::currentChanged( QIconViewItem * item ) 384void OVersatileView::currentChanged( QIconViewItem * item )
385{ 385{
386 emit( currentChanged( static_cast<OVersatileViewItem*>( item ) ) ); 386 emit( currentChanged( static_cast<OVersatileViewItem*>( item ) ) );
387} 387}
388 388
389void OVersatileView::clicked( QListViewItem * item ) 389void OVersatileView::clicked( QListViewItem * item )
390{ 390{
391 emit( clicked( static_cast<OVersatileViewItem*>( item ) ) ); 391 emit( clicked( static_cast<OVersatileViewItem*>( item ) ) );
392} 392}
393 393
394void OVersatileView::clicked( QIconViewItem * item ) 394void OVersatileView::clicked( QIconViewItem * item )
395{ 395{
396 emit( clicked( static_cast<OVersatileViewItem*>( item ) ) ); 396 emit( clicked( static_cast<OVersatileViewItem*>( item ) ) );
397} 397}
398 398
399void OVersatileView::pressed( QListViewItem * item ) 399void OVersatileView::pressed( QListViewItem * item )
400{ 400{
401 emit( pressed( static_cast<OVersatileViewItem*>( item ) ) ); 401 emit( pressed( static_cast<OVersatileViewItem*>( item ) ) );
402} 402}
403 403
404void OVersatileView::pressed( QIconViewItem * item ) 404void OVersatileView::pressed( QIconViewItem * item )
405{ 405{
406 emit( pressed( static_cast<OVersatileViewItem*>( item ) ) ); 406 emit( pressed( static_cast<OVersatileViewItem*>( item ) ) );
407} 407}
408 408
409void OVersatileView::doubleClicked( QListViewItem * item ) 409void OVersatileView::doubleClicked( QListViewItem * item )
410{ 410{