summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/examples/opiecore/oconfigdemo/oconfigdemo.cpp2
-rw-r--r--libopie2/examples/opiecore/odebugdemo/odebugdemo.cpp2
-rw-r--r--libopie2/examples/opiecore/oglobalsettingsdemo/oglobalsettingsdemo.cpp4
-rw-r--r--libopie2/examples/opiecore/oprocessdemo/oprocessdemo.cpp4
-rw-r--r--libopie2/examples/opiedb/sqltest/spaltenweise.cpp10
-rw-r--r--libopie2/examples/opiedb/sqltest/spaltenweise.pro2
-rw-r--r--libopie2/examples/opiedb/sqltest/zeilenweise.cpp10
-rw-r--r--libopie2/examples/opiedb/sqltest/zeilenweise.pro2
-rw-r--r--libopie2/examples/opiemm/osoundsystemdemo/osoundsystemdemo.cpp2
-rw-r--r--libopie2/examples/opienet/miniwellenreiter/miniwellenreiter.cpp2
-rw-r--r--libopie2/examples/opienet/onetworkdemo/onetworkdemo.cpp2
-rw-r--r--libopie2/examples/opieui/olistviewdemo/main.cpp3
-rw-r--r--libopie2/examples/opieui/olistviewdemo/olistviewdemo.cpp2
-rw-r--r--libopie2/examples/opieui/olistviewdemo/olistviewdemo.h2
-rw-r--r--libopie2/examples/opieui/osplitter_example/osplitter_example.cpp3
-rw-r--r--libopie2/examples/opieui/osplitter_example/osplitter_example.h1
-rw-r--r--libopie2/examples/opieui/osplitter_example/osplitter_mail.cpp8
-rw-r--r--libopie2/examples/opieui/osplitter_example/osplitter_mail.h6
-rw-r--r--libopie2/examples/opieui/oversatileviewdemo/main.cpp3
-rw-r--r--libopie2/examples/opieui/oversatileviewdemo/opieuidemo.cpp8
-rw-r--r--libopie2/examples/opieui/oversatileviewdemo/opieuidemo.h6
-rw-r--r--libopie2/examples/opieui/oversatileviewdemo/oversatileviewdemo.cpp2
-rw-r--r--libopie2/examples/opieui/oversatileviewdemo/oversatileviewdemo.h26
-rw-r--r--libopie2/examples/opieui/owidgetstack_example/owidgetstack_example.cpp2
-rw-r--r--libopie2/examples/opieui/owidgetstack_example/owidgetstack_example.h3
-rw-r--r--libopie2/opiecore/device/odevice.cpp17
-rw-r--r--libopie2/opiecore/device/odevice.h9
-rw-r--r--libopie2/opiecore/device/odevice_ipaq.cpp4
-rw-r--r--libopie2/opiecore/device/odevice_ipaq.h8
-rw-r--r--libopie2/opiecore/device/odevice_jornada.cpp2
-rw-r--r--libopie2/opiecore/device/odevice_jornada.h9
-rw-r--r--libopie2/opiecore/device/odevice_ramses.cpp3
-rw-r--r--libopie2/opiecore/device/odevice_ramses.h7
-rw-r--r--libopie2/opiecore/device/odevice_simpad.cpp3
-rw-r--r--libopie2/opiecore/device/odevice_simpad.h8
-rw-r--r--libopie2/opiecore/device/odevice_yopy.cpp3
-rw-r--r--libopie2/opiecore/device/odevice_yopy.h9
-rw-r--r--libopie2/opiecore/device/odevice_zaurus.cpp3
-rw-r--r--libopie2/opiecore/device/odevice_zaurus.h8
-rw-r--r--libopie2/opiecore/device/odevicebutton.cpp15
-rw-r--r--libopie2/opiecore/device/odevicebutton.h11
-rw-r--r--libopie2/opiecore/oapplication.cpp11
-rw-r--r--libopie2/opiecore/oapplication.h13
-rw-r--r--libopie2/opiecore/oconfig.cpp2
-rw-r--r--libopie2/opiecore/oconfig.h13
-rw-r--r--libopie2/opiecore/odebug.cpp7
-rw-r--r--libopie2/opiecore/odebug.h9
-rw-r--r--libopie2/opiecore/oglobal.cpp6
-rw-r--r--libopie2/opiecore/oglobal.h10
-rw-r--r--libopie2/opiecore/oglobalsettings.cpp3
-rw-r--r--libopie2/opiecore/oglobalsettings.h12
-rw-r--r--libopie2/opiecore/opiecore.pro8
-rw-r--r--libopie2/opiecore/oprocctrl.cpp2
-rw-r--r--libopie2/opiecore/oprocctrl.h10
-rw-r--r--libopie2/opiecore/oprocess.cpp10
-rw-r--r--libopie2/opiecore/oprocess.h13
-rw-r--r--libopie2/opiecore/osmartpointer.h2
-rw-r--r--libopie2/opiecore/ostorageinfo.cpp2
-rw-r--r--libopie2/opiecore/ostorageinfo.h8
-rw-r--r--libopie2/opiedb/TODO1
-rw-r--r--libopie2/opiedb/opiedb.pro2
-rw-r--r--libopie2/opiedb/osqlbackend.cpp2
-rw-r--r--libopie2/opiedb/osqlbackend.h8
-rw-r--r--libopie2/opiedb/osqlbackendmanager.cpp8
-rw-r--r--libopie2/opiedb/osqlbackendmanager.h6
-rw-r--r--libopie2/opiedb/osqldriver.cpp2
-rw-r--r--libopie2/opiedb/osqldriver.h7
-rw-r--r--libopie2/opiedb/osqlerror.cpp2
-rw-r--r--libopie2/opiedb/osqlerror.h5
-rw-r--r--libopie2/opiedb/osqlitedriver.cpp9
-rw-r--r--libopie2/opiedb/osqlitedriver.h8
-rw-r--r--libopie2/opiedb/osqlmanager.cpp6
-rw-r--r--libopie2/opiedb/osqlmanager.h6
-rw-r--r--libopie2/opiedb/osqlquery.cpp2
-rw-r--r--libopie2/opiedb/osqlquery.h8
-rw-r--r--libopie2/opiedb/osqlresult.cpp2
-rw-r--r--libopie2/opiedb/osqlresult.h8
-rw-r--r--libopie2/opiedb/osqltable.cpp2
-rw-r--r--libopie2/opiedb/osqltable.h7
-rw-r--r--libopie2/opiemm/opiemm.pro2
-rw-r--r--libopie2/opiemm/osoundsystem.cpp2
-rw-r--r--libopie2/opiemm/osoundsystem.h17
-rw-r--r--libopie2/opienet/802_11_user.h1
-rw-r--r--libopie2/opienet/dhcp.h2
-rw-r--r--libopie2/opienet/odebugmapper.cpp10
-rw-r--r--libopie2/opienet/odebugmapper.h10
-rw-r--r--libopie2/opienet/omanufacturerdb.cpp7
-rw-r--r--libopie2/opienet/omanufacturerdb.h8
-rw-r--r--libopie2/opienet/onetutils.cpp9
-rw-r--r--libopie2/opienet/onetutils.h15
-rw-r--r--libopie2/opienet/onetwork.cpp9
-rw-r--r--libopie2/opienet/onetwork.h31
-rw-r--r--libopie2/opienet/opcap.cpp8
-rw-r--r--libopie2/opienet/opcap.h52
-rw-r--r--libopie2/opienet/ostation.cpp8
-rw-r--r--libopie2/opienet/ostation.h9
-rw-r--r--libopie2/opiepim/backend/backends.pro6
-rw-r--r--libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp2
-rw-r--r--libopie2/opiepim/backend/ocontactaccessbackend_sql.h8
-rw-r--r--libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp3
-rw-r--r--libopie2/opiepim/backend/odatebookaccessbackend_sql.cpp2
-rw-r--r--libopie2/opiepim/backend/odatebookaccessbackend_sql.h8
-rw-r--r--libopie2/opiepim/backend/otodoaccesssql.cpp2
-rw-r--r--libopie2/opiepim/backend/otodoaccesssql.h12
-rw-r--r--libopie2/opiepim/core/backends/private/xmltree.cc (renamed from libopie2/opiecore/xmltree.cc)4
-rw-r--r--libopie2/opiepim/core/backends/private/xmltree.h (renamed from libopie2/opiecore/xmltree.h)7
-rw-r--r--libopie2/opieui/big-screen/obigscreen_p.h9
-rw-r--r--libopie2/opieui/big-screen/osplitter.cpp13
-rw-r--r--libopie2/opieui/big-screen/osplitter.h15
-rw-r--r--libopie2/opieui/big-screen/owidgetstack.cpp9
-rw-r--r--libopie2/opieui/big-screen/owidgetstack.h7
-rw-r--r--libopie2/opieui/fileselector/ofiledialog.cpp2
-rw-r--r--libopie2/opieui/fileselector/ofiledialog.h7
-rw-r--r--libopie2/opieui/fileselector/ofileselector.cpp9
-rw-r--r--libopie2/opieui/fileselector/ofileselector.h19
-rw-r--r--libopie2/opieui/fileselector/ofileselector_p.h10
-rw-r--r--libopie2/opieui/fileselector/ofileview.h9
-rw-r--r--libopie2/opieui/oclickablelabel.cpp2
-rw-r--r--libopie2/opieui/oclickablelabel.h7
-rw-r--r--libopie2/opieui/odialog.cpp2
-rw-r--r--libopie2/opieui/odialog.h5
-rw-r--r--libopie2/opieui/ofontselector.cpp19
-rw-r--r--libopie2/opieui/ofontselector.h12
-rw-r--r--libopie2/opieui/oimageeffect.cpp7
-rw-r--r--libopie2/opieui/oimageeffect.h5
-rw-r--r--libopie2/opieui/olistview.cpp7
-rw-r--r--libopie2/opieui/olistview.h25
-rw-r--r--libopie2/opieui/opieui.pro3
-rw-r--r--libopie2/opieui/opixmapeffect.cpp2
-rw-r--r--libopie2/opieui/opixmapeffect.h6
-rw-r--r--libopie2/opieui/opixmapprovider.cpp2
-rw-r--r--libopie2/opieui/opixmapprovider.h8
-rw-r--r--libopie2/opieui/opopupmenu.cpp3
-rw-r--r--libopie2/opieui/opopupmenu.h5
-rw-r--r--libopie2/opieui/oselector.cpp18
-rw-r--r--libopie2/opieui/oselector.h5
-rw-r--r--libopie2/opieui/oseparator.cpp2
-rw-r--r--libopie2/opieui/oseparator.h5
-rw-r--r--libopie2/opieui/otabbar.cpp2
-rw-r--r--libopie2/opieui/otabbar.h7
-rw-r--r--libopie2/opieui/otabinfo.h7
-rw-r--r--libopie2/opieui/otabwidget.cpp2
-rw-r--r--libopie2/opieui/otabwidget.h8
-rw-r--r--libopie2/opieui/otaskbarapplet.cpp52
-rw-r--r--libopie2/opieui/otaskbarapplet.h49
-rw-r--r--libopie2/opieui/otimepicker.cpp15
-rw-r--r--libopie2/opieui/otimepicker.h19
-rw-r--r--libopie2/opieui/otimepickerbase.ui38
-rw-r--r--libopie2/opieui/oversatileview.cpp43
-rw-r--r--libopie2/opieui/oversatileview.h83
-rw-r--r--libopie2/opieui/oversatileviewitem.cpp2
-rw-r--r--libopie2/opieui/oversatileviewitem.h5
-rw-r--r--libopie2/opieui/owait.cpp2
-rw-r--r--libopie2/opieui/owait.h6
-rw-r--r--libqtaux/oticker.cpp2
-rw-r--r--libqtaux/oticker.h5
156 files changed, 1001 insertions, 337 deletions
diff --git a/libopie2/examples/opiecore/oconfigdemo/oconfigdemo.cpp b/libopie2/examples/opiecore/oconfigdemo/oconfigdemo.cpp
index a3f8e10..6712870 100644
--- a/libopie2/examples/opiecore/oconfigdemo/oconfigdemo.cpp
+++ b/libopie2/examples/opiecore/oconfigdemo/oconfigdemo.cpp
@@ -1,31 +1,33 @@
1#include <opie2/oapplication.h> 1#include <opie2/oapplication.h>
2#include <opie2/oconfig.h> 2#include <opie2/oconfig.h>
3#include <qpe/config.h> 3#include <qpe/config.h>
4 4
5using namespace Opie::Core;
6
5int main( int argc, char** argv ) 7int main( int argc, char** argv )
6{ 8{
7 OApplication* app = new OApplication( argc, argv, "MyConfigDemoApplication" ); 9 OApplication* app = new OApplication( argc, argv, "MyConfigDemoApplication" );
8 10
9 OConfigGroupSaver c1( app->config(), "MyGroup" ); 11 OConfigGroupSaver c1( app->config(), "MyGroup" );
10 app->config()->writeEntry( "AnEntry", "InMyGroup" ); 12 app->config()->writeEntry( "AnEntry", "InMyGroup" );
11 { 13 {
12 OConfigGroupSaver c2( c1.config(), "AnotherGroup" ); 14 OConfigGroupSaver c2( c1.config(), "AnotherGroup" );
13 app->config()->writeEntry( "AnEntry", "InAnotherGroup" ); 15 app->config()->writeEntry( "AnEntry", "InAnotherGroup" );
14 } // closing the scope returns to the last group 16 } // closing the scope returns to the last group
15 17
16 app->config()->writeEntry( "AnotherEntry", "InMyGroup" ); 18 app->config()->writeEntry( "AnotherEntry", "InMyGroup" );
17 19
18 // do more stuff ... 20 // do more stuff ...
19 21
20 // in this (special) case it is necessary to manually call OConfig::write() (see below) 22 // in this (special) case it is necessary to manually call OConfig::write() (see below)
21 app->config()->write(); 23 app->config()->write();
22 24
23 // can't delete the app when using the OConfigGroupSaver on top level scope, 25 // can't delete the app when using the OConfigGroupSaver on top level scope,
24 // because the destructor of the OConfigGroupSaver needs an application object 26 // because the destructor of the OConfigGroupSaver needs an application object
25 //delete app; // destructor deletes config which writes changes back to disk 27 //delete app; // destructor deletes config which writes changes back to disk
26 28
27 return 0; 29 return 0;
28 30
29} 31}
30 32
31//#include "moc/oconfigdemo.moc" 33//#include "moc/oconfigdemo.moc"
diff --git a/libopie2/examples/opiecore/odebugdemo/odebugdemo.cpp b/libopie2/examples/opiecore/odebugdemo/odebugdemo.cpp
index e8bf04f..0b8e1fe 100644
--- a/libopie2/examples/opiecore/odebugdemo/odebugdemo.cpp
+++ b/libopie2/examples/opiecore/odebugdemo/odebugdemo.cpp
@@ -1,67 +1,69 @@
1/* QT */ 1/* QT */
2 2
3#include <qvbox.h> 3#include <qvbox.h>
4#include <qhbox.h> 4#include <qhbox.h>
5#include <qvbuttongroup.h> 5#include <qvbuttongroup.h>
6#include <qhbuttongroup.h> 6#include <qhbuttongroup.h>
7#include <qlineedit.h> 7#include <qlineedit.h>
8#include <qradiobutton.h> 8#include <qradiobutton.h>
9#include <qpushbutton.h> 9#include <qpushbutton.h>
10 10
11/* OPIE */ 11/* OPIE */
12 12
13#include <qpe/config.h> 13#include <qpe/config.h>
14 14
15#include <opie2/odebug.h> 15#include <opie2/odebug.h>
16#include <opie2/oapplication.h> 16#include <opie2/oapplication.h>
17#include <opie2/oglobal.h> 17#include <opie2/oglobal.h>
18#include <opie2/oglobalsettings.h> 18#include <opie2/oglobalsettings.h>
19 19
20using namespace Opie::Core;
21
20class DemoApp : public OApplication 22class DemoApp : public OApplication
21{ 23{
22Q_OBJECT 24Q_OBJECT
23public: 25public:
24 DemoApp( int argc, char** argv ) : OApplication( argc, argv, "libopie2 debug demo" ) 26 DemoApp( int argc, char** argv ) : OApplication( argc, argv, "libopie2 debug demo" )
25 { 27 {
26 // you have access to your OApplication object via oApp 28 // you have access to your OApplication object via oApp
27 qDebug( "Process-wide OApplication object @ %0x", oApp ); 29 qDebug( "Process-wide OApplication object @ %0x", oApp );
28 30
29 // you have access to global settings via OGlobalSettings 31 // you have access to global settings via OGlobalSettings
30 int mode = OGlobalSettings::debugMode(); 32 int mode = OGlobalSettings::debugMode();
31 33
32 QVBox* vbox = new QVBox(); 34 QVBox* vbox = new QVBox();
33 setMainWidget( vbox ); 35 setMainWidget( vbox );
34 36
35 g = new QVButtonGroup( "Output Strategy", vbox ); 37 g = new QVButtonGroup( "Output Strategy", vbox );
36 QRadioButton* r0 = new QRadioButton( "file", g ); 38 QRadioButton* r0 = new QRadioButton( "file", g );
37 QRadioButton* r1 = new QRadioButton( "messagebox", g ); 39 QRadioButton* r1 = new QRadioButton( "messagebox", g );
38 QRadioButton* r2 = new QRadioButton( "stderr", g ); 40 QRadioButton* r2 = new QRadioButton( "stderr", g );
39 QRadioButton* r3 = new QRadioButton( "syslog", g ); 41 QRadioButton* r3 = new QRadioButton( "syslog", g );
40 QRadioButton* r4 = new QRadioButton( "socket", g ); 42 QRadioButton* r4 = new QRadioButton( "socket", g );
41 g->insert( r0, 0 ); 43 g->insert( r0, 0 );
42 g->insert( r1, 1 ); 44 g->insert( r1, 1 );
43 g->insert( r2, 2 ); 45 g->insert( r2, 2 );
44 g->insert( r3, 3 ); 46 g->insert( r3, 3 );
45 g->insert( r4, 4 ); 47 g->insert( r4, 4 );
46 g->setRadioButtonExclusive( true ); 48 g->setRadioButtonExclusive( true );
47 connect( g, SIGNAL( clicked(int) ), this, SLOT( chooseMethod(int) ) ); 49 connect( g, SIGNAL( clicked(int) ), this, SLOT( chooseMethod(int) ) );
48 50
49 if ( mode != -1 ) g->setButton( mode ); 51 if ( mode != -1 ) g->setButton( mode );
50 52
51 QHButtonGroup* hbox = new QHButtonGroup( "Extra Output Information", vbox ); 53 QHButtonGroup* hbox = new QHButtonGroup( "Extra Output Information", vbox );
52 e = new QLineEdit( hbox ); 54 e = new QLineEdit( hbox );
53 QPushButton* pb = new QPushButton( hbox ); 55 QPushButton* pb = new QPushButton( hbox );
54 56
55 connect( e, SIGNAL( returnPressed() ), this, SLOT( updateDebugOutput() ) ); 57 connect( e, SIGNAL( returnPressed() ), this, SLOT( updateDebugOutput() ) );
56 connect( pb, SIGNAL( clicked() ), this, SLOT( updateDebugOutput() ) ); 58 connect( pb, SIGNAL( clicked() ), this, SLOT( updateDebugOutput() ) );
57 59
58 // show the additional debug mode dependent output information 60 // show the additional debug mode dependent output information
59 e->setText( OGlobalSettings::debugOutput() ); 61 e->setText( OGlobalSettings::debugOutput() );
60 62
61 // buttos 63 // buttos
62 QPushButton* info = new QPushButton( "Emit Debug(Info) Output!", vbox ); 64 QPushButton* info = new QPushButton( "Emit Debug(Info) Output!", vbox );
63 connect( info, SIGNAL( clicked() ), this, SLOT( emitInfoOutput() ) ); 65 connect( info, SIGNAL( clicked() ), this, SLOT( emitInfoOutput() ) );
64 QPushButton* warn = new QPushButton( "Emit a Warning Output!", vbox ); 66 QPushButton* warn = new QPushButton( "Emit a Warning Output!", vbox );
65 connect( warn, SIGNAL( clicked() ), this, SLOT( emitWarningOutput() ) ); 67 connect( warn, SIGNAL( clicked() ), this, SLOT( emitWarningOutput() ) );
66 QPushButton* error = new QPushButton( "Emit an Error Output!", vbox ); 68 QPushButton* error = new QPushButton( "Emit an Error Output!", vbox );
67 connect( error, SIGNAL( clicked() ), this, SLOT( emitErrorOutput() ) ); 69 connect( error, SIGNAL( clicked() ), this, SLOT( emitErrorOutput() ) );
diff --git a/libopie2/examples/opiecore/oglobalsettingsdemo/oglobalsettingsdemo.cpp b/libopie2/examples/opiecore/oglobalsettingsdemo/oglobalsettingsdemo.cpp
index 2f5220b..56f1a0b 100644
--- a/libopie2/examples/opiecore/oglobalsettingsdemo/oglobalsettingsdemo.cpp
+++ b/libopie2/examples/opiecore/oglobalsettingsdemo/oglobalsettingsdemo.cpp
@@ -1,13 +1,15 @@
1#include <opie2/oglobalsettings.h> 1#include <opie2/oglobalsettings.h>
2#include <iostream.h> 2#include <iostream>
3
4using namespace Opie::Core;
3 5
4int main( int argc, char** argv ) 6int main( int argc, char** argv )
5{ 7{
6 printf( "current debugmode seems to be '%d'\n", OGlobalSettings::debugMode() ); 8 printf( "current debugmode seems to be '%d'\n", OGlobalSettings::debugMode() );
7 printf( "output information for this mode is '%s'\n", (const char*) OGlobalSettings::debugOutput() ); 9 printf( "output information for this mode is '%s'\n", (const char*) OGlobalSettings::debugOutput() );
8 10
9 return 0; 11 return 0;
10 12
11} 13}
12 14
13//#include "moc/oconfigdemo.moc" 15//#include "moc/oconfigdemo.moc"
diff --git a/libopie2/examples/opiecore/oprocessdemo/oprocessdemo.cpp b/libopie2/examples/opiecore/oprocessdemo/oprocessdemo.cpp
index 0abf53e..2193565 100644
--- a/libopie2/examples/opiecore/oprocessdemo/oprocessdemo.cpp
+++ b/libopie2/examples/opiecore/oprocessdemo/oprocessdemo.cpp
@@ -1,11 +1,13 @@
1#include <opie2/oprocess.h> 1#include <opie2/oprocess.h>
2#include <iostream.h> 2#include <iostream>
3
4using namespace Opie::Core;
3 5
4int main( int argc, char** argv ) 6int main( int argc, char** argv )
5{ 7{
6 printf( "my own PID seems to be '%d'\n", OProcess::processPID( "oprocessdemo" ) ); 8 printf( "my own PID seems to be '%d'\n", OProcess::processPID( "oprocessdemo" ) );
7 printf( "the PID of process 'Mickey' seems to be '%d'\n\n", OProcess::processPID( "Mickey" ) ); 9 printf( "the PID of process 'Mickey' seems to be '%d'\n\n", OProcess::processPID( "Mickey" ) );
8 10
9 return 0; 11 return 0;
10} 12}
11 13
diff --git a/libopie2/examples/opiedb/sqltest/spaltenweise.cpp b/libopie2/examples/opiedb/sqltest/spaltenweise.cpp
index 8790cdd..e1a4d5d 100644
--- a/libopie2/examples/opiedb/sqltest/spaltenweise.cpp
+++ b/libopie2/examples/opiedb/sqltest/spaltenweise.cpp
@@ -1,41 +1,43 @@
1#include <qdir.h> 1#include <qdir.h>
2 2
3#include <qpe/qpeapplication.h> 3#include <qpe/qpeapplication.h>
4#include "../osqlmanager.h" 4#include <opie2/osqlmanager.h>
5#include "../osqlquery.h" 5#include <opie2/osqlquery.h>
6#include "../osqldriver.h" 6#include <opie2/osqldriver.h>
7#include "../osqlresult.h" 7#include <opie2/osqlresult.h>
8
9using namespace Opie::DB;
8 10
9int main( int argc, char* argv[] ) { 11int main( int argc, char* argv[] ) {
10 12
11 QPEApplication app( argc, argv ); 13 QPEApplication app( argc, argv );
12 OSQLManager man; 14 OSQLManager man;
13 man.registerPath( QDir::currentDirPath() ); 15 man.registerPath( QDir::currentDirPath() );
14 OSQLBackEnd::ValueList list = man.queryBackEnd(); 16 OSQLBackEnd::ValueList list = man.queryBackEnd();
15 17
16 OSQLDriver *driver = man.standard(); 18 OSQLDriver *driver = man.standard();
17 qWarning("testmain" + driver->id() ); 19 qWarning("testmain" + driver->id() );
18 driver->setUrl("/home/ich/spaltenweise"); 20 driver->setUrl("/home/ich/spaltenweise");
19 if ( driver->open() ) { 21 if ( driver->open() ) {
20 qWarning("could open"); 22 qWarning("could open");
21 }else 23 }else
22 qWarning("wasn't able to open"); 24 qWarning("wasn't able to open");
23 OSQLRawQuery *raw = new OSQLRawQuery("create table todolist(" 25 OSQLRawQuery *raw = new OSQLRawQuery("create table todolist("
24 "uid,categories,completed," 26 "uid,categories,completed,"
25 "progress,summary,HasDate," 27 "progress,summary,HasDate,"
26 "DateDay,DateMonth,DateYear," 28 "DateDay,DateMonth,DateYear,"
27 "priority,description)" ); 29 "priority,description)" );
28 30
29 OSQLResult res = driver->query( raw ); 31 OSQLResult res = driver->query( raw );
30 delete raw; 32 delete raw;
31 for (int i = 0; i< 10000; i++ ) { 33 for (int i = 0; i< 10000; i++ ) {
32 int uid = i; 34 int uid = i;
33 OSQLRawQuery raw("insert into todolist VALUES("+ 35 OSQLRawQuery raw("insert into todolist VALUES("+
34 QString::number(uid)+ ",'-122324;-12132',1,100,"+ 36 QString::number(uid)+ ",'-122324;-12132',1,100,"+
35 "'Summary234-"+QString::number(uid)+"',1,5,8,2002,1,"+ 37 "'Summary234-"+QString::number(uid)+"',1,5,8,2002,1,"+
36 "'Description\n12344')"); 38 "'Description\n12344')");
37 OSQLResult res = driver->query( &raw ); 39 OSQLResult res = driver->query( &raw );
38 40
39 } 41 }
40 return 0; 42 return 0;
41}; 43};
diff --git a/libopie2/examples/opiedb/sqltest/spaltenweise.pro b/libopie2/examples/opiedb/sqltest/spaltenweise.pro
index f54fada..3cab802 100644
--- a/libopie2/examples/opiedb/sqltest/spaltenweise.pro
+++ b/libopie2/examples/opiedb/sqltest/spaltenweise.pro
@@ -1,13 +1,13 @@
1 TEMPLATE= app 1 TEMPLATE= app
2 CONFIG = qt warn_on release 2 CONFIG = qt warn_on release
3 HEADERS = 3 HEADERS =
4 SOURCES = spaltenweise.cpp 4 SOURCES = spaltenweise.cpp
5INCLUDEPATH += $(OPIEDIR)/include 5INCLUDEPATH += $(OPIEDIR)/include
6 DEPENDPATH+= $(OPIEDIR)/include 6 DEPENDPATH+= $(OPIEDIR)/include
7LIBS += -lqpe -lopiesql 7LIBS += -lqpe -lopiedb2
8 TARGET = spaltenweise 8 TARGET = spaltenweise
9 9
10 10
11 11
12 12
13include ( $(OPIEDIR)/include.pro ) 13include ( $(OPIEDIR)/include.pro )
diff --git a/libopie2/examples/opiedb/sqltest/zeilenweise.cpp b/libopie2/examples/opiedb/sqltest/zeilenweise.cpp
index e538c9f..2d11ac5 100644
--- a/libopie2/examples/opiedb/sqltest/zeilenweise.cpp
+++ b/libopie2/examples/opiedb/sqltest/zeilenweise.cpp
@@ -1,55 +1,57 @@
1#include <qdir.h> 1#include <qdir.h>
2 2
3#include <qpe/qpeapplication.h> 3#include <qpe/qpeapplication.h>
4#include "../osqlmanager.h" 4#include <opie2/osqlmanager.h>
5#include "../osqlquery.h" 5#include <opie2/osqlquery.h>
6#include "../osqldriver.h" 6#include <opie2/osqldriver.h>
7#include "../osqlresult.h" 7#include <opie2/osqlresult.h>
8
9using namespace Opie::DB;
8 10
9int main( int argc, char* argv[] ) { 11int main( int argc, char* argv[] ) {
10 12
11QPEApplication app( argc, argv ); 13QPEApplication app( argc, argv );
12OSQLManager man; 14OSQLManager man;
13man.registerPath( QDir::currentDirPath() ); 15man.registerPath( QDir::currentDirPath() );
14OSQLBackEnd::ValueList list = man.queryBackEnd(); 16OSQLBackEnd::ValueList list = man.queryBackEnd();
15 17
16OSQLDriver *driver = man.standard(); 18OSQLDriver *driver = man.standard();
17 qWarning("testmain" + driver->id() ); 19 qWarning("testmain" + driver->id() );
18 driver->setUrl("/home/ich/zeilenweise"); 20 driver->setUrl("/home/ich/zeilenweise");
19 if ( driver->open() ) { 21 if ( driver->open() ) {
20 qWarning("could open"); 22 qWarning("could open");
21 }else 23 }else
22 qWarning("wasn't able to open"); 24 qWarning("wasn't able to open");
23 OSQLRawQuery raw2("BEGIN TRANSACTION"); 25 OSQLRawQuery raw2("BEGIN TRANSACTION");
24 OSQLRawQuery *raw = new OSQLRawQuery("create table todolist(uid,key,value)"); 26 OSQLRawQuery *raw = new OSQLRawQuery("create table todolist(uid,key,value)");
25 OSQLResult res = driver->query( &raw2 ); 27 OSQLResult res = driver->query( &raw2 );
26 res = driver->query( raw ); 28 res = driver->query( raw );
27 delete raw; 29 delete raw;
28 for (int i = 0; i< 10000; i++ ) { 30 for (int i = 0; i< 10000; i++ ) {
29 int uid = i; 31 int uid = i;
30 OSQLRawQuery *raw; 32 OSQLRawQuery *raw;
31 raw = new OSQLRawQuery("insert into todolist VALUES("+QString::number(uid)+",'Categories',"+"'-122324;-12132')"); 33 raw = new OSQLRawQuery("insert into todolist VALUES("+QString::number(uid)+",'Categories',"+"'-122324;-12132')");
32 OSQLResult res = driver->query(raw ); 34 OSQLResult res = driver->query(raw );
33 delete raw; 35 delete raw;
34 36
35 raw = new OSQLRawQuery("insert into todolist VALUES("+QString::number(uid) + 37 raw = new OSQLRawQuery("insert into todolist VALUES("+QString::number(uid) +
36 ",'Completed',1)" ); 38 ",'Completed',1)" );
37 res = driver->query(raw ); 39 res = driver->query(raw );
38 delete raw; 40 delete raw;
39 41
40 raw = new OSQLRawQuery("insert into todolist VALUES("+ 42 raw = new OSQLRawQuery("insert into todolist VALUES("+
41 QString::number(uid)+",'Progress',100)" ); 43 QString::number(uid)+",'Progress',100)" );
42 res = driver->query( raw ); 44 res = driver->query( raw );
43 delete raw; 45 delete raw;
44 46
45 raw = new OSQLRawQuery("insert into todolist VALUES("+ 47 raw = new OSQLRawQuery("insert into todolist VALUES("+
46 QString::number(uid)+",'Summary',"+ 48 QString::number(uid)+",'Summary',"+
47 "'Summary234-"+ QString::number(uid) + "')"); 49 "'Summary234-"+ QString::number(uid) + "')");
48 res = driver->query( raw ); 50 res = driver->query( raw );
49 delete raw; 51 delete raw;
50 52
51 raw = new OSQLRawQuery("insert into todolist VALUES("+ 53 raw = new OSQLRawQuery("insert into todolist VALUES("+
52 QString::number(uid)+",'HasDate',1)"); 54 QString::number(uid)+",'HasDate',1)");
53 res = driver->query( raw ); 55 res = driver->query( raw );
54 delete raw; 56 delete raw;
55 57
diff --git a/libopie2/examples/opiedb/sqltest/zeilenweise.pro b/libopie2/examples/opiedb/sqltest/zeilenweise.pro
index e5cfcc7..6952921 100644
--- a/libopie2/examples/opiedb/sqltest/zeilenweise.pro
+++ b/libopie2/examples/opiedb/sqltest/zeilenweise.pro
@@ -1,13 +1,13 @@
1 TEMPLATE= app 1 TEMPLATE= app
2 CONFIG = qt warn_on release 2 CONFIG = qt warn_on release
3 HEADERS = 3 HEADERS =
4 SOURCES = zeilenweise.cpp 4 SOURCES = zeilenweise.cpp
5INCLUDEPATH += $(OPIEDIR)/include 5INCLUDEPATH += $(OPIEDIR)/include
6 DEPENDPATH+= $(OPIEDIR)/include 6 DEPENDPATH+= $(OPIEDIR)/include
7LIBS += -lqpe -lopiesql 7LIBS += -lqpe -lopiedb2
8 TARGET = zeilenweise 8 TARGET = zeilenweise
9 9
10 10
11 11
12 12
13include ( $(OPIEDIR)/include.pro ) 13include ( $(OPIEDIR)/include.pro )
diff --git a/libopie2/examples/opiemm/osoundsystemdemo/osoundsystemdemo.cpp b/libopie2/examples/opiemm/osoundsystemdemo/osoundsystemdemo.cpp
index 79bf327..8d421fd 100644
--- a/libopie2/examples/opiemm/osoundsystemdemo/osoundsystemdemo.cpp
+++ b/libopie2/examples/opiemm/osoundsystemdemo/osoundsystemdemo.cpp
@@ -1,32 +1,34 @@
1#include <opie2/osoundsystem.h> 1#include <opie2/osoundsystem.h>
2 2
3using namespace Opie::MM;
4
3int main( int argc, char** argv ) 5int main( int argc, char** argv )
4{ 6{
5 qDebug( "OPIE Sound System Demo" ); 7 qDebug( "OPIE Sound System Demo" );
6 8
7 OSoundSystem* sound = OSoundSystem::instance(); 9 OSoundSystem* sound = OSoundSystem::instance();
8 10
9 OSoundSystem::CardIterator it = sound->iterator(); 11 OSoundSystem::CardIterator it = sound->iterator();
10/* 12/*
11 while ( it.current() ) 13 while ( it.current() )
12 { 14 {
13 qDebug( "DEMO: OSoundSystem contains Interface '%s'", (const char*) it.current()->name() ); 15 qDebug( "DEMO: OSoundSystem contains Interface '%s'", (const char*) it.current()->name() );
14 ++it; 16 ++it;
15 } 17 }
16 18
17*/ 19*/
18 OSoundCard* card = it.current(); 20 OSoundCard* card = it.current();
19 21
20 OMixerInterface* mixer = card->mixer(); 22 OMixerInterface* mixer = card->mixer();
21 23
22 QStringList channels = mixer->allChannels(); 24 QStringList channels = mixer->allChannels();
23 25
24 for ( QStringList::Iterator it = channels.begin(); it != channels.end(); ++it ) 26 for ( QStringList::Iterator it = channels.begin(); it != channels.end(); ++it )
25 { 27 {
26 qDebug( "OSSDEMO: Mixer has channel %s", (const char*) *it ); 28 qDebug( "OSSDEMO: Mixer has channel %s", (const char*) *it );
27 qDebug( "OSSDEMO: +--- volume %d (left) | %d (right)", mixer->volume( *it ) & 0xff, mixer->volume( *it ) >> 8 ); 29 qDebug( "OSSDEMO: +--- volume %d (left) | %d (right)", mixer->volume( *it ) & 0xff, mixer->volume( *it ) >> 8 );
28 } 30 }
29 31
30 return 0; 32 return 0;
31 33
32} 34}
diff --git a/libopie2/examples/opienet/miniwellenreiter/miniwellenreiter.cpp b/libopie2/examples/opienet/miniwellenreiter/miniwellenreiter.cpp
index eb2e8e8..f1966c1 100644
--- a/libopie2/examples/opienet/miniwellenreiter/miniwellenreiter.cpp
+++ b/libopie2/examples/opienet/miniwellenreiter/miniwellenreiter.cpp
@@ -1,59 +1,61 @@
1#include <qdict.h> 1#include <qdict.h>
2#include <qsocketnotifier.h> 2#include <qsocketnotifier.h>
3#include <qstring.h> 3#include <qstring.h>
4#include <opie2/onetwork.h> 4#include <opie2/onetwork.h>
5#include <qapplication.h> 5#include <qapplication.h>
6#include <opie2/opcap.h> 6#include <opie2/opcap.h>
7#include <cerrno> 7#include <cerrno>
8#include <cstdio> 8#include <cstdio>
9#include <cstdlib> 9#include <cstdlib>
10#include <cstring> 10#include <cstring>
11 11
12
13using namespace Opie::Net;
12//======================== Station help class =============================== 14//======================== Station help class ===============================
13 15
14class Station 16class Station
15{ 17{
16 public: 18 public:
17 Station( QString t, int c, bool w ) : type(t), channel(c), wep(w), beacons(1) {}; 19 Station( QString t, int c, bool w ) : type(t), channel(c), wep(w), beacons(1) {};
18 ~Station() {}; 20 ~Station() {};
19 21
20 QString type; 22 QString type;
21 int channel; 23 int channel;
22 bool wep; 24 bool wep;
23 int beacons; 25 int beacons;
24}; 26};
25 27
26QDict<Station> stations; 28QDict<Station> stations;
27 29
28//======================== Application class =============================== 30//======================== Application class ===============================
29 31
30class Wellenreiter : public QApplication 32class Wellenreiter : public QApplication
31{ 33{
32Q_OBJECT 34Q_OBJECT
33public: 35public:
34 Wellenreiter( int argc, char** argv ) : QApplication( argc, argv ), channel( 1 ) 36 Wellenreiter( int argc, char** argv ) : QApplication( argc, argv ), channel( 1 )
35 { 37 {
36 38
37 ONetwork* net = ONetwork::instance(); 39 ONetwork* net = ONetwork::instance();
38 40
39 if ( argc < 3 ) 41 if ( argc < 3 )
40 { 42 {
41 printf( "Usage: ./%s <interface> <driver> <interval>\n", argv[0] ); 43 printf( "Usage: ./%s <interface> <driver> <interval>\n", argv[0] );
42 printf( "\n" ); 44 printf( "\n" );
43 printf( "Valid wireless interfaces (detected) are:\n" ); 45 printf( "Valid wireless interfaces (detected) are:\n" );
44 46
45 ONetwork::InterfaceIterator it = net->iterator(); 47 ONetwork::InterfaceIterator it = net->iterator();
46 while ( it.current() ) 48 while ( it.current() )
47 { 49 {
48 if ( it.current()->isWireless() ) 50 if ( it.current()->isWireless() )
49 { 51 {
50 printf( " - '%s' (MAC=%s) (IPv4=%s)\n", (const char*) it.current()->name(), 52 printf( " - '%s' (MAC=%s) (IPv4=%s)\n", (const char*) it.current()->name(),
51 (const char*) it.current()->macAddress().toString(), 53 (const char*) it.current()->macAddress().toString(),
52 (const char*) it.current()->ipV4Address() ); 54 (const char*) it.current()->ipV4Address() );
53 } 55 }
54 ++it; 56 ++it;
55 } 57 }
56 exit( -1 ); 58 exit( -1 );
57 } 59 }
58 60
59 printf( "*******************************************************************\n" ); 61 printf( "*******************************************************************\n" );
diff --git a/libopie2/examples/opienet/onetworkdemo/onetworkdemo.cpp b/libopie2/examples/opienet/onetworkdemo/onetworkdemo.cpp
index 4763316..4f8af60 100644
--- a/libopie2/examples/opienet/onetworkdemo/onetworkdemo.cpp
+++ b/libopie2/examples/opienet/onetworkdemo/onetworkdemo.cpp
@@ -1,54 +1,56 @@
1#include <opie2/onetwork.h> 1#include <opie2/onetwork.h>
2#include <opie2/ostation.h> 2#include <opie2/ostation.h>
3#include <opie2/omanufacturerdb.h> 3#include <opie2/omanufacturerdb.h>
4 4
5#include <unistd.h> 5#include <unistd.h>
6 6
7using namespace Opie::Net;
8
7int main( int argc, char** argv ) 9int main( int argc, char** argv )
8{ 10{
9 qDebug( "OPIE Network Demo" ); 11 qDebug( "OPIE Network Demo" );
10 12
11 ONetwork* net = ONetwork::instance(); 13 ONetwork* net = ONetwork::instance();
12 14
13 ONetwork::InterfaceIterator it = net->iterator(); 15 ONetwork::InterfaceIterator it = net->iterator();
14 16
15 while ( it.current() ) 17 while ( it.current() )
16 { 18 {
17 qDebug( "DEMO: ONetwork contains Interface '%s'", (const char*) it.current()->name() ); 19 qDebug( "DEMO: ONetwork contains Interface '%s'", (const char*) it.current()->name() );
18 qDebug( "DEMO: Datalink code is '%d'", it.current()->dataLinkType() ); 20 qDebug( "DEMO: Datalink code is '%d'", it.current()->dataLinkType() );
19 qDebug( "DEMO: MAC Address is '%s'", (const char*) it.current()->macAddress().toString() ); 21 qDebug( "DEMO: MAC Address is '%s'", (const char*) it.current()->macAddress().toString() );
20 qDebug( "DEMO: MAC Address is '%s'", (const char*) it.current()->macAddress().toString(true) ); 22 qDebug( "DEMO: MAC Address is '%s'", (const char*) it.current()->macAddress().toString(true) );
21 qDebug( "DEMO: MAC Manufacturer seems to be '%s'", (const char*) it.current()->macAddress().manufacturer() ); 23 qDebug( "DEMO: MAC Manufacturer seems to be '%s'", (const char*) it.current()->macAddress().manufacturer() );
22 qDebug( "DEMO: Manufacturertest1 = '%s'", (const char*) OManufacturerDB::instance()->lookupExt( "08:00:87" ) ); 24 qDebug( "DEMO: Manufacturertest1 = '%s'", (const char*) OManufacturerDB::instance()->lookupExt( "08:00:87" ) );
23 qDebug( "DEMO: Manufacturertest2 = '%s'", (const char*) OManufacturerDB::instance()->lookupExt( "E2:0C:0F" ) ); 25 qDebug( "DEMO: Manufacturertest2 = '%s'", (const char*) OManufacturerDB::instance()->lookupExt( "E2:0C:0F" ) );
24 qDebug( "Demo: IPv4 Address is '%s'", (const char*) it.current()->ipV4Address() ); 26 qDebug( "Demo: IPv4 Address is '%s'", (const char*) it.current()->ipV4Address() );
25 if ( it.current()->isWireless() ) 27 if ( it.current()->isWireless() )
26 { 28 {
27 OWirelessNetworkInterface* iface = static_cast<OWirelessNetworkInterface*>( it.current() ); 29 OWirelessNetworkInterface* iface = static_cast<OWirelessNetworkInterface*>( it.current() );
28 qDebug( "DEMO: '%s' seems to feature the wireless extensions.", (const char*) iface->name() ); 30 qDebug( "DEMO: '%s' seems to feature the wireless extensions.", (const char*) iface->name() );
29 qDebug( "DEMO: Current SSID is '%s'", (const char*) iface->SSID() ); 31 qDebug( "DEMO: Current SSID is '%s'", (const char*) iface->SSID() );
30 qDebug( "DEMO: Antenna is tuned to '%f', that is channel %d", iface->frequency(), iface->channel() ); 32 qDebug( "DEMO: Antenna is tuned to '%f', that is channel %d", iface->frequency(), iface->channel() );
31 33
32 //if ( iface->mode() == OWirelessNetworkInterface::adhoc ) 34 //if ( iface->mode() == OWirelessNetworkInterface::adhoc )
33 //{ 35 //{
34 //qDebug( "DEMO: Associated AP has MAC Address '%s'", (const char*) iface->associatedAP().toString() ); 36 //qDebug( "DEMO: Associated AP has MAC Address '%s'", (const char*) iface->associatedAP().toString() );
35 //} 37 //}
36 38
37 /* 39 /*
38 40
39 // nickname 41 // nickname
40 qDebug( "DEMO: Current NickName is '%s'", (const char*) iface->nickName() ); 42 qDebug( "DEMO: Current NickName is '%s'", (const char*) iface->nickName() );
41 iface->setNickName( "MyNickName" ); 43 iface->setNickName( "MyNickName" );
42 if ( iface->nickName() != "MyNickName" ) 44 if ( iface->nickName() != "MyNickName" )
43 qDebug( "DEMO: Warning! Can't change nickname" ); 45 qDebug( "DEMO: Warning! Can't change nickname" );
44 else 46 else
45 qDebug( "DEMO: Nickname change successful." ); 47 qDebug( "DEMO: Nickname change successful." );
46 48
47 /* 49 /*
48 50
49 // operation mode 51 // operation mode
50 qDebug( "DEMO: Current OperationMode is '%s'", (const char*) iface->mode() ); 52 qDebug( "DEMO: Current OperationMode is '%s'", (const char*) iface->mode() );
51 iface->setMode( "adhoc" ); 53 iface->setMode( "adhoc" );
52 if ( iface->mode() != "adhoc" ) 54 if ( iface->mode() != "adhoc" )
53 qDebug( "DEMO: Warning! Can't change operation mode" ); 55 qDebug( "DEMO: Warning! Can't change operation mode" );
54 else 56 else
diff --git a/libopie2/examples/opieui/olistviewdemo/main.cpp b/libopie2/examples/opieui/olistviewdemo/main.cpp
index a93f361..cd49c28 100644
--- a/libopie2/examples/opieui/olistviewdemo/main.cpp
+++ b/libopie2/examples/opieui/olistviewdemo/main.cpp
@@ -1,26 +1,29 @@
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#include "olistviewdemo.h" 16#include "olistviewdemo.h"
17#include <opie2/oapplication.h> 17#include <opie2/oapplication.h>
18 18
19using namespace Opie::Ui;
20using namespace Opie::Core;
21
19int main( int argc, char **argv ) 22int main( int argc, char **argv )
20{ 23{
21 OApplication a( argc, argv, "OListViewDemo" ); 24 OApplication a( argc, argv, "OListViewDemo" );
22 OListViewDemo e; 25 OListViewDemo e;
23 a.showMainWidget(&e); 26 a.showMainWidget(&e);
24 return a.exec(); 27 return a.exec();
25} 28}
26 29
diff --git a/libopie2/examples/opieui/olistviewdemo/olistviewdemo.cpp b/libopie2/examples/opieui/olistviewdemo/olistviewdemo.cpp
index 5ba7b69..7834b3b 100644
--- a/libopie2/examples/opieui/olistviewdemo/olistviewdemo.cpp
+++ b/libopie2/examples/opieui/olistviewdemo/olistviewdemo.cpp
@@ -1,80 +1,82 @@
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 "olistviewdemo.h" 33#include "olistviewdemo.h"
34#include <opie2/olistview.h> 34#include <opie2/olistview.h>
35 35
36#include <qstring.h> 36#include <qstring.h>
37#include <qpixmap.h> 37#include <qpixmap.h>
38#include <qlistview.h> 38#include <qlistview.h>
39 39
40using namespace Opie::Ui;
41
40OListViewDemo::OListViewDemo( QWidget* parent, const char* name, WFlags f ) 42OListViewDemo::OListViewDemo( QWidget* parent, const char* name, WFlags f )
41 :QVBox( parent, name, f ) 43 :QVBox( parent, name, f )
42{ 44{
43 lv = new ONamedListView( this ); 45 lv = new ONamedListView( this );
44 lv->setRootIsDecorated( true ); 46 lv->setRootIsDecorated( true );
45 lv->addColumns( QStringList::split( ' ', "Column1 Column2 Column3 Column4" ) ); 47 lv->addColumns( QStringList::split( ' ', "Column1 Column2 Column3 Column4" ) );
46 48
47 ONamedListViewItem* item = new ONamedListViewItem( lv, QStringList::split( ' ', "Text1 Text2 Text3 Text4" ) ); 49 ONamedListViewItem* item = new ONamedListViewItem( lv, QStringList::split( ' ', "Text1 Text2 Text3 Text4" ) );
48 item->setText( "Column2", "ModifiedText" ); 50 item->setText( "Column2", "ModifiedText" );
49 item->setText( "Column5", "ThisColumnDoesNotExits" ); 51 item->setText( "Column5", "ThisColumnDoesNotExits" );
50 52
51 new ONamedListViewItem( lv, QStringList::split( ' ', "Text1 Text2 Text3 Text4" ) ); 53 new ONamedListViewItem( lv, QStringList::split( ' ', "Text1 Text2 Text3 Text4" ) );
52 new ONamedListViewItem( lv, QStringList::split( ' ', "Text1 Text2 Text3 Text4" ) ); 54 new ONamedListViewItem( lv, QStringList::split( ' ', "Text1 Text2 Text3 Text4" ) );
53 new ONamedListViewItem( lv, QStringList::split( ' ', "Text1 Text2 Text3 Minni" ) ); 55 new ONamedListViewItem( lv, QStringList::split( ' ', "Text1 Text2 Text3 Minni" ) );
54 item = new ONamedListViewItem( lv, QStringList::split( ' ', "XXX YYY ZZZ ***" ) ); 56 item = new ONamedListViewItem( lv, QStringList::split( ' ', "XXX YYY ZZZ ***" ) );
55 new ONamedListViewItem( lv, QStringList::split( ' ', "Text1 Text2 Text3 Text4" ) ); 57 new ONamedListViewItem( lv, QStringList::split( ' ', "Text1 Text2 Text3 Text4" ) );
56 new ONamedListViewItem( lv, QStringList::split( ' ', "Text1 Text2 Text3 Text4" ) ); 58 new ONamedListViewItem( lv, QStringList::split( ' ', "Text1 Text2 Text3 Text4" ) );
57 59
58 new ONamedListViewItem( item, QStringList::split( ' ', "SubText1 Text2 Text3 Text4" ) ); 60 new ONamedListViewItem( item, QStringList::split( ' ', "SubText1 Text2 Text3 Text4" ) );
59 new ONamedListViewItem( item, QStringList::split( ' ', "SubText1 Text2 Text3 Text4" ) ); 61 new ONamedListViewItem( item, QStringList::split( ' ', "SubText1 Text2 Text3 Text4" ) );
60 new ONamedListViewItem( item, QStringList::split( ' ', "SubText1 Text2 Text3 Text4" ) ); 62 new ONamedListViewItem( item, QStringList::split( ' ', "SubText1 Text2 Text3 Text4" ) );
61 item = new ONamedListViewItem( item, QStringList::split( ' ', "Text1 Text2 Text3 HereItComes" ) ); 63 item = new ONamedListViewItem( item, QStringList::split( ' ', "Text1 Text2 Text3 HereItComes" ) );
62 item = new ONamedListViewItem( item, QStringList::split( ' ', "Text1 Text2 Text3 HereItComesSoon" ) ); 64 item = new ONamedListViewItem( item, QStringList::split( ' ', "Text1 Text2 Text3 HereItComesSoon" ) );
63 item = new ONamedListViewItem( item, QStringList::split( ' ', "Text1 Text2 Text3 Mickey" ) ); 65 item = new ONamedListViewItem( item, QStringList::split( ' ', "Text1 Text2 Text3 Mickey" ) );
64 66
65 if ( lv->find( 3, "Mickey", 3 ) ) 67 if ( lv->find( 3, "Mickey", 3 ) )
66 qDebug( "found Mickey :-)" ); 68 qDebug( "found Mickey :-)" );
67 else 69 else
68 qDebug( "did not found Mickey :-(" ); 70 qDebug( "did not found Mickey :-(" );
69 71
70 if ( lv->find( 3, "Minni", 0 ) ) 72 if ( lv->find( 3, "Minni", 0 ) )
71 qDebug( "found Minni :-)" ); 73 qDebug( "found Minni :-)" );
72 else 74 else
73 qDebug( "did not found Minni :-(" ); 75 qDebug( "did not found Minni :-(" );
74 76
75} 77}
76 78
77OListViewDemo::~OListViewDemo() 79OListViewDemo::~OListViewDemo()
78{ 80{
79} 81}
80 82
diff --git a/libopie2/examples/opieui/olistviewdemo/olistviewdemo.h b/libopie2/examples/opieui/olistviewdemo/olistviewdemo.h
index 8a5986a..0b5c498 100644
--- a/libopie2/examples/opieui/olistviewdemo/olistviewdemo.h
+++ b/libopie2/examples/opieui/olistviewdemo/olistviewdemo.h
@@ -1,51 +1,51 @@
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 <mickey@tm.informatik.uni-frankfurt.de> 4              Copyright (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
5 =. 5 =.
6 .=l. 6 .=l.
7           .>+-= 7           .>+-=
8 _;:,     .>    :=|. This program is free software; you can 8 _;:,     .>    :=|. This program is free software; you can
9.> <`_,   >  .   <= redistribute it and/or modify it under 9.> <`_,   >  .   <= redistribute it and/or modify it under
10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
11.="- .-=="i,     .._ License as published by the Free Software 11.="- .-=="i,     .._ License as published by the Free Software
12 - .   .-<_>     .<> Foundation; either version 2 of the License, 12 - .   .-<_>     .<> Foundation; either version 2 of the License,
13     ._= =}       : or (at your option) any later version. 13     ._= =}       : or (at your option) any later version.
14    .%`+i>       _;_. 14    .%`+i>       _;_.
15    .i_,=:_.      -<s. This program is distributed in the hope that 15    .i_,=:_.      -<s. This program is distributed in the hope that
16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
17    : ..    .:,     . . . without even the implied warranty of 17    : ..    .:,     . . . without even the implied warranty of
18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.=       =       ; Library General Public License for more 20..}^=.=       =       ; Library General Public License for more
21++=   -.     .`     .: details. 21++=   -.     .`     .: details.
22 :     =  ...= . :.=- 22 :     =  ...= . :.=-
23 -.   .:....=;==+<; You should have received a copy of the GNU 23 -.   .:....=;==+<; You should have received a copy of the GNU
24  -_. . .   )=.  = Library General Public License along with 24  -_. . .   )=.  = Library General Public License along with
25    --        :-=` this library; see the file COPYING.LIB. 25    --        :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation, 26 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330, 27 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA. 28 Boston, MA 02111-1307, USA.
29 29
30*/ 30*/
31 31
32#ifndef OLISTVIEWDEMO_H 32#ifndef OLISTVIEWDEMO_H
33#define OLISTVIEWDEMO_H 33#define OLISTVIEWDEMO_H
34 34
35#include <qvbox.h> 35#include <qvbox.h>
36#include <opie2/olistview.h> 36#include <opie2/olistview.h>
37 37
38class OListViewDemo: public QVBox 38class OListViewDemo: public QVBox
39{ 39{
40 Q_OBJECT 40 Q_OBJECT
41 41
42 public: 42 public:
43 OListViewDemo( QWidget* parent=0, const char* name=0, WFlags f=0 ); 43 OListViewDemo( QWidget* parent=0, const char* name=0, WFlags f=0 );
44 virtual ~OListViewDemo(); 44 virtual ~OListViewDemo();
45 45
46 private: 46 private:
47 ONamedListView* lv; 47 Opie::Ui::ONamedListView* lv;
48 48
49}; 49};
50 50
51#endif 51#endif
diff --git a/libopie2/examples/opieui/osplitter_example/osplitter_example.cpp b/libopie2/examples/opieui/osplitter_example/osplitter_example.cpp
index 7ba0f0d..4a1468d 100644
--- a/libopie2/examples/opieui/osplitter_example/osplitter_example.cpp
+++ b/libopie2/examples/opieui/osplitter_example/osplitter_example.cpp
@@ -1,32 +1,33 @@
1#include "osplitter_example.h" 1#include "osplitter_example.h"
2 2
3/* OPIE */ 3/* OPIE */
4 4
5#include <opie2/osplitter.h> 5#include <opie2/osplitter.h>
6#include <opie2/ofileselector.h>
6#include <qpe/qpeapplication.h> 7#include <qpe/qpeapplication.h>
7#include <opie2/oapplicationfactory.h> 8#include <opie2/oapplicationfactory.h>
8 9
9/* QT*/ 10/* QT*/
10#include <qdir.h> 11#include <qdir.h>
11#include <qlayout.h> 12#include <qlayout.h>
12 13
13using namespace Opie; 14using namespace Opie::Ui;
14 15
15OPIE_EXPORT_APP( OApplicationFactory<OSplitterExample> ) 16OPIE_EXPORT_APP( OApplicationFactory<OSplitterExample> )
16 17
17OSplitterExample::OSplitterExample( QWidget *w,const char* n,WFlags f ) 18OSplitterExample::OSplitterExample( QWidget *w,const char* n,WFlags f )
18 : QWidget( w, n, f ){ 19 : QWidget( w, n, f ){
19 QVBoxLayout * lay = new QVBoxLayout(this); 20 QVBoxLayout * lay = new QVBoxLayout(this);
20 OSplitter * splitter = new OSplitter( Horizontal, this ); 21 OSplitter * splitter = new OSplitter( Horizontal, this );
21 lay->addWidget( splitter ); 22 lay->addWidget( splitter );
22 23
23 OFileSelector *selector = new OFileSelector( splitter, OFileSelector::FileSelector, 24 OFileSelector *selector = new OFileSelector( splitter, OFileSelector::FileSelector,
24 OFileSelector::Normal, QDir::homeDirPath(), 25 OFileSelector::Normal, QDir::homeDirPath(),
25 QString::null ); 26 QString::null );
26 splitter->addWidget( selector, "zoom", tr("Selector 1") ); 27 splitter->addWidget( selector, "zoom", tr("Selector 1") );
27 28
28 selector = new OFileSelector( splitter, OFileSelector::FileSelector, OFileSelector::Normal, 29 selector = new OFileSelector( splitter, OFileSelector::FileSelector, OFileSelector::Normal,
29 QDir::homeDirPath(), QString::null ); 30 QDir::homeDirPath(), QString::null );
30 splitter->addWidget( selector, "zoom", tr("Selector 2") ); 31 splitter->addWidget( selector, "zoom", tr("Selector 2") );
31 32
32} 33}
diff --git a/libopie2/examples/opieui/osplitter_example/osplitter_example.h b/libopie2/examples/opieui/osplitter_example/osplitter_example.h
index 176ad62..0cf28aa 100644
--- a/libopie2/examples/opieui/osplitter_example/osplitter_example.h
+++ b/libopie2/examples/opieui/osplitter_example/osplitter_example.h
@@ -1,20 +1,19 @@
1/* 1/*
2 * May be used, copied and modified wihtout any limitation 2 * May be used, copied and modified wihtout any limitation
3 */ 3 */
4 4
5#ifndef OSPlitter_EXAMPLE_H 5#ifndef OSPlitter_EXAMPLE_H
6#define OSPlitter_EXAMPLE_H 6#define OSPlitter_EXAMPLE_H
7 7
8#include <qvbox.h> 8#include <qvbox.h>
9#include <opie2/ofileselector.h>
10 9
11class OSplitterExample : public QWidget { 10class OSplitterExample : public QWidget {
12 Q_OBJECT 11 Q_OBJECT
13public: 12public:
14 static QString appName() { return QString::fromLatin1("osplitter_example"); } 13 static QString appName() { return QString::fromLatin1("osplitter_example"); }
15 OSplitterExample( QWidget *parent, const char* name, WFlags fl ); 14 OSplitterExample( QWidget *parent, const char* name, WFlags fl );
16 15
17}; 16};
18 17
19 18
20#endif 19#endif
diff --git a/libopie2/examples/opieui/osplitter_example/osplitter_mail.cpp b/libopie2/examples/opieui/osplitter_example/osplitter_mail.cpp
index 789496c..6443dc0 100644
--- a/libopie2/examples/opieui/osplitter_example/osplitter_mail.cpp
+++ b/libopie2/examples/opieui/osplitter_example/osplitter_mail.cpp
@@ -1,79 +1,81 @@
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
12using namespace Opie::Ui;
13
12OPIE_EXPORT_APP( OApplicationFactory<ListViews> ) 14OPIE_EXPORT_APP( OApplicationFactory<ListViews> )
13 15
14class Folder { 16class Folder {
15 int dummy; 17 int dummy;
16}; 18};
17 19
18// ----------------------------------------------------------------- 20// -----------------------------------------------------------------
19 21
20ListViews::ListViews( QWidget* p, const char* name, WFlags fl ) 22ListViews::ListViews( QWidget* p, const char* name, WFlags fl )
21 : QWidget( p, name, fl ) { 23 : QWidget( p, name, fl ) {
22 qApp->installEventFilter( this ); 24 qApp->installEventFilter( this );
23 m_lstFolders.setAutoDelete( true ); 25 m_lstFolders.setAutoDelete( true );
24 QHBoxLayout *lay = new QHBoxLayout(this); 26 QHBoxLayout *lay = new QHBoxLayout(this);
25 27
26 m_splitter = new OSplitter( Horizontal, this, "SPlitter 1" ); 28 m_splitter = new OSplitter( Horizontal, this, "SPlitter 1" );
27 lay->addWidget( m_splitter ); 29 lay->addWidget( m_splitter );
28 connect(m_splitter, SIGNAL(sizeChange(bool,const QSize&) ), 30 connect(m_splitter, SIGNAL(sizeChanged(bool,Orientation) ),
29 this, SLOT(slotSizeChange(bool,const QSize&) ) ); 31 this, SLOT(slotSizeChange(bool,Orientation) ) );
30 32
31 m_overview = new QListView( m_splitter ); 33 m_overview = new QListView( m_splitter );
32 m_overview->header()->setClickEnabled( FALSE ); 34 m_overview->header()->setClickEnabled( FALSE );
33 m_overview->addColumn( tr("Folder") ); 35 m_overview->addColumn( tr("Folder") );
34 m_overview->setMaximumWidth( 200 ); 36// m_overview->setMaximumWidth( 200 );
35 m_splitter->addWidget( m_overview, "zoom", tr("Folder Overview") ); 37 m_splitter->addWidget( m_overview, "zoom", tr("Folder Overview") );
36 m_splitter->setSizeChange( 300 ); 38 m_splitter->setSizeChange( 300 );
37 39
38 /* OSplitter starts with the small mode */ 40 /* OSplitter starts with the small mode */
39 m_messages = 0; 41 m_messages = 0;
40 m_message = m_attach = 0; 42 m_message = m_attach = 0;
41 43
42 splitti = new OSplitter( Vertical, m_splitter, "Splitti2" ); 44 splitti = new OSplitter( Vertical, m_splitter, "Splitti2" );
43 splitti->setSizeChange( 300 ); 45 splitti->setSizeChange( 300 );
44 splitti->setSizePolicy( QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding ) ); 46 splitti->setSizePolicy( QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding ) );
45 47
46 QLabel *lbl = new QLabel(splitti); 48 QLabel *lbl = new QLabel(splitti);
47 lbl->setTextFormat ( Qt::RichText ); 49 lbl->setTextFormat ( Qt::RichText );
48 lbl->setText("<br><br><b>Test Test Test</b><br><br><p>Fooooo hjhh</p>"); 50 lbl->setText("<br><br><b>Test Test Test</b><br><br><p>Fooooo hjhh</p>");
49 51
50 m_messages = new QListView( splitti ); 52 m_messages = new QListView( splitti );
51 m_messages->addColumn(" Messages "); 53 m_messages->addColumn(" Messages ");
52 54
53 folder1 = new QListView( splitti ); 55 folder1 = new QListView( splitti );
54 folder1->addColumn( "Messages 2 " ); 56 folder1->addColumn( "Messages 2 " );
55 57
56 splitti->addWidget(m_messages, "mail", tr("Mails") ); 58 splitti->addWidget(m_messages, "mail", tr("Mails") );
57 splitti->addWidget(folder1, "folder", tr("Folder") ); 59 splitti->addWidget(folder1, "folder", tr("Folder") );
58 splitti->addWidget( lbl, "logo", tr("Label") ); 60 splitti->addWidget( lbl, "logo", tr("Label") );
59 m_message = lbl; 61 m_message = lbl;
60 62
61 m_splitter->addWidget( splitti ); 63 m_splitter->addWidget( splitti );
62 64
63} 65}
64 66
65 67
66ListViews::~ListViews() { 68ListViews::~ListViews() {
67 69
68} 70}
69 71
70 72
71bool ListViews::eventFilter( QObject* obj, QEvent* ev ) { 73bool ListViews::eventFilter( QObject* obj, QEvent* ev ) {
72 if (!obj->isWidgetType() ) 74 if (!obj->isWidgetType() )
73 return false; 75 return false;
74 if ( ev->type() == QEvent::MouseButtonRelease ) { 76 if ( ev->type() == QEvent::MouseButtonRelease ) {
75 qWarning(" name %s, class %s", obj->name(), obj->className() ); 77 qWarning(" name %s, class %s", obj->name(), obj->className() );
76 } 78 }
77 79
78 return false; 80 return false;
79} 81}
diff --git a/libopie2/examples/opieui/osplitter_example/osplitter_mail.h b/libopie2/examples/opieui/osplitter_example/osplitter_mail.h
index 1447a92..67961fb 100644
--- a/libopie2/examples/opieui/osplitter_example/osplitter_mail.h
+++ b/libopie2/examples/opieui/osplitter_example/osplitter_mail.h
@@ -1,53 +1,51 @@
1/* 1/*
2 * You may use, modify and distribute this code without any limitation 2 * You may use, modify and distribute this code without any limitation
3 */ 3 */
4 4
5/* 5/*
6 * Header file for a more complete email client like 6 * Header file for a more complete email client like
7 * layout 7 * layout
8 */ 8 */
9 9
10#ifndef OPIE_SPLITTER_MAIL_EXAMPLE_H 10#ifndef OPIE_SPLITTER_MAIL_EXAMPLE_H
11#define OPIE_SPLITTER_MAIL_EXAMPLE_H 11#define OPIE_SPLITTER_MAIL_EXAMPLE_H
12 12
13#include <qwidget.h> 13#include <qwidget.h>
14#include <qlist.h> 14#include <qlist.h>
15#include <qlistview.h> 15#include <qlistview.h>
16 16
17#include <opie2/osplitter.h> 17#include <opie2/osplitter.h>
18 18
19using Opie::OSplitter;
20 19
21class Folder; 20class Folder;
22class QLabel; 21class QLabel;
23 22
24class OSplitter;
25class ListViews : public QWidget { 23class ListViews : public QWidget {
26 Q_OBJECT 24 Q_OBJECT
27public: 25public:
28 static QString appName() { return QString::fromLatin1("osplitter-mail"); } 26 static QString appName() { return QString::fromLatin1("osplitter-mail"); }
29 ListViews( QWidget* parent, const char * name, WFlags fl ); 27 ListViews( QWidget* parent, const char * name, WFlags fl );
30 ~ListViews(); 28 ~ListViews();
31 29
32 bool eventFilter( QObject* , QEvent* ); 30 bool eventFilter( QObject* , QEvent* );
33private: 31private:
34 void initFolders(); 32 void initFolders();
35 void initFolder( Folder *folder, unsigned int &count ); 33 void initFolder( Folder *folder, unsigned int &count );
36 34
37 QListView *m_messages, *m_overview; 35 QListView *m_messages, *m_overview;
38 QLabel *m_message, *m_attach; 36 QLabel *m_message, *m_attach;
39 QList<QListView> m_folders; // used in tab mode 37 QList<QListView> m_folders; // used in tab mode
40 QList<Folder> m_lstFolders; 38 QList<Folder> m_lstFolders;
41 bool m_mode : 1; // bitfield 39 bool m_mode : 1; // bitfield
42 OSplitter *m_splitter; 40 Opie::Ui::OSplitter *m_splitter;
43 OSplitter *splitti; 41 Opie::Ui::OSplitter *splitti;
44 QListView *folder1; 42 QListView *folder1;
45#if 0 43#if 0
46//private slots: 44//private slots:
47// void slotFolderChanged( QListViewItem* ); 45// void slotFolderChanged( QListViewItem* );
48// void slotMessageChanged(); 46// void slotMessageChanged();
49// void slotSizeChange( bool, const QSize& ); 47// void slotSizeChange( bool, const QSize& );
50#endif 48#endif
51}; 49};
52 50
53#endif 51#endif
diff --git a/libopie2/examples/opieui/oversatileviewdemo/main.cpp b/libopie2/examples/opieui/oversatileviewdemo/main.cpp
index d8c01a4..bcda14c 100644
--- a/libopie2/examples/opieui/oversatileviewdemo/main.cpp
+++ b/libopie2/examples/opieui/oversatileviewdemo/main.cpp
@@ -1,29 +1,32 @@
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#include "opieuidemo.h" 16#include "opieuidemo.h"
17 17
18#include <opie2/oapplication.h> 18#include <opie2/oapplication.h>
19 19
20using namespace Opie::Core;
21using namespace Opie::Ui;
22
20int main( int argc, char **argv ) 23int main( int argc, char **argv )
21{ 24{
22 OApplication a( argc, argv, "Opie UI Demo" ); 25 OApplication a( argc, argv, "Opie UI Demo" );
23 qDebug( "." ); 26 qDebug( "." );
24 OpieUIDemo e; 27 OpieUIDemo e;
25 qDebug( "." ); 28 qDebug( "." );
26 a.showMainWidget(&e); 29 a.showMainWidget(&e);
27 qDebug( "." ); 30 qDebug( "." );
28 return a.exec(); 31 return a.exec();
29} 32}
diff --git a/libopie2/examples/opieui/oversatileviewdemo/opieuidemo.cpp b/libopie2/examples/opieui/oversatileviewdemo/opieuidemo.cpp
index 0d8bc9f..754a744 100644
--- a/libopie2/examples/opieui/oversatileviewdemo/opieuidemo.cpp
+++ b/libopie2/examples/opieui/oversatileviewdemo/opieuidemo.cpp
@@ -1,101 +1,99 @@
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
29#include <qpe/qpeapplication.h> 28#include <qpe/qpeapplication.h>
30#include <qpe/global.h> 29#include <qpe/global.h>
31#endif
32 30
33// Opie 31// Opie
34 32
35#ifdef QWS
36#include <opie2/odevice.h> 33#include <opie2/odevice.h>
37using namespace Opie;
38#endif
39 34
40#include <opie2/ocompletionbox.h> 35#include <opie2/ocompletionbox.h>
41#include <opie2/olineedit.h> 36#include <opie2/olineedit.h>
42#include <opie2/ocombobox.h> 37#include <opie2/ocombobox.h>
43#include <opie2/oeditlistbox.h> 38#include <opie2/oeditlistbox.h>
44#include <opie2/oselector.h> 39#include <opie2/oselector.h>
45#include <opie2/opopupmenu.h> 40#include <opie2/opopupmenu.h>
46 41
47#include <qtabwidget.h> 42#include <qtabwidget.h>
48#include "oversatileviewdemo.h" 43#include "oversatileviewdemo.h"
49 44
50// Local 45// Local
51 46
52#include "opieuidemo.h" 47#include "opieuidemo.h"
53 48
49using namespace Opie::Core;
50using namespace Opie::Ui;
51
54enum Demos { ocompletionbox, olineedit, ocombobox, oeditlistbox, oselector }; 52enum Demos { ocompletionbox, olineedit, ocombobox, oeditlistbox, oselector };
55 53
56OpieUIDemo::OpieUIDemo( QWidget* parent, const char* name, WFlags fl ) 54OpieUIDemo::OpieUIDemo( QWidget* parent, const char* name, WFlags fl )
57 : QMainWindow( parent, name, fl ) 55 : QMainWindow( parent, name, fl )
58{ 56{
59 57
60 QMenuBar* mbar = this->menuBar(); 58 QMenuBar* mbar = this->menuBar();
61 OPopupMenu* demo = new OPopupMenu( this ); 59 OPopupMenu* demo = new OPopupMenu( this );
62 demo->setTitle( "Title" ); 60 demo->setTitle( "Title" );
63 demo->setItemParameter( demo->insertItem( "OCompletionBox", this, SLOT( demo(int) ) ), ocompletionbox ); 61 demo->setItemParameter( demo->insertItem( "OCompletionBox", this, SLOT( demo(int) ) ), ocompletionbox );
64 demo->setItemParameter( demo->insertItem( "OLineEdit", this, SLOT( demo(int) ) ), olineedit ); 62 demo->setItemParameter( demo->insertItem( "OLineEdit", this, SLOT( demo(int) ) ), olineedit );
65 demo->setItemParameter( demo->insertItem( "OComboBox", this, SLOT( demo(int) ) ), ocombobox ); 63 demo->setItemParameter( demo->insertItem( "OComboBox", this, SLOT( demo(int) ) ), ocombobox );
66 demo->setItemParameter( demo->insertItem( "OEditListBox", this, SLOT( demo(int) ) ), oeditlistbox ); 64 demo->setItemParameter( demo->insertItem( "OEditListBox", this, SLOT( demo(int) ) ), oeditlistbox );
67 demo->setItemParameter( demo->insertItem( "OSelector", this, SLOT( demo(int) ) ), oselector ); 65 demo->setItemParameter( demo->insertItem( "OSelector", this, SLOT( demo(int) ) ), oselector );
68 mbar->insertItem( "Demonstrate", demo ); 66 mbar->insertItem( "Demonstrate", demo );
69 67
70 build(); 68 build();
71 69
72} 70}
73 71
74OpieUIDemo::~OpieUIDemo() 72OpieUIDemo::~OpieUIDemo()
75{ 73{
76} 74}
77 75
78void OpieUIDemo::build() 76void OpieUIDemo::build()
79{ 77{
80 main = new QTabWidget( this, "tabwidget" ); 78 main = new QTabWidget( this, "tabwidget" );
81 setCentralWidget( main ); 79 setCentralWidget( main );
82 main->show(); 80 main->show();
83 81
84 main->addTab( new OVersatileViewDemo( main ), "VersatileView" ); 82 main->addTab( new OVersatileViewDemo( main ), "VersatileView" );
85} 83}
86 84
87 85
88void OpieUIDemo::demo( int d ) 86void OpieUIDemo::demo( int d )
89{ 87{
90 switch (d) 88 switch (d)
91 { 89 {
92 case ocompletionbox: demoOCompletionBox(); break; 90 case ocompletionbox: demoOCompletionBox(); break;
93 case olineedit: demoOLineEdit(); break; 91 case olineedit: demoOLineEdit(); break;
94 case ocombobox: demoOComboBox(); break; 92 case ocombobox: demoOComboBox(); break;
95 case oeditlistbox: demoOEditListBox(); break; 93 case oeditlistbox: demoOEditListBox(); break;
96 case oselector: demoOSelector(); break; 94 case oselector: demoOSelector(); break;
97 95
98 } 96 }
99 97
100} 98}
101 99
diff --git a/libopie2/examples/opieui/oversatileviewdemo/opieuidemo.h b/libopie2/examples/opieui/oversatileviewdemo/opieuidemo.h
index 0519ae6..382885f 100644
--- a/libopie2/examples/opieui/oversatileviewdemo/opieuidemo.h
+++ b/libopie2/examples/opieui/oversatileviewdemo/opieuidemo.h
@@ -1,56 +1,60 @@
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#ifndef OPIEUIDEMO_H 16#ifndef OPIEUIDEMO_H
17#define OPIEUIDEMO_H 17#define OPIEUIDEMO_H
18 18
19#include <qmainwindow.h> 19#include <qmainwindow.h>
20 20
21namespace Opie {
22namespace Ui {
21class OVersatileView; 23class OVersatileView;
24}
25}
22class QTabWidget; 26class QTabWidget;
23class QVBox; 27class QVBox;
24 28
25class OpieUIDemo : public QMainWindow { 29class OpieUIDemo : public QMainWindow {
26 Q_OBJECT 30 Q_OBJECT
27 31
28public: 32public:
29 33
30 OpieUIDemo( QWidget* parent = 0, const char* name = 0, WFlags fl = WType_TopLevel ); 34 OpieUIDemo( QWidget* parent = 0, const char* name = 0, WFlags fl = WType_TopLevel );
31 ~OpieUIDemo(); 35 ~OpieUIDemo();
32 36
33 void demoOCompletionBox(); 37 void demoOCompletionBox();
34 void demoOLineEdit(); 38 void demoOLineEdit();
35 void demoOComboBox(); 39 void demoOComboBox();
36 void demoOEditListBox(); 40 void demoOEditListBox();
37 void demoOSelector(); 41 void demoOSelector();
38 42
39public slots: 43public slots:
40 void demo( int ); 44 void demo( int );
41 void messageBox( const QString& text ); 45 void messageBox( const QString& text );
42 46
43protected: 47protected:
44 void build(); 48 void build();
45 void buildVV( QVBox* b ); 49 void buildVV( QVBox* b );
46 50
47private: 51private:
48 QTabWidget* main; 52 QTabWidget* main;
49 53
50 OVersatileView* vv; 54 Opie::Ui::OVersatileView* vv;
51 55
52}; 56};
53 57
54 58
55 59
56#endif 60#endif
diff --git a/libopie2/examples/opieui/oversatileviewdemo/oversatileviewdemo.cpp b/libopie2/examples/opieui/oversatileviewdemo/oversatileviewdemo.cpp
index 9db4e62..b6d59aa 100644
--- a/libopie2/examples/opieui/oversatileviewdemo/oversatileviewdemo.cpp
+++ b/libopie2/examples/opieui/oversatileviewdemo/oversatileviewdemo.cpp
@@ -1,88 +1,90 @@
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
41using namespace Opie::Ui;
42
41OVersatileViewDemo::OVersatileViewDemo( QWidget* parent, const char* name, WFlags f ) 43OVersatileViewDemo::OVersatileViewDemo( QWidget* parent, const char* name, WFlags f )
42 :QVBox( parent, name, f ) 44 :QVBox( parent, name, f )
43{ 45{
44 vv = new OVersatileView( this ); 46 vv = new OVersatileView( this );
45 47
46 vv->addColumn( "First" ); 48 vv->addColumn( "First" );
47 vv->addColumn( "2nd" ); 49 vv->addColumn( "2nd" );
48 vv->addColumn( "IIIrd" ); 50 vv->addColumn( "IIIrd" );
49 51
50 QString counter; 52 QString counter;
51 53
52 QPixmap leaf( "leaf.png" ); 54 QPixmap leaf( "leaf.png" );
53 QPixmap opened( "folder_opened.png" ); 55 QPixmap opened( "folder_opened.png" );
54 QPixmap closed( "folder_closed.png" ); 56 QPixmap closed( "folder_closed.png" );
55 57
56 QPixmap leaf32( "leaf32.png" ); 58 QPixmap leaf32( "leaf32.png" );
57 QPixmap opened32( "folder_opened32.png" ); 59 QPixmap opened32( "folder_opened32.png" );
58 QPixmap closed32( "folder_closed32.png" ); 60 QPixmap closed32( "folder_closed32.png" );
59 61
60 vv->setDefaultPixmaps( OVersatileView::Tree, leaf, opened, closed ); 62 vv->setDefaultPixmaps( OVersatileView::Tree, leaf, opened, closed );
61 vv->setDefaultPixmaps( OVersatileView::Icons, leaf32, opened32, closed32 ); 63 vv->setDefaultPixmaps( OVersatileView::Icons, leaf32, opened32, closed32 );
62 64
63 OVersatileViewItem* item; 65 OVersatileViewItem* item;
64 OVersatileViewItem* item2; 66 OVersatileViewItem* item2;
65 67
66 for ( int i = 0; i < 5; ++i ) 68 for ( int i = 0; i < 5; ++i )
67 { 69 {
68 counter.sprintf( "%d", i ); 70 counter.sprintf( "%d", i );
69 item = new OVersatileViewItem( vv, "Item", "Text", "Some more", counter ); 71 item = new OVersatileViewItem( vv, "Item", "Text", "Some more", counter );
70 item->setRenameEnabled( true ); 72 item->setRenameEnabled( true );
71 item2 = new OVersatileViewItem( item, "OSubitem", "123", "...", counter ); 73 item2 = new OVersatileViewItem( item, "OSubitem", "123", "...", counter );
72 item2->setRenameEnabled( true ); 74 item2->setRenameEnabled( true );
73 75
74 } 76 }
75 77
76 connect( vv, SIGNAL( selectionChanged() ), this, SLOT( selectionChanged() ) ); 78 connect( vv, SIGNAL( selectionChanged() ), this, SLOT( selectionChanged() ) );
77 connect( vv, SIGNAL( selectionChanged(OVersatileViewItem*) ), this, SLOT( selectionChanged(OVersatileViewItem*) ) ); 79 connect( vv, SIGNAL( selectionChanged(OVersatileViewItem*) ), this, SLOT( selectionChanged(OVersatileViewItem*) ) );
78 connect( vv, SIGNAL( currentChanged(OVersatileViewItem*) ), this, SLOT( currentChanged(OVersatileViewItem*) ) ); 80 connect( vv, SIGNAL( currentChanged(OVersatileViewItem*) ), this, SLOT( currentChanged(OVersatileViewItem*) ) );
79 connect( vv, SIGNAL( clicked(OVersatileViewItem*) ), this, SLOT( clicked(OVersatileViewItem*) ) ); 81 connect( vv, SIGNAL( clicked(OVersatileViewItem*) ), this, SLOT( clicked(OVersatileViewItem*) ) );
80 connect( vv, SIGNAL( pressed(OVersatileViewItem*) ), this, SLOT( pressed(OVersatileViewItem*) ) ); 82 connect( vv, SIGNAL( pressed(OVersatileViewItem*) ), this, SLOT( pressed(OVersatileViewItem*) ) );
81 83
82 connect( vv, SIGNAL( doubleClicked(OVersatileViewItem*) ), this, SLOT( doubleClicked(OVersatileViewItem*) ) ); 84 connect( vv, SIGNAL( doubleClicked(OVersatileViewItem*) ), this, SLOT( doubleClicked(OVersatileViewItem*) ) );
83 connect( vv, SIGNAL( returnPressed(OVersatileViewItem*) ), this, SLOT( returnPressed(OVersatileViewItem*) ) ); 85 connect( vv, SIGNAL( returnPressed(OVersatileViewItem*) ), this, SLOT( returnPressed(OVersatileViewItem*) ) );
84 86
85 connect( vv, SIGNAL( onItem(OVersatileViewItem*) ), this, SLOT( onItem(OVersatileViewItem*) ) ); 87 connect( vv, SIGNAL( onItem(OVersatileViewItem*) ), this, SLOT( onItem(OVersatileViewItem*) ) );
86 connect( vv, SIGNAL( onViewport() ), this, SLOT( onViewport() ) ); 88 connect( vv, SIGNAL( onViewport() ), this, SLOT( onViewport() ) );
87 89
88 connect( vv, SIGNAL( expanded(OVersatileViewItem*) ), this, SLOT( expanded(OVersatileViewItem*) ) ); 90 connect( vv, SIGNAL( expanded(OVersatileViewItem*) ), this, SLOT( expanded(OVersatileViewItem*) ) );
diff --git a/libopie2/examples/opieui/oversatileviewdemo/oversatileviewdemo.h b/libopie2/examples/opieui/oversatileviewdemo/oversatileviewdemo.h
index 79318d0..35e2c3c 100644
--- a/libopie2/examples/opieui/oversatileviewdemo/oversatileviewdemo.h
+++ b/libopie2/examples/opieui/oversatileviewdemo/oversatileviewdemo.h
@@ -1,73 +1,77 @@
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 <mickey@tm.informatik.uni-frankfurt.de> 4              Copyright (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
5 =. 5 =.
6 .=l. 6 .=l.
7           .>+-= 7           .>+-=
8 _;:,     .>    :=|. This program is free software; you can 8 _;:,     .>    :=|. This program is free software; you can
9.> <`_,   >  .   <= redistribute it and/or modify it under 9.> <`_,   >  .   <= redistribute it and/or modify it under
10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
11.="- .-=="i,     .._ License as published by the Free Software 11.="- .-=="i,     .._ License as published by the Free Software
12 - .   .-<_>     .<> Foundation; either version 2 of the License, 12 - .   .-<_>     .<> Foundation; either version 2 of the License,
13     ._= =}       : or (at your option) any later version. 13     ._= =}       : or (at your option) any later version.
14    .%`+i>       _;_. 14    .%`+i>       _;_.
15    .i_,=:_.      -<s. This program is distributed in the hope that 15    .i_,=:_.      -<s. This program is distributed in the hope that
16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
17    : ..    .:,     . . . without even the implied warranty of 17    : ..    .:,     . . . without even the implied warranty of
18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.=       =       ; Library General Public License for more 20..}^=.=       =       ; Library General Public License for more
21++=   -.     .`     .: details. 21++=   -.     .`     .: details.
22 :     =  ...= . :.=- 22 :     =  ...= . :.=-
23 -.   .:....=;==+<; You should have received a copy of the GNU 23 -.   .:....=;==+<; You should have received a copy of the GNU
24  -_. . .   )=.  = Library General Public License along with 24  -_. . .   )=.  = Library General Public License along with
25    --        :-=` this library; see the file COPYING.LIB. 25    --        :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation, 26 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330, 27 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA. 28 Boston, MA 02111-1307, USA.
29 29
30*/ 30*/
31 31
32#ifndef OVERSATILEVIEWDEMO_H 32#ifndef OVERSATILEVIEWDEMO_H
33#define OVERSATILEVIEWDEMO_H 33#define OVERSATILEVIEWDEMO_H
34 34
35#include <qvbox.h> 35#include <qvbox.h>
36 36
37namespace Opie {
38namespace Ui {
37class OVersatileView; 39class OVersatileView;
38class OVersatileViewItem; 40class OVersatileViewItem;
41}
42}
39 43
40class OVersatileViewDemo: public QVBox 44class OVersatileViewDemo: public QVBox
41{ 45{
42 Q_OBJECT 46 Q_OBJECT
43 47
44 public: 48 public:
45 OVersatileViewDemo( QWidget* parent=0, const char* name=0, WFlags f=0 ); 49 OVersatileViewDemo( QWidget* parent=0, const char* name=0, WFlags f=0 );
46 virtual ~OVersatileViewDemo(); 50 virtual ~OVersatileViewDemo();
47 51
48 public slots: 52 public slots:
49 void selectionChanged(); 53 void selectionChanged();
50 void selectionChanged( OVersatileViewItem * ); 54 void selectionChanged( Opie::Ui::OVersatileViewItem * );
51 void currentChanged( OVersatileViewItem * ); 55 void currentChanged( Opie::Ui::OVersatileViewItem * );
52 void clicked( OVersatileViewItem * ); 56 void clicked( Opie::Ui::OVersatileViewItem * );
53 void pressed( OVersatileViewItem * ); 57 void pressed( OPie::Ui::OVersatileViewItem * );
54 58
55 void doubleClicked( OVersatileViewItem *item ); 59 void doubleClicked( Opie::Ui::OVersatileViewItem *item );
56 void returnPressed( OVersatileViewItem *item ); 60 void returnPressed( Opie::Ui::OVersatileViewItem *item );
57 61
58 void onItem( OVersatileViewItem *item ); 62 void onItem( Opie::Ui::OVersatileViewItem *item );
59 void onViewport(); 63 void onViewport();
60 64
61 void expanded( OVersatileViewItem *item ); 65 void expanded( Opie::Ui::OVersatileViewItem *item );
62 void collapsed( OVersatileViewItem *item ); 66 void collapsed( Opie::Ui::OVersatileViewItem *item );
63 67
64 void moved(); 68 void moved();
65 69
66 void contextMenuRequested( OVersatileViewItem *item, const QPoint&, int col ); 70 void contextMenuRequested( Opie::Ui::OVersatileViewItem *item, const QPoint&, int col );
67 71
68 private: 72 private:
69 OVersatileView* vv; 73 Opie::Ui::OVersatileView* vv;
70 74
71}; 75};
72 76
73#endif 77#endif
diff --git a/libopie2/examples/opieui/owidgetstack_example/owidgetstack_example.cpp b/libopie2/examples/opieui/owidgetstack_example/owidgetstack_example.cpp
index b1c5e70..50cc11b 100644
--- a/libopie2/examples/opieui/owidgetstack_example/owidgetstack_example.cpp
+++ b/libopie2/examples/opieui/owidgetstack_example/owidgetstack_example.cpp
@@ -1,70 +1,70 @@
1/* 1/*
2 * You may use, modify and distribute this example without any limitation 2 * You may use, modify and distribute this example without any limitation
3 */ 3 */
4 4
5#include "owidgetstack_example.h" 5#include "owidgetstack_example.h"
6 6
7/* OPIE */ 7/* OPIE */
8#include <opie2/oapplicationfactory.h> 8#include <opie2/oapplicationfactory.h>
9#include <opie2/owidgetstack.h> 9#include <opie2/owidgetstack.h>
10#include <qpe/resource.h> 10#include <qpe/resource.h>
11 11
12/* QT */ 12/* QT */
13#include <qaction.h> 13#include <qaction.h>
14#include <qtoolbar.h> 14#include <qtoolbar.h>
15#include <qpopupmenu.h> 15#include <qpopupmenu.h>
16#include <qmenubar.h> 16#include <qmenubar.h>
17#include <qlayout.h> 17#include <qlayout.h>
18#include <qlabel.h> 18#include <qlabel.h>
19#include <qpushbutton.h> 19#include <qpushbutton.h>
20#include <qsignalmapper.h> 20#include <qsignalmapper.h>
21 21
22using namespace Opie; 22using namespace Opie::Ui;
23 23
24OPIE_EXPORT_APP( OApplicationFactory<StackExample> ) 24OPIE_EXPORT_APP( OApplicationFactory<StackExample> )
25 25
26StackExample::StackExample( QWidget* parent, const char* name, WFlags fl ) 26StackExample::StackExample( QWidget* parent, const char* name, WFlags fl )
27 : QMainWindow( parent, name, fl ) 27 : QMainWindow( parent, name, fl )
28{ 28{
29 m_stack = new OWidgetStack( this ); 29 m_stack = new OWidgetStack( this );
30 setCentralWidget( m_stack ); 30 setCentralWidget( m_stack );
31 31
32 /* nice Signal Mapper ;) */ 32 /* nice Signal Mapper ;) */
33 QSignalMapper *sm = new QSignalMapper(this); 33 QSignalMapper *sm = new QSignalMapper(this);
34 connect(sm, SIGNAL(mapped(int) ), m_stack, SLOT(raiseWidget(int)) ); 34 connect(sm, SIGNAL(mapped(int) ), m_stack, SLOT(raiseWidget(int)) );
35 35
36 /* toolbar first but this should be known from the other examples */ 36 /* toolbar first but this should be known from the other examples */
37 setToolBarsMovable( false ); 37 setToolBarsMovable( false );
38 38
39 /* only a menubar here */ 39 /* only a menubar here */
40 QToolBar* holder = new QToolBar( this ); 40 QToolBar* holder = new QToolBar( this );
41 holder->setHorizontalStretchable( true ); 41 holder->setHorizontalStretchable( true );
42 42
43 QMenuBar *bar = new QMenuBar( holder ); 43 QMenuBar *bar = new QMenuBar( holder );
44 QPopupMenu *menu = new QPopupMenu( this ); 44 QPopupMenu *menu = new QPopupMenu( this );
45 45
46 QAction* a = new QAction( tr("Show MainWidget"), Resource::loadPixmap("zoom"), 46 QAction* a = new QAction( tr("Show MainWidget"), Resource::loadPixmap("zoom"),
47 QString::null, 0, this, 0 ); 47 QString::null, 0, this, 0 );
48 sm->setMapping(a, 1 ); 48 sm->setMapping(a, 1 );
49 connect(a, SIGNAL(activated() ), 49 connect(a, SIGNAL(activated() ),
50 sm, SLOT(map() ) ); 50 sm, SLOT(map() ) );
51 a->addTo( menu ); 51 a->addTo( menu );
52 52
53 a = new QAction( tr("Show Details Small"), Resource::loadPixmap("zoom"), 53 a = new QAction( tr("Show Details Small"), Resource::loadPixmap("zoom"),
54 QString::null, 0, this, 0 ); 54 QString::null, 0, this, 0 );
55 sm->setMapping(a, 2 ); 55 sm->setMapping(a, 2 );
56 connect(a, SIGNAL(activated() ), 56 connect(a, SIGNAL(activated() ),
57 sm, SLOT(map() ) ); 57 sm, SLOT(map() ) );
58 a->addTo( menu ); 58 a->addTo( menu );
59 59
60 a = new QAction( tr("Show Details More"), Resource::loadPixmap("zoom"), 60 a = new QAction( tr("Show Details More"), Resource::loadPixmap("zoom"),
61 QString::null, 0, this, 0 ); 61 QString::null, 0, this, 0 );
62 sm->setMapping(a, 3 ); 62 sm->setMapping(a, 3 );
63 connect(a, SIGNAL(activated() ), 63 connect(a, SIGNAL(activated() ),
64 sm, SLOT(map() ) ); 64 sm, SLOT(map() ) );
65 a->addTo( menu ); 65 a->addTo( menu );
66 66
67 a = new QAction( tr("Show Details All"), Resource::loadPixmap("zoom"), 67 a = new QAction( tr("Show Details All"), Resource::loadPixmap("zoom"),
68 QString::null, 0, this, 0 ); 68 QString::null, 0, this, 0 );
69 sm->setMapping(a, 4 ); 69 sm->setMapping(a, 4 );
70 connect(a, SIGNAL(activated() ), 70 connect(a, SIGNAL(activated() ),
diff --git a/libopie2/examples/opieui/owidgetstack_example/owidgetstack_example.h b/libopie2/examples/opieui/owidgetstack_example/owidgetstack_example.h
index aea85cb..c9b70cb 100644
--- a/libopie2/examples/opieui/owidgetstack_example/owidgetstack_example.h
+++ b/libopie2/examples/opieui/owidgetstack_example/owidgetstack_example.h
@@ -1,28 +1,27 @@
1/* 1/*
2 * You may use, modify and distribute this example without any limitation 2 * You may use, modify and distribute this example without any limitation
3 */ 3 */
4 4
5#ifndef O_STACK_EXAMPLE_SIMPLE_H 5#ifndef O_STACK_EXAMPLE_SIMPLE_H
6#define O_STACK_EXAMPLE_SIMPLE_H 6#define O_STACK_EXAMPLE_SIMPLE_H
7 7
8#include <qmainwindow.h> 8#include <qmainwindow.h>
9#include <opie2/owidgetstack.h> 9#include <opie2/owidgetstack.h>
10 10
11using namespace Opie;
12 11
13class StackExample : public QMainWindow { 12class StackExample : public QMainWindow {
14 Q_OBJECT 13 Q_OBJECT
15public: 14public:
16 StackExample( QWidget* paren, const char* name, WFlags fl ); 15 StackExample( QWidget* paren, const char* name, WFlags fl );
17 ~StackExample(); 16 ~StackExample();
18 static QString appName() { return QString::fromLatin1("owidgetstack-example"); } 17 static QString appName() { return QString::fromLatin1("owidgetstack-example"); }
19 18
20protected: 19protected:
21 void closeEvent( QCloseEvent* e ); 20 void closeEvent( QCloseEvent* e );
22private: 21private:
23 OWidgetStack* m_stack; 22 Opie::Ui::OWidgetStack* m_stack;
24 QWidget* m_main; 23 QWidget* m_main;
25 24
26}; 25};
27 26
28#endif 27#endif
diff --git a/libopie2/opiecore/device/odevice.cpp b/libopie2/opiecore/device/odevice.cpp
index 27b0e53..f3e2cfb 100644
--- a/libopie2/opiecore/device/odevice.cpp
+++ b/libopie2/opiecore/device/odevice.cpp
@@ -15,122 +15,122 @@ _;:, .> :=|. This program is free software; you can
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::Core;
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 Private::Zaurus();
85 else if ( line.contains( "ipaq", false ) ) dev = new iPAQ(); 85 else if ( line.contains( "ipaq", false ) ) dev = new Private::iPAQ();
86 else if ( line.contains( "simpad", false ) ) dev = new SIMpad(); 86 else if ( line.contains( "simpad", false ) ) dev = new Private::SIMpad();
87 else if ( line.contains( "jornada", false ) ) dev = new Jornada(); 87 else if ( line.contains( "jornada", false ) ) dev = new Private::Jornada();
88 else if ( line.contains( "ramses", false ) ) dev = new Ramses(); 88 else if ( line.contains( "ramses", false ) ) dev = new Private::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*/
@@ -142,97 +142,97 @@ void ODevice::initButtons()
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;
@@ -579,50 +579,53 @@ void ODevice::remapPressedAction ( int button, const OQCopMessage &action )
579{ 579{
580 initButtons(); 580 initButtons();
581 581
582 QString mb_chan; 582 QString mb_chan;
583 583
584 if ( button >= (int) d->m_buttons->count()) 584 if ( button >= (int) d->m_buttons->count())
585 return; 585 return;
586 586
587 ODeviceButton &b = ( *d->m_buttons ) [button]; 587 ODeviceButton &b = ( *d->m_buttons ) [button];
588 b. setPressedAction ( action ); 588 b. setPressedAction ( action );
589 589
590 mb_chan=b. pressedAction(). channel(); 590 mb_chan=b. pressedAction(). channel();
591 591
592 Config buttonFile ( "ButtonSettings" ); 592 Config buttonFile ( "ButtonSettings" );
593 buttonFile. setGroup ( "Button" + QString::number ( button )); 593 buttonFile. setGroup ( "Button" + QString::number ( button ));
594 buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan); 594 buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan);
595 buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction(). message()); 595 buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction(). message());
596 596
597 //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction(). data())); 597 //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction(). data()));
598 598
599 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); 599 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
600} 600}
601 601
602void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) 602void ODevice::remapHeldAction ( int button, const OQCopMessage &action )
603{ 603{
604 initButtons(); 604 initButtons();
605 605
606 if ( button >= (int) d->m_buttons->count()) 606 if ( button >= (int) d->m_buttons->count())
607 return; 607 return;
608 608
609 ODeviceButton &b = ( *d->m_buttons ) [button]; 609 ODeviceButton &b = ( *d->m_buttons ) [button];
610 b. setHeldAction ( action ); 610 b. setHeldAction ( action );
611 611
612 Config buttonFile ( "ButtonSettings" ); 612 Config buttonFile ( "ButtonSettings" );
613 buttonFile. setGroup ( "Button" + QString::number ( button )); 613 buttonFile. setGroup ( "Button" + QString::number ( button ));
614 buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction(). channel()); 614 buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction(). channel());
615 buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction(). message()); 615 buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction(). message());
616 616
617 //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction(). data())); 617 //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction(). data()));
618 618
619 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); 619 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
620} 620}
621void ODevice::virtual_hook(int, void* ){ 621void ODevice::virtual_hook(int, void* ){
622 622
623} 623}
624 624
625void ODevice::sendSuspendmsg() 625void ODevice::sendSuspendmsg()
626{ 626{
627 if ( isQWS() )
628 return;
629
627 QCopEnvelope ( "QPE/System", "aboutToSuspend()" ); 630 QCopEnvelope ( "QPE/System", "aboutToSuspend()" );
628} 631}
diff --git a/libopie2/opiecore/device/odevice.h b/libopie2/opiecore/device/odevice.h
index bccb449..5ee9cca 100644
--- a/libopie2/opiecore/device/odevice.h
+++ b/libopie2/opiecore/device/odevice.h
@@ -1,92 +1,93 @@
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#ifndef ODEVICE_H_ 30#ifndef ODEVICE_H_
31#define ODEVICE_H_ 31#define ODEVICE_H_
32 32
33/* OPIE */ 33/* OPIE */
34#include <opie2/odevicebutton.h> 34#include <opie2/odevicebutton.h>
35#include <qpe/qpeapplication.h> /* for Transformation enum.. */ 35#include <qpe/qpeapplication.h> /* for Transformation enum.. */
36 36
37/* QT */ 37/* QT */
38#include <qnamespace.h> 38#include <qnamespace.h>
39#include <qobject.h> 39#include <qobject.h>
40#include <qstring.h> 40#include <qstring.h>
41#include <qstrlist.h> 41#include <qstrlist.h>
42 42
43namespace Opie 43namespace Opie{
44{ 44namespace Core{
45
45 class ODeviceData; 46 class ODeviceData;
46/** 47/**
47 * The available devices 48 * The available devices
48 */ 49 */
49enum OModel { 50enum OModel {
50 Model_Unknown, // = 0 51 Model_Unknown, // = 0
51 52
52 Model_Series_Mask = 0xff000000, 53 Model_Series_Mask = 0xff000000,
53 54
54 Model_iPAQ = ( 1 << 24 ), 55 Model_iPAQ = ( 1 << 24 ),
55 56
56 Model_iPAQ_All = ( Model_iPAQ | 0xffffff ), 57 Model_iPAQ_All = ( Model_iPAQ | 0xffffff ),
57 Model_iPAQ_H31xx = ( Model_iPAQ | 0x000001 ), 58 Model_iPAQ_H31xx = ( Model_iPAQ | 0x000001 ),
58 Model_iPAQ_H36xx = ( Model_iPAQ | 0x000002 ), 59 Model_iPAQ_H36xx = ( Model_iPAQ | 0x000002 ),
59 Model_iPAQ_H37xx = ( Model_iPAQ | 0x000004 ), 60 Model_iPAQ_H37xx = ( Model_iPAQ | 0x000004 ),
60 Model_iPAQ_H38xx = ( Model_iPAQ | 0x000008 ), 61 Model_iPAQ_H38xx = ( Model_iPAQ | 0x000008 ),
61 Model_iPAQ_H39xx = ( Model_iPAQ | 0x000010 ), 62 Model_iPAQ_H39xx = ( Model_iPAQ | 0x000010 ),
62 Model_iPAQ_H5xxx = ( Model_iPAQ | 0x000011 ), 63 Model_iPAQ_H5xxx = ( Model_iPAQ | 0x000011 ),
63 64
64 Model_Jornada = ( 6 << 24 ), 65 Model_Jornada = ( 6 << 24 ),
65 Model_Jornada_56x = ( Model_Jornada | 0x000001 ), 66 Model_Jornada_56x = ( Model_Jornada | 0x000001 ),
66 67
67 Model_Zaurus = ( 2 << 24 ), 68 Model_Zaurus = ( 2 << 24 ),
68 69
69 Model_Zaurus_SL5000 = ( Model_Zaurus | 0x000001 ), 70 Model_Zaurus_SL5000 = ( Model_Zaurus | 0x000001 ),
70 Model_Zaurus_SL5500 = ( Model_Zaurus | 0x000002 ), 71 Model_Zaurus_SL5500 = ( Model_Zaurus | 0x000002 ),
71 Model_Zaurus_SLA300 = ( Model_Zaurus | 0x000003 ), 72 Model_Zaurus_SLA300 = ( Model_Zaurus | 0x000003 ),
72 Model_Zaurus_SLB600 = ( Model_Zaurus | 0x000004 ), 73 Model_Zaurus_SLB600 = ( Model_Zaurus | 0x000004 ),
73 Model_Zaurus_SLC7x0 = ( Model_Zaurus | 0x000005 ), 74 Model_Zaurus_SLC7x0 = ( Model_Zaurus | 0x000005 ),
74 75
75 Model_SIMpad = ( 3 << 24 ), 76 Model_SIMpad = ( 3 << 24 ),
76 77
77 Model_SIMpad_All = ( Model_SIMpad | 0xffffff ), 78 Model_SIMpad_All = ( Model_SIMpad | 0xffffff ),
78 Model_SIMpad_CL4 = ( Model_SIMpad | 0x000001 ), 79 Model_SIMpad_CL4 = ( Model_SIMpad | 0x000001 ),
79 Model_SIMpad_SL4 = ( Model_SIMpad | 0x000002 ), 80 Model_SIMpad_SL4 = ( Model_SIMpad | 0x000002 ),
80 Model_SIMpad_SLC = ( Model_SIMpad | 0x000004 ), 81 Model_SIMpad_SLC = ( Model_SIMpad | 0x000004 ),
81 Model_SIMpad_TSinus = ( Model_SIMpad | 0x000008 ), 82 Model_SIMpad_TSinus = ( Model_SIMpad | 0x000008 ),
82 83
83 Model_Ramses = ( 4 << 24 ), 84 Model_Ramses = ( 4 << 24 ),
84 85
85 Model_Ramses_All = ( Model_Ramses | 0xffffff ), 86 Model_Ramses_All = ( Model_Ramses | 0xffffff ),
86 Model_Ramses_MNCI = ( Model_Ramses | 0x000001 ), 87 Model_Ramses_MNCI = ( Model_Ramses | 0x000001 ),
87 88
88 Model_Yopy = ( 5 << 24 ), 89 Model_Yopy = ( 5 << 24 ),
89 90
90 Model_Yopy_All = ( Model_Yopy | 0xffffff ), 91 Model_Yopy_All = ( Model_Yopy | 0xffffff ),
91 Model_Yopy_3000 = ( Model_Yopy | 0x000001 ), 92 Model_Yopy_3000 = ( Model_Yopy | 0x000001 ),
92 Model_Yopy_3500 = ( Model_Yopy | 0x000002 ), 93 Model_Yopy_3500 = ( Model_Yopy | 0x000002 ),
@@ -205,128 +206,130 @@ public:
205 206
206 QString systemVersionString() const; 207 QString systemVersionString() const;
207 208
208 virtual Transformation rotation() const; 209 virtual Transformation rotation() const;
209 virtual ODirection direction() const; 210 virtual ODirection direction() const;
210 211
211 // system 212 // system
212 213
213 virtual bool setSoftSuspend ( bool on ); 214 virtual bool setSoftSuspend ( bool on );
214 virtual bool suspend(); 215 virtual bool suspend();
215 216
216 virtual bool setDisplayStatus ( bool on ); 217 virtual bool setDisplayStatus ( bool on );
217 virtual bool setDisplayBrightness ( int brightness ); 218 virtual bool setDisplayBrightness ( int brightness );
218 virtual int displayBrightnessResolution() const; 219 virtual int displayBrightnessResolution() const;
219 virtual bool setDisplayContrast ( int contrast ); 220 virtual bool setDisplayContrast ( int contrast );
220 virtual int displayContrastResolution() const; 221 virtual int displayContrastResolution() const;
221 222
222 // don't add new virtual methods, use this: 223 // don't add new virtual methods, use this:
223 ///*virtual */ void boo(int i ) { return virtual_hook(1,&i); }; 224 ///*virtual */ void boo(int i ) { return virtual_hook(1,&i); };
224 // and in your subclass do do overwrite 225 // and in your subclass do do overwrite
225 //protected virtual int virtual_hook(int, void *) 226 //protected virtual int virtual_hook(int, void *)
226 // which is defined below 227 // which is defined below
227 228
228 // input / output 229 // input / output
229 virtual void playAlarmSound(); 230 virtual void playAlarmSound();
230 virtual void playKeySound(); 231 virtual void playKeySound();
231 virtual void playTouchSound(); 232 virtual void playTouchSound();
232 233
233 virtual QValueList <OLed> ledList() const; 234 virtual QValueList <OLed> ledList() const;
234 virtual QValueList <OLedState> ledStateList ( OLed led ) const; 235 virtual QValueList <OLedState> ledStateList ( OLed led ) const;
235 virtual OLedState ledState ( OLed led ) const; 236 virtual OLedState ledState ( OLed led ) const;
236 virtual bool setLedState ( OLed led, OLedState st ); 237 virtual bool setLedState ( OLed led, OLedState st );
237 238
238 virtual bool hasLightSensor() const; 239 virtual bool hasLightSensor() const;
239 virtual int readLightSensor(); 240 virtual int readLightSensor();
240 virtual int lightSensorResolution() const; 241 virtual int lightSensorResolution() const;
241 242
242 virtual bool hasHingeSensor() const; 243 virtual bool hasHingeSensor() const;
243 virtual OHingeStatus readHingeSensor(); 244 virtual OHingeStatus readHingeSensor();
244 245
245 const QStrList &allowedCpuFrequencies() const; 246 const QStrList &allowedCpuFrequencies() const;
246 bool setCurrentCpuFrequency(uint index); 247 bool setCurrentCpuFrequency(uint index);
247 248
248 /** 249 /**
249 * Returns the available buttons on this device. The number and location 250 * Returns the available buttons on this device. The number and location
250 * of buttons will vary depending on the device. Button numbers will be assigned 251 * of buttons will vary depending on the device. Button numbers will be assigned
251 * by the device manufacturer and will be from most preferred button to least preffered 252 * by the device manufacturer and will be from most preferred button to least preffered
252 * button. Note that this list only contains "user mappable" buttons. 253 * button. Note that this list only contains "user mappable" buttons.
253 * 254 *
254 * @todo Make method const and take care of calling initButtons or make that const too 255 * @todo Make method const and take care of calling initButtons or make that const too
255 * 256 *
256 */ 257 */
257 const QValueList<ODeviceButton> &buttons(); 258 const QValueList<ODeviceButton> &buttons();
258 259
259 /** 260 /**
260 * Returns the DeviceButton for the \a keyCode. If \a keyCode is not found, it 261 * Returns the DeviceButton for the \a keyCode. If \a keyCode is not found, it
261 * returns 0L 262 * returns 0L
262 */ 263 */
263 const ODeviceButton *buttonForKeycode ( ushort keyCode ); 264 const ODeviceButton *buttonForKeycode ( ushort keyCode );
264 265
265 /** 266 /**
266 * Reassigns the pressed action for \a button. To return to the factory 267 * Reassigns the pressed action for \a button. To return to the factory
267 * default pass an empty string as \a qcopMessage. 268 * default pass an empty string as \a qcopMessage.
268 */ 269 */
269 void remapPressedAction ( int button, const OQCopMessage &qcopMessage ); 270 void remapPressedAction ( int button, const OQCopMessage &qcopMessage );
270 271
271 /** 272 /**
272 * Reassigns the held action for \a button. To return to the factory 273 * Reassigns the held action for \a button. To return to the factory
273 * default pass an empty string as \a qcopMessage. 274 * default pass an empty string as \a qcopMessage.
274 */ 275 */
275 void remapHeldAction ( int button, const OQCopMessage &qcopMessage ); 276 void remapHeldAction ( int button, const OQCopMessage &qcopMessage );
276 277
277 /** 278 /**
278 * How long (in ms) you have to press a button for a "hold" action 279 * How long (in ms) you have to press a button for a "hold" action
279 */ 280 */
280 uint buttonHoldTime() const; 281 uint buttonHoldTime() const;
281 282
282signals: 283signals:
283 void buttonMappingChanged(); 284 void buttonMappingChanged();
284 285
285private slots: 286private slots:
286 void systemMessage ( const QCString &, const QByteArray & ); 287 void systemMessage ( const QCString &, const QByteArray & );
287 288
288protected: 289protected:
289 void reloadButtonMapping(); 290 void reloadButtonMapping();
290 /* ugly virtual hook */ 291 /* ugly virtual hook */
291 virtual void virtual_hook( int id, void* data ); 292 virtual void virtual_hook( int id, void* data );
292}; 293};
293 294
294class ODeviceData { 295class ODeviceData {
295 296
296 public: 297 public:
297 QString m_vendorstr; 298 QString m_vendorstr;
298 OVendor m_vendor; 299 OVendor m_vendor;
299 300
300 QString m_modelstr; 301 QString m_modelstr;
301 OModel m_model; 302 OModel m_model;
302 303
303 QString m_systemstr; 304 QString m_systemstr;
304 OSystem m_system; 305 OSystem m_system;
305 306
306 QString m_sysverstr; 307 QString m_sysverstr;
307 308
308 Transformation m_rotation; 309 Transformation m_rotation;
309 ODirection m_direction; 310 ODirection m_direction;
310 311
311 QValueList <ODeviceButton> *m_buttons; 312 QValueList <ODeviceButton> *m_buttons;
312 uint m_holdtime; 313 uint m_holdtime;
313 QStrList *m_cpu_frequencies; 314 QStrList *m_cpu_frequencies;
314}; 315};
315 316
316} 317}
318}
317 319
318static inline bool isQWS() 320static inline bool isQWS()
319{ 321{
320 return qApp ? ( qApp->type() == QApplication::GuiServer ) : false; 322 return qApp ? ( qApp->type() == QApplication::GuiServer ) : false;
321} 323}
322 324
323static QCString makeChannel ( const char *str ) 325static QCString makeChannel ( const char *str )
324{ 326{
325 if ( str && !::strchr ( str, '/' )) 327 if ( str && !::strchr ( str, '/' ))
326 return QCString ( "QPE/Application/" ) + str; 328 return QCString ( "QPE/Application/" ) + str;
327 else 329 else
328 return str; 330 return str;
329} 331}
330 332
333
331#endif 334#endif
332 335
diff --git a/libopie2/opiecore/device/odevice_ipaq.cpp b/libopie2/opiecore/device/odevice_ipaq.cpp
index 8ecea1b..177fd4c 100644
--- a/libopie2/opiecore/device/odevice_ipaq.cpp
+++ b/libopie2/opiecore/device/odevice_ipaq.cpp
@@ -8,96 +8,100 @@
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 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
57using namespace Opie::Core;
58using namespace Opie::Core::Private;
59
56/* KERNEL */ 60/* KERNEL */
57#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) 61#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 ))
58 62
59#define OD_IO(type,number) OD_IOC(0,type,number,0) 63#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)) 64#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)) 65#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)) 66#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size))
63 67
64typedef struct { 68typedef struct {
65 unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ 69 unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */
66 unsigned char TotalTime; /* Units of 5 seconds */ 70 unsigned char TotalTime; /* Units of 5 seconds */
67 unsigned char OnTime; /* units of 100m/s */ 71 unsigned char OnTime; /* units of 100m/s */
68 unsigned char OffTime; /* units of 100m/s */ 72 unsigned char OffTime; /* units of 100m/s */
69} LED_IN; 73} LED_IN;
70 74
71typedef struct { 75typedef struct {
72 unsigned char mode; 76 unsigned char mode;
73 unsigned char pwr; 77 unsigned char pwr;
74 unsigned char brightness; 78 unsigned char brightness;
75} FLITE_IN; 79} FLITE_IN;
76 80
77#define LED_ON OD_IOW( 'f', 5, LED_IN ) 81#define LED_ON OD_IOW( 'f', 5, LED_IN )
78#define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) 82#define FLITE_ON OD_IOW( 'f', 7, FLITE_IN )
79 83
80struct i_button ipaq_buttons [] = { 84struct i_button ipaq_buttons [] = {
81 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, 85 { 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"), 86 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
83 "devicebuttons/ipaq_calendar", 87 "devicebuttons/ipaq_calendar",
84 "datebook", "nextView()", 88 "datebook", "nextView()",
85 "today", "raise()" }, 89 "today", "raise()" },
86 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, 90 { 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"), 91 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
88 "devicebuttons/ipaq_contact", 92 "devicebuttons/ipaq_contact",
89 "addressbook", "raise()", 93 "addressbook", "raise()",
90 "addressbook", "beamBusinessCard()" }, 94 "addressbook", "beamBusinessCard()" },
91 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx, 95 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx,
92 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 96 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
93 "devicebuttons/ipaq_menu", 97 "devicebuttons/ipaq_menu",
94 "QPE/TaskBar", "toggleMenu()", 98 "QPE/TaskBar", "toggleMenu()",
95 "QPE/TaskBar", "toggleStartMenu()" }, 99 "QPE/TaskBar", "toggleStartMenu()" },
96 { Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, 100 { Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx,
97 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), 101 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
98 "devicebuttons/ipaq_mail", 102 "devicebuttons/ipaq_mail",
99 "mail", "raise()", 103 "mail", "raise()",
100 "mail", "newMail()" }, 104 "mail", "newMail()" },
101 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, 105 { 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"), 106 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
103 "devicebuttons/ipaq_home", 107 "devicebuttons/ipaq_home",
diff --git a/libopie2/opiecore/device/odevice_ipaq.h b/libopie2/opiecore/device/odevice_ipaq.h
index f512344..4f4af46 100644
--- a/libopie2/opiecore/device/odevice_ipaq.h
+++ b/libopie2/opiecore/device/odevice_ipaq.h
@@ -1,84 +1,90 @@
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#ifndef ODEVICE_IPAQ 30#ifndef ODEVICE_IPAQ
31#define ODEVICE_IPAQ 31#define ODEVICE_IPAQ
32 32
33#include "odevice.h" 33#include "odevice.h"
34 34
35/* QT */ 35/* QT */
36#include <qwindowsystem_qws.h> 36#include <qwindowsystem_qws.h>
37 37
38using namespace Opie; 38namespace Opie {
39namespace Core {
40namespace Private {
39 41
40class iPAQ : public ODevice, public QWSServer::KeyboardFilter 42class iPAQ : public ODevice, public QWSServer::KeyboardFilter
41{ 43{
42 44
43 protected: 45 protected:
44 virtual void init(); 46 virtual void init();
45 virtual void initButtons(); 47 virtual void initButtons();
46 48
47 public: 49 public:
48 virtual bool setSoftSuspend( bool soft ); 50 virtual bool setSoftSuspend( bool soft );
49 51
50 virtual bool setDisplayBrightness( int b ); 52 virtual bool setDisplayBrightness( int b );
51 virtual int displayBrightnessResolution() const; 53 virtual int displayBrightnessResolution() const;
52 54
53 virtual void playAlarmSound(); 55 virtual void playAlarmSound();
54 56
55 virtual QValueList <OLed> ledList() const; 57 virtual QValueList <OLed> ledList() const;
56 virtual QValueList <OLedState> ledStateList( OLed led ) const; 58 virtual QValueList <OLedState> ledStateList( OLed led ) const;
57 virtual OLedState ledState( OLed led ) const; 59 virtual OLedState ledState( OLed led ) const;
58 virtual bool setLedState( OLed led, OLedState st ); 60 virtual bool setLedState( OLed led, OLedState st );
59 61
60 virtual bool hasLightSensor() const; 62 virtual bool hasLightSensor() const;
61 virtual int readLightSensor(); 63 virtual int readLightSensor();
62 virtual int lightSensorResolution() const; 64 virtual int lightSensorResolution() const;
63 65
64 protected: 66 protected:
65 virtual bool filter( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); 67 virtual bool filter( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat );
66 virtual void timerEvent( QTimerEvent *te ); 68 virtual void timerEvent( QTimerEvent *te );
67 69
68 int m_power_timer; 70 int m_power_timer;
69 71
70 OLedState m_leds [2]; 72 OLedState m_leds [2];
71}; 73};
72 74
73struct i_button { 75struct i_button {
74 uint model; 76 uint model;
75 Qt::Key code; 77 Qt::Key code;
76 char *utext; 78 char *utext;
77 char *pix; 79 char *pix;
78 char *fpressedservice; 80 char *fpressedservice;
79 char *fpressedaction; 81 char *fpressedaction;
80 char *fheldservice; 82 char *fheldservice;
81 char *fheldaction; 83 char *fheldaction;
82}; 84};
83 85
86}
87}
88}
89
84#endif 90#endif
diff --git a/libopie2/opiecore/device/odevice_jornada.cpp b/libopie2/opiecore/device/odevice_jornada.cpp
index 37bd6e9..b79b0b5 100644
--- a/libopie2/opiecore/device/odevice_jornada.cpp
+++ b/libopie2/opiecore/device/odevice_jornada.cpp
@@ -32,97 +32,97 @@
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
80using namespace Opie; 80using namespace Opie::Core::Private;
81 81
82void Jornada::init() 82void Jornada::init()
83{ 83{
84 d->m_vendorstr = "HP"; 84 d->m_vendorstr = "HP";
85 d->m_vendor = Vendor_HP; 85 d->m_vendor = Vendor_HP;
86 d->m_modelstr = "Jornada 56x"; 86 d->m_modelstr = "Jornada 56x";
87 d->m_model = Model_Jornada_56x; 87 d->m_model = Model_Jornada_56x;
88 d->m_systemstr = "Familiar"; 88 d->m_systemstr = "Familiar";
89 d->m_system = System_Familiar; 89 d->m_system = System_Familiar;
90 d->m_rotation = Rot0; 90 d->m_rotation = Rot0;
91 91
92 QFile f ( "/etc/familiar-version" ); 92 QFile f ( "/etc/familiar-version" );
93 f.setName ( "/etc/familiar-version" ); 93 f.setName ( "/etc/familiar-version" );
94 if ( f.open ( IO_ReadOnly )) { 94 if ( f.open ( IO_ReadOnly )) {
95 95
96 QTextStream ts ( &f ); 96 QTextStream ts ( &f );
97 d->m_sysverstr = ts.readLine().mid( 10 ); 97 d->m_sysverstr = ts.readLine().mid( 10 );
98 98
99 f. close(); 99 f. close();
100 } 100 }
101} 101}
102 102
103 103
104int Jornada::displayBrightnessResolution() const 104int Jornada::displayBrightnessResolution() const
105{ 105{
106 return 0; 106 return 0;
107} 107}
108 108
109 109
110bool Jornada::setDisplayBrightness( int bright ) 110bool Jornada::setDisplayBrightness( int bright )
111{ 111{
112 bool res = false; 112 bool res = false;
113 int fd; 113 int fd;
114 114
115 if ( bright > 255 ) 115 if ( bright > 255 )
116 bright = 255; 116 bright = 255;
117 if ( bright < 0 ) 117 if ( bright < 0 )
118 bright = 0; 118 bright = 0;
119 119
120 if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { 120 if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) {
121 FLITE_IN bl; 121 FLITE_IN bl;
122 bl. mode = 1; 122 bl. mode = 1;
123 bl. pwr = bright ? 1 : 0; 123 bl. pwr = bright ? 1 : 0;
124 bl. brightness = ( bright * ( displayBrightnessResolution() - 1 ) + 127 ) / 255; 124 bl. brightness = ( bright * ( displayBrightnessResolution() - 1 ) + 127 ) / 255;
125 res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); 125 res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 );
126 ::close ( fd ); 126 ::close ( fd );
127 } 127 }
128 return res; 128 return res;
diff --git a/libopie2/opiecore/device/odevice_jornada.h b/libopie2/opiecore/device/odevice_jornada.h
index 59be8da..c37d75e 100644
--- a/libopie2/opiecore/device/odevice_jornada.h
+++ b/libopie2/opiecore/device/odevice_jornada.h
@@ -1,50 +1,53 @@
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#ifndef ODEVICE_JORNADA 30#ifndef ODEVICE_JORNADA
31#define ODEVICE_JORNADA 31#define ODEVICE_JORNADA
32 32
33#include <opie2/odevice.h> 33#include <opie2/odevice.h>
34 34
35using namespace Opie; 35namespace Opie {
36 36namespace Core {
37namespace Private {
37class Jornada : public ODevice 38class Jornada : public ODevice
38{ 39{
39 40
40 protected: 41 protected:
41 virtual void init(); 42 virtual void init();
42 43
43 public: 44 public:
44 virtual bool setSoftSuspend ( bool soft ); 45 virtual bool setSoftSuspend ( bool soft );
45 virtual bool setDisplayBrightness ( int b ); 46 virtual bool setDisplayBrightness ( int b );
46 virtual int displayBrightnessResolution() const; 47 virtual int displayBrightnessResolution() const;
47}; 48};
48 49}
50}
51}
49#endif 52#endif
50 53
diff --git a/libopie2/opiecore/device/odevice_ramses.cpp b/libopie2/opiecore/device/odevice_ramses.cpp
index 5bcf6a9..77de8c5 100644
--- a/libopie2/opiecore/device/odevice_ramses.cpp
+++ b/libopie2/opiecore/device/odevice_ramses.cpp
@@ -8,96 +8,99 @@
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_ramses.h" 30#include "odevice_ramses.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::Core;
57using namespace Opie::Core::Private;
58
56struct r_button ramses_buttons [] = { 59struct r_button ramses_buttons [] = {
57 { Model_Ramses_MNCI, 60 { Model_Ramses_MNCI,
58 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 61 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
59 "devicebuttons/z_menu", 62 "devicebuttons/z_menu",
60 "QPE/TaskBar", "toggleMenu()", 63 "QPE/TaskBar", "toggleMenu()",
61 "QPE/TaskBar", "toggleStartMenu()" }, 64 "QPE/TaskBar", "toggleStartMenu()" },
62 { Model_Ramses_MNCI, 65 { Model_Ramses_MNCI,
63 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 66 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
64 "devicebuttons/ipaq_home", 67 "devicebuttons/ipaq_home",
65 "QPE/Launcher", "home()", 68 "QPE/Launcher", "home()",
66 "buttonsettings", "raise()" }, 69 "buttonsettings", "raise()" },
67}; 70};
68 71
69void Ramses::init() 72void Ramses::init()
70{ 73{
71 d->m_vendorstr = "M und N"; 74 d->m_vendorstr = "M und N";
72 d->m_vendor = Vendor_MundN; 75 d->m_vendor = Vendor_MundN;
73 76
74 QFile f("/proc/sys/board/ramses"); 77 QFile f("/proc/sys/board/ramses");
75 78
76 d->m_modelstr = "Ramses"; 79 d->m_modelstr = "Ramses";
77 d->m_model = Model_Ramses_MNCI; 80 d->m_model = Model_Ramses_MNCI;
78 81
79 d->m_rotation = Rot0; 82 d->m_rotation = Rot0;
80 d->m_holdtime = 1000; 83 d->m_holdtime = 1000;
81 84
82 f.setName("/etc/oz_version"); 85 f.setName("/etc/oz_version");
83 86
84 if (f.open(IO_ReadOnly)) { 87 if (f.open(IO_ReadOnly)) {
85 d->m_systemstr = "OpenEmbedded/Ramses"; 88 d->m_systemstr = "OpenEmbedded/Ramses";
86 d->m_system = System_OpenZaurus; 89 d->m_system = System_OpenZaurus;
87 90
88 QTextStream ts(&f); 91 QTextStream ts(&f);
89 ts.setDevice(&f); 92 ts.setDevice(&f);
90 d->m_sysverstr = ts.readLine(); 93 d->m_sysverstr = ts.readLine();
91 f.close(); 94 f.close();
92 } 95 }
93 96
94 m_power_timer = 0; 97 m_power_timer = 0;
95 98
96#ifdef QT_QWS_ALLOW_OVERCLOCK 99#ifdef QT_QWS_ALLOW_OVERCLOCK
97#warning *** Overclocking enabled - this may fry your hardware - you have been warned *** 100#warning *** Overclocking enabled - this may fry your hardware - you have been warned ***
98#define OC(x...) x 101#define OC(x...) x
99#else 102#else
100#define OC(x...) 103#define OC(x...)
101#endif 104#endif
102 105
103 // This table is true for a Intel XScale PXA 255 106 // This table is true for a Intel XScale PXA 255
diff --git a/libopie2/opiecore/device/odevice_ramses.h b/libopie2/opiecore/device/odevice_ramses.h
index 1b660ab..e673b1a 100644
--- a/libopie2/opiecore/device/odevice_ramses.h
+++ b/libopie2/opiecore/device/odevice_ramses.h
@@ -1,72 +1,77 @@
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#ifndef ODEVICE_RAMSES 30#ifndef ODEVICE_RAMSES
31#define ODEVICE_RAMSES 31#define ODEVICE_RAMSES
32 32
33#include <opie2/odevice.h> 33#include <opie2/odevice.h>
34/* QT */ 34/* QT */
35#include <qwindowsystem_qws.h> 35#include <qwindowsystem_qws.h>
36 36
37using namespace Opie; 37namespace Opie {
38namespace Core {
39namespace Private {
38 40
39class Ramses : public ODevice, public QWSServer::KeyboardFilter 41class Ramses : public ODevice, public QWSServer::KeyboardFilter
40{ 42{
41 protected: 43 protected:
42 virtual void init(); 44 virtual void init();
43 45
44 public: 46 public:
45 virtual bool setSoftSuspend( bool soft ); 47 virtual bool setSoftSuspend( bool soft );
46 virtual bool suspend(); 48 virtual bool suspend();
47 49
48 virtual bool setDisplayStatus( bool on ); 50 virtual bool setDisplayStatus( bool on );
49 virtual bool setDisplayBrightness( int b ); 51 virtual bool setDisplayBrightness( int b );
50 virtual int displayBrightnessResolution() const; 52 virtual int displayBrightnessResolution() const;
51 virtual bool setDisplayContrast( int b ); 53 virtual bool setDisplayContrast( int b );
52 virtual int displayContrastResolution() const; 54 virtual int displayContrastResolution() const;
53 55
54 protected: 56 protected:
55 virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); 57 virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat );
56 virtual void timerEvent ( QTimerEvent *te ); 58 virtual void timerEvent ( QTimerEvent *te );
57 59
58 int m_power_timer; 60 int m_power_timer;
59}; 61};
60 62
61struct r_button { 63struct r_button {
62 uint model; 64 uint model;
63 Qt::Key code; 65 Qt::Key code;
64 char *utext; 66 char *utext;
65 char *pix; 67 char *pix;
66 char *fpressedservice; 68 char *fpressedservice;
67 char *fpressedaction; 69 char *fpressedaction;
68 char *fheldservice; 70 char *fheldservice;
69 char *fheldaction; 71 char *fheldaction;
70}; 72};
73}
74}
75}
71 76
72#endif 77#endif
diff --git a/libopie2/opiecore/device/odevice_simpad.cpp b/libopie2/opiecore/device/odevice_simpad.cpp
index 90aca2f..80d40a3 100644
--- a/libopie2/opiecore/device/odevice_simpad.cpp
+++ b/libopie2/opiecore/device/odevice_simpad.cpp
@@ -8,97 +8,98 @@ _;:, .> :=|. 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::Core;
57using namespace Opie::Core::Private;
57 58
58struct s_button simpad_buttons [] = { 59struct s_button simpad_buttons [] = {
59 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 60 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
60 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Lower+Up"), 61 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Lower+Up"),
61 "devicebuttons/simpad_lower_up", 62 "devicebuttons/simpad_lower_up",
62 "datebook", "nextView()", 63 "datebook", "nextView()",
63 "today", "raise()" }, 64 "today", "raise()" },
64 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 65 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
65 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Lower+Down"), 66 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Lower+Down"),
66 "devicebuttons/simpad_lower_down", 67 "devicebuttons/simpad_lower_down",
67 "addressbook", "raise()", 68 "addressbook", "raise()",
68 "addressbook", "beamBusinessCard()" }, 69 "addressbook", "beamBusinessCard()" },
69 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 70 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
70 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Lower+Right"), 71 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Lower+Right"),
71 "devicebuttons/simpad_lower_right", 72 "devicebuttons/simpad_lower_right",
72 "QPE/TaskBar", "toggleMenu()", 73 "QPE/TaskBar", "toggleMenu()",
73 "QPE/TaskBar", "toggleStartMenu()" }, 74 "QPE/TaskBar", "toggleStartMenu()" },
74 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 75 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
75 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Lower+Left"), 76 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Lower+Left"),
76 "devicebuttons/simpad_lower_left", 77 "devicebuttons/simpad_lower_left",
77 "mail", "raise()", 78 "mail", "raise()",
78 "mail", "newMail()" }, 79 "mail", "newMail()" },
79 80
80 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 81 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
81 Qt::Key_F5, QT_TRANSLATE_NOOP("Button", "Upper+Up"), 82 Qt::Key_F5, QT_TRANSLATE_NOOP("Button", "Upper+Up"),
82 "devicebuttons/simpad_upper_up", 83 "devicebuttons/simpad_upper_up",
83 "QPE/Launcher", "home()", 84 "QPE/Launcher", "home()",
84 "buttonsettings", "raise()" }, 85 "buttonsettings", "raise()" },
85 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 86 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
86 Qt::Key_F6, QT_TRANSLATE_NOOP("Button", "Upper+Down"), 87 Qt::Key_F6, QT_TRANSLATE_NOOP("Button", "Upper+Down"),
87 "devicebuttons/simpad_upper_down", 88 "devicebuttons/simpad_upper_down",
88 "addressbook", "raise()", 89 "addressbook", "raise()",
89 "addressbook", "beamBusinessCard()" }, 90 "addressbook", "beamBusinessCard()" },
90 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 91 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
91 Qt::Key_F7, QT_TRANSLATE_NOOP("Button", "Upper+Right"), 92 Qt::Key_F7, QT_TRANSLATE_NOOP("Button", "Upper+Right"),
92 "devicebuttons/simpad_upper_right", 93 "devicebuttons/simpad_upper_right",
93 "QPE/TaskBar", "toggleMenu()", 94 "QPE/TaskBar", "toggleMenu()",
94 "QPE/TaskBar", "toggleStartMenu()" }, 95 "QPE/TaskBar", "toggleStartMenu()" },
95 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 96 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
96 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Upper+Left"), 97 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Upper+Left"),
97 "devicebuttons/simpad_upper_left", 98 "devicebuttons/simpad_upper_left",
98 "QPE/Rotation", "flip()", 99 "QPE/Rotation", "flip()",
99 "QPE/Rotation", "flip()" }, 100 "QPE/Rotation", "flip()" },
100 /* 101 /*
101 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 102 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
102 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), 103 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"),
103 "devicebuttons/simpad_lower_upper", 104 "devicebuttons/simpad_lower_upper",
104 "QPE/Launcher", "home()", 105 "QPE/Launcher", "home()",
diff --git a/libopie2/opiecore/device/odevice_simpad.h b/libopie2/opiecore/device/odevice_simpad.h
index 3287ee8..1848151 100644
--- a/libopie2/opiecore/device/odevice_simpad.h
+++ b/libopie2/opiecore/device/odevice_simpad.h
@@ -1,81 +1,87 @@
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#ifndef ODEVICE_SIMPAD 30#ifndef ODEVICE_SIMPAD
31#define ODEVICE_SIMPAD 31#define ODEVICE_SIMPAD
32 32
33#include <opie2/odevice.h> 33#include <opie2/odevice.h>
34 34
35/* QT */ 35/* QT */
36#include <qwindowsystem_qws.h> 36#include <qwindowsystem_qws.h>
37 37
38using namespace Opie; 38namespace Opie {
39namespace Core {
40namespace Private {
39 41
40class SIMpad : public ODevice, public QWSServer::KeyboardFilter 42class SIMpad : public ODevice, public QWSServer::KeyboardFilter
41{ 43{
42 protected: 44 protected:
43 virtual void init(); 45 virtual void init();
44 virtual void initButtons(); 46 virtual void initButtons();
45 47
46 public: 48 public:
47 virtual bool setSoftSuspend( bool soft ); 49 virtual bool setSoftSuspend( bool soft );
48 virtual bool suspend(); 50 virtual bool suspend();
49 51
50 virtual bool setDisplayStatus( bool on ); 52 virtual bool setDisplayStatus( bool on );
51 virtual bool setDisplayBrightness( int b ); 53 virtual bool setDisplayBrightness( int b );
52 virtual int displayBrightnessResolution() const; 54 virtual int displayBrightnessResolution() const;
53 55
54 virtual void playAlarmSound(); 56 virtual void playAlarmSound();
55 57
56 virtual QValueList <OLed> ledList() const; 58 virtual QValueList <OLed> ledList() const;
57 virtual QValueList <OLedState> ledStateList( OLed led ) const; 59 virtual QValueList <OLedState> ledStateList( OLed led ) const;
58 virtual OLedState ledState( OLed led ) const; 60 virtual OLedState ledState( OLed led ) const;
59 virtual bool setLedState( OLed led, OLedState st ); 61 virtual bool setLedState( OLed led, OLedState st );
60 62
61 protected: 63 protected:
62 virtual bool filter( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); 64 virtual bool filter( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat );
63 virtual void timerEvent( QTimerEvent *te ); 65 virtual void timerEvent( QTimerEvent *te );
64 66
65 int m_power_timer; 67 int m_power_timer;
66 68
67 OLedState m_leds [1]; 69 OLedState m_leds [1];
68}; 70};
69 71
70struct s_button { 72struct s_button {
71 uint model; 73 uint model;
72 Qt::Key code; 74 Qt::Key code;
73 char *utext; 75 char *utext;
74 char *pix; 76 char *pix;
75 char *fpressedservice; 77 char *fpressedservice;
76 char *fpressedaction; 78 char *fpressedaction;
77 char *fheldservice; 79 char *fheldservice;
78 char *fheldaction; 80 char *fheldaction;
79}; 81};
80 82
83}
84}
85}
86
81#endif 87#endif
diff --git a/libopie2/opiecore/device/odevice_yopy.cpp b/libopie2/opiecore/device/odevice_yopy.cpp
index d241db8..f7a4025 100644
--- a/libopie2/opiecore/device/odevice_yopy.cpp
+++ b/libopie2/opiecore/device/odevice_yopy.cpp
@@ -8,97 +8,98 @@ _;:,     .>    :=|. 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::Core;
57using namespace Opie::Core::Private;
57 58
58struct yopy_button yopy_buttons [] = { 59struct yopy_button yopy_buttons [] = {
59 { Qt::Key_F10, QT_TRANSLATE_NOOP( "Button", "Action Button" ), 60 { Qt::Key_F10, QT_TRANSLATE_NOOP( "Button", "Action Button" ),
60 "devicebuttons/yopy_action", 61 "devicebuttons/yopy_action",
61 "datebook", "nextView()", 62 "datebook", "nextView()",
62 "today", "raise()" }, 63 "today", "raise()" },
63 { Qt::Key_F11, QT_TRANSLATE_NOOP( "Button", "OK Button" ), 64 { Qt::Key_F11, QT_TRANSLATE_NOOP( "Button", "OK Button" ),
64 "devicebuttons/yopy_ok", 65 "devicebuttons/yopy_ok",
65 "addressbook", "raise()", 66 "addressbook", "raise()",
66 "addressbook", "beamBusinessCard()" }, 67 "addressbook", "beamBusinessCard()" },
67 { Qt::Key_F12, QT_TRANSLATE_NOOP( "Button", "End Button" ), 68 { Qt::Key_F12, QT_TRANSLATE_NOOP( "Button", "End Button" ),
68 "devicebuttons/yopy_end", 69 "devicebuttons/yopy_end",
69 "QPE/Launcher", "home()", 70 "QPE/Launcher", "home()",
70 "buttonsettings", "raise()" }, 71 "buttonsettings", "raise()" },
71}; 72};
72 73
73void Yopy::init() 74void Yopy::init()
74{ 75{
75 d->m_vendorstr = "G.Mate"; 76 d->m_vendorstr = "G.Mate";
76 d->m_vendor = Vendor_GMate; 77 d->m_vendor = Vendor_GMate;
77 d->m_modelstr = "Yopy3700"; 78 d->m_modelstr = "Yopy3700";
78 d->m_model = Model_Yopy_3700; 79 d->m_model = Model_Yopy_3700;
79 d->m_rotation = Rot0; 80 d->m_rotation = Rot0;
80 81
81 d->m_systemstr = "Linupy"; 82 d->m_systemstr = "Linupy";
82 d->m_system = System_Linupy; 83 d->m_system = System_Linupy;
83 84
84 QFile f ( "/etc/issue" ); 85 QFile f ( "/etc/issue" );
85 if ( f. open ( IO_ReadOnly ) ) 86 if ( f. open ( IO_ReadOnly ) )
86 { 87 {
87 QTextStream ts ( &f ); 88 QTextStream ts ( &f );
88 ts.readLine(); 89 ts.readLine();
89 d->m_sysverstr = ts. readLine(); 90 d->m_sysverstr = ts. readLine();
90 f. close(); 91 f. close();
91 } 92 }
92} 93}
93 94
94 95
95void Yopy::initButtons() 96void Yopy::initButtons()
96{ 97{
97 if ( d->m_buttons ) 98 if ( d->m_buttons )
98 return ; 99 return ;
99 100
100 d->m_buttons = new QValueList <ODeviceButton>; 101 d->m_buttons = new QValueList <ODeviceButton>;
101 102
102 for ( uint i = 0; i < ( sizeof( yopy_buttons ) / sizeof( yopy_button ) ); i++ ) 103 for ( uint i = 0; i < ( sizeof( yopy_buttons ) / sizeof( yopy_button ) ); i++ )
103 { 104 {
104 105
diff --git a/libopie2/opiecore/device/odevice_yopy.h b/libopie2/opiecore/device/odevice_yopy.h
index be8f62c..7d85479 100644
--- a/libopie2/opiecore/device/odevice_yopy.h
+++ b/libopie2/opiecore/device/odevice_yopy.h
@@ -1,62 +1,67 @@
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#ifndef ODEVICE_YOPY 30#ifndef ODEVICE_YOPY
31#define ODEVICE_YOPY 31#define ODEVICE_YOPY
32 32
33#include <opie2/odevice.h> 33#include <opie2/odevice.h>
34 34
35using namespace Opie; 35namespace Opie {
36 36namespace Core {
37namespace Private {
37class Yopy : public ODevice 38class Yopy : public ODevice
38{ 39{
39 protected: 40 protected:
40 41
41 virtual void init(); 42 virtual void init();
42 virtual void initButtons(); 43 virtual void initButtons();
43 44
44 public: 45 public:
45 virtual bool suspend(); 46 virtual bool suspend();
46 47
47 virtual bool setDisplayBrightness ( int b ); 48 virtual bool setDisplayBrightness ( int b );
48 virtual int displayBrightnessResolution() const; 49 virtual int displayBrightnessResolution() const;
49}; 50};
50 51
51struct yopy_button 52struct yopy_button
52{ 53{
53 Qt::Key code; 54 Qt::Key code;
54 char *utext; 55 char *utext;
55 char *pix; 56 char *pix;
56 char *fpressedservice; 57 char *fpressedservice;
57 char *fpressedaction; 58 char *fpressedaction;
58 char *fheldservice; 59 char *fheldservice;
59 char *fheldaction; 60 char *fheldaction;
60}; 61};
61 62
63}
64}
65}
66
62#endif 67#endif
diff --git a/libopie2/opiecore/device/odevice_zaurus.cpp b/libopie2/opiecore/device/odevice_zaurus.cpp
index 8ab3cbe..0d21f26 100644
--- a/libopie2/opiecore/device/odevice_zaurus.cpp
+++ b/libopie2/opiecore/device/odevice_zaurus.cpp
@@ -8,97 +8,98 @@ _;:, .> :=|. 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_zaurus.h" 30#include "odevice_zaurus.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::Core;
57using namespace Opie::Core::Private;
57 58
58struct z_button z_buttons [] = { 59struct z_button z_buttons [] = {
59 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 60 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
60 "devicebuttons/z_calendar", 61 "devicebuttons/z_calendar",
61 "datebook", "nextView()", 62 "datebook", "nextView()",
62 "today", "raise()" }, 63 "today", "raise()" },
63 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 64 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
64 "devicebuttons/z_contact", 65 "devicebuttons/z_contact",
65 "addressbook", "raise()", 66 "addressbook", "raise()",
66 "addressbook", "beamBusinessCard()" }, 67 "addressbook", "beamBusinessCard()" },
67 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 68 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
68 "devicebuttons/z_home", 69 "devicebuttons/z_home",
69 "QPE/Launcher", "home()", 70 "QPE/Launcher", "home()",
70 "buttonsettings", "raise()" }, 71 "buttonsettings", "raise()" },
71 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 72 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
72 "devicebuttons/z_menu", 73 "devicebuttons/z_menu",
73 "QPE/TaskBar", "toggleMenu()", 74 "QPE/TaskBar", "toggleMenu()",
74 "QPE/TaskBar", "toggleStartMenu()" }, 75 "QPE/TaskBar", "toggleStartMenu()" },
75 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), 76 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
76 "devicebuttons/z_mail", 77 "devicebuttons/z_mail",
77 "mail", "raise()", 78 "mail", "raise()",
78 "mail", "newMail()" }, 79 "mail", "newMail()" },
79}; 80};
80 81
81struct z_button z_buttons_c700 [] = { 82struct z_button z_buttons_c700 [] = {
82 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 83 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
83 "devicebuttons/z_calendar", 84 "devicebuttons/z_calendar",
84 "datebook", "nextView()", 85 "datebook", "nextView()",
85 "today", "raise()" }, 86 "today", "raise()" },
86 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 87 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
87 "devicebuttons/z_contact", 88 "devicebuttons/z_contact",
88 "addressbook", "raise()", 89 "addressbook", "raise()",
89 "addressbook", "beamBusinessCard()" }, 90 "addressbook", "beamBusinessCard()" },
90 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 91 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
91 "devicebuttons/z_home", 92 "devicebuttons/z_home",
92 "QPE/Launcher", "home()", 93 "QPE/Launcher", "home()",
93 "buttonsettings", "raise()" }, 94 "buttonsettings", "raise()" },
94 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 95 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
95 "devicebuttons/z_menu", 96 "devicebuttons/z_menu",
96 "QPE/TaskBar", "toggleMenu()", 97 "QPE/TaskBar", "toggleMenu()",
97 "QPE/TaskBar", "toggleStartMenu()" }, 98 "QPE/TaskBar", "toggleStartMenu()" },
98 { Qt::Key_F14, QT_TRANSLATE_NOOP("Button", "Display Rotate"), 99 { Qt::Key_F14, QT_TRANSLATE_NOOP("Button", "Display Rotate"),
99 "devicebuttons/z_hinge", 100 "devicebuttons/z_hinge",
100 "QPE/Rotation", "rotateDefault()", 101 "QPE/Rotation", "rotateDefault()",
101 "QPE/Dummy", "doNothing()" }, 102 "QPE/Dummy", "doNothing()" },
102}; 103};
103 104
104// FIXME This gets unnecessary complicated. We should think about splitting the Zaurus 105// FIXME This gets unnecessary complicated. We should think about splitting the Zaurus
diff --git a/libopie2/opiecore/device/odevice_zaurus.h b/libopie2/opiecore/device/odevice_zaurus.h
index f5c5172..ffb648f 100644
--- a/libopie2/opiecore/device/odevice_zaurus.h
+++ b/libopie2/opiecore/device/odevice_zaurus.h
@@ -1,96 +1,100 @@
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#ifndef ODEVICE_ZAURUS 30#ifndef ODEVICE_ZAURUS
31#define ODEVICE_ZAURUS 31#define ODEVICE_ZAURUS
32 32
33#include <opie2/odevice.h> 33#include <opie2/odevice.h>
34 34
35#ifndef ARRAY_SIZE 35#ifndef ARRAY_SIZE
36#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) 36#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
37#endif 37#endif
38 38
39// _IO and friends are only defined in kernel headers ... 39// _IO and friends are only defined in kernel headers ...
40 40
41#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) 41#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 ))
42 42
43#define OD_IO(type,number) OD_IOC(0,type,number,0) 43#define OD_IO(type,number) OD_IOC(0,type,number,0)
44#define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) 44#define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size))
45#define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) 45#define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size))
46#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) 46#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size))
47 47
48using namespace Opie;
49 48
49namespace Opie {
50namespace Core {
51namespace Private {
50class Zaurus : public ODevice 52class Zaurus : public ODevice
51{ 53{
52 54
53 protected: 55 protected:
54 virtual void init(); 56 virtual void init();
55 virtual void initButtons(); 57 virtual void initButtons();
56 58
57 public: 59 public:
58 virtual bool setSoftSuspend ( bool soft ); 60 virtual bool setSoftSuspend ( bool soft );
59 61
60 virtual bool setDisplayBrightness ( int b ); 62 virtual bool setDisplayBrightness ( int b );
61 virtual int displayBrightnessResolution() const; 63 virtual int displayBrightnessResolution() const;
62 64
63 virtual void playAlarmSound(); 65 virtual void playAlarmSound();
64 virtual void playKeySound(); 66 virtual void playKeySound();
65 virtual void playTouchSound(); 67 virtual void playTouchSound();
66 68
67 virtual QValueList <OLed> ledList() const; 69 virtual QValueList <OLed> ledList() const;
68 virtual QValueList <OLedState> ledStateList ( OLed led ) const; 70 virtual QValueList <OLedState> ledStateList ( OLed led ) const;
69 virtual OLedState ledState( OLed led ) const; 71 virtual OLedState ledState( OLed led ) const;
70 virtual bool setLedState( OLed led, OLedState st ); 72 virtual bool setLedState( OLed led, OLedState st );
71 73
72 virtual bool hasHingeSensor() const; 74 virtual bool hasHingeSensor() const;
73 virtual OHingeStatus readHingeSensor(); 75 virtual OHingeStatus readHingeSensor();
74 76
75 virtual bool suspend(); 77 virtual bool suspend();
76 virtual Transformation rotation() const; 78 virtual Transformation rotation() const;
77 virtual ODirection direction() const; 79 virtual ODirection direction() const;
78 80
79 protected: 81 protected:
80 virtual void buzzer ( int snd ); 82 virtual void buzzer ( int snd );
81 83
82 OLedState m_leds [1]; 84 OLedState m_leds [1];
83 bool m_embedix; 85 bool m_embedix;
84}; 86};
85 87
86struct z_button { 88struct z_button {
87 Qt::Key code; 89 Qt::Key code;
88 char *utext; 90 char *utext;
89 char *pix; 91 char *pix;
90 char *fpressedservice; 92 char *fpressedservice;
91 char *fpressedaction; 93 char *fpressedaction;
92 char *fheldservice; 94 char *fheldservice;
93 char *fheldaction; 95 char *fheldaction;
94}; 96};
95 97}
98}
99}
96#endif 100#endif
diff --git a/libopie2/opiecore/device/odevicebutton.cpp b/libopie2/opiecore/device/odevicebutton.cpp
index 0b593d5..a081b7f 100644
--- a/libopie2/opiecore/device/odevicebutton.cpp
+++ b/libopie2/opiecore/device/odevicebutton.cpp
@@ -1,176 +1,182 @@
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 <qpixmap.h> 30#include <qpixmap.h>
31#include <qstring.h> 31#include <qstring.h>
32 32
33#include <qpe/qcopenvelope_qws.h> 33#include <qpe/qcopenvelope_qws.h>
34#include <opie2/odevicebutton.h> 34#include <opie2/odevicebutton.h>
35 35
36using namespace Opie; 36
37namespace Opie {
38namespace Core {
39namespace Private {
37 40
38class OQCopMessageData 41class OQCopMessageData
39{ 42{
40 public: 43 public:
41 QCString m_channel; 44 QCString m_channel;
42 QCString m_message; 45 QCString m_message;
43 QByteArray m_data; 46 QByteArray m_data;
44}; 47};
48}
45 49
50using namespace Opie::Core;
51using namespace Opie::Core::Private;
46 52
47OQCopMessage::OQCopMessage() 53OQCopMessage::OQCopMessage()
48 : d ( 0 ) 54 : d ( 0 )
49{ 55{
50 init ( QCString(), QCString(), QByteArray()); 56 init ( QCString(), QCString(), QByteArray());
51} 57}
52 58
53OQCopMessage::OQCopMessage ( const OQCopMessage &copy ) 59OQCopMessage::OQCopMessage ( const OQCopMessage &copy )
54 : d ( 0 ) 60 : d ( 0 )
55{ 61{
56 init ( copy. channel(), copy. message(), copy. data()); 62 init ( copy. channel(), copy. message(), copy. data());
57} 63}
58 64
59OQCopMessage &OQCopMessage::operator = ( const OQCopMessage &assign ) 65OQCopMessage &OQCopMessage::operator = ( const OQCopMessage &assign )
60{ 66{
61 init ( assign. channel(), assign. message(), assign. data()); 67 init ( assign. channel(), assign. message(), assign. data());
62 return *this; 68 return *this;
63} 69}
64 70
65OQCopMessage::OQCopMessage ( const QCString &ch, const QCString &m, const QByteArray &arg ) 71OQCopMessage::OQCopMessage ( const QCString &ch, const QCString &m, const QByteArray &arg )
66 : d ( 0 ) 72 : d ( 0 )
67{ 73{
68 init ( ch, m, arg ); 74 init ( ch, m, arg );
69} 75}
70 76
71void OQCopMessage::init ( const QCString &ch, const QCString &m, const QByteArray &arg ) 77void OQCopMessage::init ( const QCString &ch, const QCString &m, const QByteArray &arg )
72{ 78{
73 if ( !d ) 79 if ( !d )
74 d = new OQCopMessageData(); 80 d = new OQCopMessageData();
75 d->m_channel = ch; 81 d->m_channel = ch;
76 d->m_message = m; 82 d->m_message = m;
77 d->m_data = arg; 83 d->m_data = arg;
78} 84}
79 85
80bool OQCopMessage::send() 86bool OQCopMessage::send()
81{ 87{
82 if ( d->m_channel. isEmpty() || d->m_message. isEmpty() ) 88 if ( d->m_channel. isEmpty() || d->m_message. isEmpty() )
83 return false; 89 return false;
84 90
85 QCopEnvelope e ( d->m_channel, d->m_message ); 91 QCopEnvelope e ( d->m_channel, d->m_message );
86 92
87 if ( d->m_data. size()) 93 if ( d->m_data. size())
88 e. writeRawBytes ( d->m_data. data(), d->m_data. size()); 94 e. writeRawBytes ( d->m_data. data(), d->m_data. size());
89 95
90 return true; 96 return true;
91} 97}
92 98
93QCString OQCopMessage::channel() const 99QCString OQCopMessage::channel() const
94{ 100{
95 return d->m_channel; 101 return d->m_channel;
96} 102}
97 103
98QCString OQCopMessage::message() const 104QCString OQCopMessage::message() const
99{ 105{
100 return d->m_message; 106 return d->m_message;
101} 107}
102 108
103QByteArray OQCopMessage::data() const 109QByteArray OQCopMessage::data() const
104{ 110{
105 return d->m_data; 111 return d->m_data;
106} 112}
107 113
108bool OQCopMessage::isNull() const 114bool OQCopMessage::isNull() const
109{ 115{
110 return d->m_message.isNull() || d->m_channel.isNull(); 116 return d->m_message.isNull() || d->m_channel.isNull();
111} 117}
112void OQCopMessage::setChannel ( const QCString &ch ) 118void OQCopMessage::setChannel ( const QCString &ch )
113{ 119{
114 d->m_channel = ch; 120 d->m_channel = ch;
115} 121}
116 122
117void OQCopMessage::setMessage ( const QCString &m ) 123void OQCopMessage::setMessage ( const QCString &m )
118{ 124{
119 d->m_message = m; 125 d->m_message = m;
120} 126}
121 127
122void OQCopMessage::setData ( const QByteArray &data ) 128void OQCopMessage::setData ( const QByteArray &data )
123{ 129{
124 d->m_data = data; 130 d->m_data = data;
125} 131}
126 132
127/*! \class Opie::ODeviceButton 133/*! \class Opie::Core::ODeviceButton
128 \brief The Opie::ODeviceButton class represents a physical user mappable button on a Qtopia device. 134 \brief The Opie::Core::ODeviceButton class represents a physical user mappable button on a Qtopia device.
129 135
130 This class represents a physical button on a Qtopia device. A 136 This class represents a physical button on a Qtopia device. A
131 device may have "user programmable" buttons. 137 device may have "user programmable" buttons.
132 The location and number of buttons will vary from device to 138 The location and number of buttons will vary from device to
133 device. userText() and pixmap() may be used to describe this button 139 device. userText() and pixmap() may be used to describe this button
134 to the user in help documentation. 140 to the user in help documentation.
135 141
136 \ingroup qtopiaemb 142 \ingroup qtopiaemb
137 \internal 143 \internal
138*/ 144*/
139 145
140ODeviceButton::ODeviceButton() 146ODeviceButton::ODeviceButton()
141{} 147{}
142 148
143ODeviceButton::~ODeviceButton() 149ODeviceButton::~ODeviceButton()
144{} 150{}
145 151
146/*! 152/*!
147Returns the button's keycode. 153Returns the button's keycode.
148*/ 154*/
149ushort ODeviceButton::keycode() const 155ushort ODeviceButton::keycode() const
150{ 156{
151 return m_Keycode; 157 return m_Keycode;
152} 158}
153 159
154 160
155/*! 161/*!
156This function returns a human readable, translated description of the button. 162This function returns a human readable, translated description of the button.
157*/ 163*/
158QString ODeviceButton::userText() const 164QString ODeviceButton::userText() const
159{ 165{
160 return m_UserText; 166 return m_UserText;
161} 167}
162 168
163/*! 169/*!
164This function returns the pixmap for this button. If there isn't one 170This function returns the pixmap for this button. If there isn't one
165it will return an empty (null) pixmap. 171it will return an empty (null) pixmap.
166*/ 172*/
167QPixmap ODeviceButton::pixmap() const 173QPixmap ODeviceButton::pixmap() const
168{ 174{
169 return m_Pixmap; 175 return m_Pixmap;
170} 176}
171 177
172/*! 178/*!
173This function returns the factory preset (default) action for when this button 179This function returns the factory preset (default) action for when this button
174is pressed. The return value is a legal QCop message. 180is pressed. The return value is a legal QCop message.
175*/ 181*/
176OQCopMessage ODeviceButton::factoryPresetPressedAction() const 182OQCopMessage ODeviceButton::factoryPresetPressedAction() const
@@ -199,48 +205,51 @@ OQCopMessage ODeviceButton::factoryPresetHeldAction() const
199} 205}
200 206
201/*! 207/*!
202This function returns the user assigned action for when this button is pressed 208This function returns the user assigned action for when this button is pressed
203and held. If no action is assigned, factoryPresetAction() is returned. 209and held. If no action is assigned, factoryPresetAction() is returned.
204*/ 210*/
205OQCopMessage ODeviceButton::heldAction() const 211OQCopMessage ODeviceButton::heldAction() const
206{ 212{
207 if (m_HeldAction.channel().isEmpty()) 213 if (m_HeldAction.channel().isEmpty())
208 return factoryPresetHeldAction(); 214 return factoryPresetHeldAction();
209 return m_HeldAction; 215 return m_HeldAction;
210} 216}
211 217
212void ODeviceButton::setKeycode(ushort keycode) 218void ODeviceButton::setKeycode(ushort keycode)
213{ 219{
214 m_Keycode = keycode; 220 m_Keycode = keycode;
215} 221}
216 222
217void ODeviceButton::setUserText(const QString& text) 223void ODeviceButton::setUserText(const QString& text)
218{ 224{
219 m_UserText = text; 225 m_UserText = text;
220} 226}
221 227
222void ODeviceButton::setPixmap(const QPixmap& picture) 228void ODeviceButton::setPixmap(const QPixmap& picture)
223{ 229{
224 m_Pixmap = picture; 230 m_Pixmap = picture;
225} 231}
226 232
227void ODeviceButton::setFactoryPresetPressedAction(const OQCopMessage& action) 233void ODeviceButton::setFactoryPresetPressedAction(const OQCopMessage& action)
228{ 234{
229 m_FactoryPresetPressedAction = action; 235 m_FactoryPresetPressedAction = action;
230} 236}
231 237
232 238
233void ODeviceButton::setPressedAction(const OQCopMessage& action) 239void ODeviceButton::setPressedAction(const OQCopMessage& action)
234{ 240{
235 m_PressedAction = action; 241 m_PressedAction = action;
236} 242}
237 243
238void ODeviceButton::setFactoryPresetHeldAction(const OQCopMessage& action) 244void ODeviceButton::setFactoryPresetHeldAction(const OQCopMessage& action)
239{ 245{
240 m_FactoryPresetHeldAction = action; 246 m_FactoryPresetHeldAction = action;
241} 247}
242 248
243void ODeviceButton::setHeldAction(const OQCopMessage& action) 249void ODeviceButton::setHeldAction(const OQCopMessage& action)
244{ 250{
245 m_HeldAction = action; 251 m_HeldAction = action;
246} 252}
253
254}
255}
diff --git a/libopie2/opiecore/device/odevicebutton.h b/libopie2/opiecore/device/odevicebutton.h
index a66b88f..4000144 100644
--- a/libopie2/opiecore/device/odevicebutton.h
+++ b/libopie2/opiecore/device/odevicebutton.h
@@ -1,108 +1,111 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#ifndef DEVICE_BUTTON_H 20#ifndef DEVICE_BUTTON_H
21#define DEVICE_BUTTON_H 21#define DEVICE_BUTTON_H
22 22
23#include <qpixmap.h> 23#include <qpixmap.h>
24#include <qstring.h> 24#include <qstring.h>
25 25
26class OQCopMessageData;
27 26
28namespace Opie 27namespace Opie{
29{ 28namespace Core{
29namespace Private {
30class OQCopMessageData;
31}
30 32
31class OQCopMessage 33class OQCopMessage
32{ 34{
33public: 35public:
34 OQCopMessage ( ); 36 OQCopMessage ( );
35 OQCopMessage ( const OQCopMessage &copy ); 37 OQCopMessage ( const OQCopMessage &copy );
36 OQCopMessage ( const QCString &m_channel, const QCString &message, const QByteArray &args = QByteArray ( )); 38 OQCopMessage ( const QCString &m_channel, const QCString &message, const QByteArray &args = QByteArray ( ));
37 39
38 OQCopMessage &operator = ( const OQCopMessage &assign ); 40 OQCopMessage &operator = ( const OQCopMessage &assign );
39 41
40 void setChannel ( const QCString &channel ); 42 void setChannel ( const QCString &channel );
41 void setMessage ( const QCString &message ); 43 void setMessage ( const QCString &message );
42 void setData ( const QByteArray &ba ); 44 void setData ( const QByteArray &ba );
43 45
44 QCString channel ( ) const; 46 QCString channel ( ) const;
45 QCString message ( ) const; 47 QCString message ( ) const;
46 QByteArray data ( ) const; 48 QByteArray data ( ) const;
47 49
48 bool isNull()const; 50 bool isNull()const;
49 51
50 bool send ( ); 52 bool send ( );
51 53
52private: 54private:
53 void init ( const QCString &m_channel, const QCString &message, const QByteArray &args ); 55 void init ( const QCString &m_channel, const QCString &message, const QByteArray &args );
54 56
55 OQCopMessageData *d; 57 Private::OQCopMessageData *d;
56 class Private; 58 class Private;
57 Private* m_data; 59 Private* m_data;
58}; 60};
59 61
60 62
61/** 63/**
62 * This class represents a physical button on a Qtopia device. A device may 64 * This class represents a physical button on a Qtopia device. A device may
63 * have n "user programmable" buttons, which are number 1..n. The location 65 * have n "user programmable" buttons, which are number 1..n. The location
64 * and number of buttons will vary from device to device. userText() and pixmap() 66 * and number of buttons will vary from device to device. userText() and pixmap()
65 * may be used to describe this button to the user in help documentation. 67 * may be used to describe this button to the user in help documentation.
66 * 68 *
67 * @version 1.0 69 * @version 1.0
68 * @author Trolltech 70 * @author Trolltech
69 * @short A representation of buttons 71 * @short A representation of buttons
70 */ 72 */
71 73
72class ODeviceButton 74class ODeviceButton
73{ 75{
74 public: 76 public:
75 ODeviceButton(); 77 ODeviceButton();
76 virtual ~ODeviceButton(); 78 virtual ~ODeviceButton();
77 79
78 ushort keycode ( ) const; 80 ushort keycode ( ) const;
79 QString userText ( ) const; 81 QString userText ( ) const;
80 QPixmap pixmap ( ) const; 82 QPixmap pixmap ( ) const;
81 OQCopMessage factoryPresetPressedAction ( ) const; 83 OQCopMessage factoryPresetPressedAction ( ) const;
82 OQCopMessage pressedAction ( ) const; 84 OQCopMessage pressedAction ( ) const;
83 OQCopMessage factoryPresetHeldAction ( ) const; 85 OQCopMessage factoryPresetHeldAction ( ) const;
84 OQCopMessage heldAction ( ) const; 86 OQCopMessage heldAction ( ) const;
85 87
86 void setKeycode ( ushort keycode ); 88 void setKeycode ( ushort keycode );
87 void setUserText ( const QString& text ); 89 void setUserText ( const QString& text );
88 void setPixmap ( const QPixmap& picture ); 90 void setPixmap ( const QPixmap& picture );
89 void setFactoryPresetPressedAction ( const OQCopMessage& qcopMessage ); 91 void setFactoryPresetPressedAction ( const OQCopMessage& qcopMessage );
90 void setPressedAction ( const OQCopMessage& qcopMessage ); 92 void setPressedAction ( const OQCopMessage& qcopMessage );
91 void setFactoryPresetHeldAction ( const OQCopMessage& qcopMessage ); 93 void setFactoryPresetHeldAction ( const OQCopMessage& qcopMessage );
92 void setHeldAction ( const OQCopMessage& qcopMessage ); 94 void setHeldAction ( const OQCopMessage& qcopMessage );
93 95
94 private: 96 private:
95 ushort m_Keycode; 97 ushort m_Keycode;
96 QString m_UserText; 98 QString m_UserText;
97 QPixmap m_Pixmap; 99 QPixmap m_Pixmap;
98 OQCopMessage m_FactoryPresetPressedAction; 100 OQCopMessage m_FactoryPresetPressedAction;
99 OQCopMessage m_PressedAction; 101 OQCopMessage m_PressedAction;
100 OQCopMessage m_FactoryPresetHeldAction; 102 OQCopMessage m_FactoryPresetHeldAction;
101 OQCopMessage m_HeldAction; 103 OQCopMessage m_HeldAction;
102 class Private; 104 class Private;
103 Private *d; 105 Private *d;
104}; 106};
105 107
106} 108}
109}
107 110
108#endif 111#endif
diff --git a/libopie2/opiecore/oapplication.cpp b/libopie2/opiecore/oapplication.cpp
index d340c0e..e2f6e82 100644
--- a/libopie2/opiecore/oapplication.cpp
+++ b/libopie2/opiecore/oapplication.cpp
@@ -1,127 +1,136 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3              Copyright (C) 2003 Michael 'Mickey' Lauer <mickey@Vanille.de> 3              Copyright (C) 2003 Michael 'Mickey' Lauer <mickey@Vanille.de>
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 <opie2/oapplication.h> 30#include <opie2/oapplication.h>
31#include <opie2/oconfig.h> 31#include <opie2/oconfig.h>
32#include <opie2/odebug.h> 32#include <opie2/odebug.h>
33 33
34#include <signal.h> 34#include <signal.h>
35#include <stdio.h> 35#include <stdio.h>
36 36
37using namespace Opie::Core;
38
39
37OApplication* OApplication::_instance = 0; 40OApplication* OApplication::_instance = 0;
38 41
39/************************************************************************************************** 42/**************************************************************************************************
40 * OApplicationPrivate 43 * OApplicationPrivate
41 **************************************************************************************************/ 44 **************************************************************************************************/
42 45
46namespace Opie {
47namespace Core {
48namespace Private {
43class OApplicationPrivate 49class OApplicationPrivate
44{ 50{
45 public: 51 public:
46 OApplicationPrivate() {}; 52 OApplicationPrivate() {};
47 ~OApplicationPrivate() {}; 53 ~OApplicationPrivate() {};
48}; 54};
55}
49 56
50/************************************************************************************************** 57/**************************************************************************************************
51 * OApplication 58 * OApplication
52 **************************************************************************************************/ 59 **************************************************************************************************/
53 60
54 61
55OApplication::OApplication( int& argc, char** argv, const QCString& rAppName ) 62OApplication::OApplication( int& argc, char** argv, const QCString& rAppName )
56 :QPEApplication( argc, argv ), 63 :QPEApplication( argc, argv ),
57 _appname( rAppName ), 64 _appname( rAppName ),
58 _config( 0 ) 65 _config( 0 )
59{ 66{
60 init(); 67 init();
61} 68}
62 69
63 70
64OApplication::~OApplication() 71OApplication::~OApplication()
65{ 72{
66 delete d; 73 delete d;
67 if ( _config ) 74 if ( _config )
68 delete _config; 75 delete _config;
69 OApplication::_instance = 0; 76 OApplication::_instance = 0;
70 // after deconstruction of the one-and-only application object, 77 // after deconstruction of the one-and-only application object,
71 // the construction of another object is allowed 78 // the construction of another object is allowed
72} 79}
73 80
74 81
75OConfig* OApplication::config() 82OConfig* OApplication::config()
76{ 83{
77 if ( !_config ) 84 if ( !_config )
78 { 85 {
79 _config = new OConfig( _appname ); 86 _config = new OConfig( _appname );
80 } 87 }
81 return _config; 88 return _config;
82} 89}
83 90
84 91
85void OApplication::init() 92void OApplication::init()
86{ 93{
87 d = new OApplicationPrivate(); 94 d = new Private::OApplicationPrivate();
88 if ( !OApplication::_instance ) 95 if ( !OApplication::_instance )
89 { 96 {
90 OApplication::_instance = this; 97 OApplication::_instance = this;
91 98
92 /* register SIGSEGV handler to give programs an option 99 /* register SIGSEGV handler to give programs an option
93 * to exit gracefully, e.g. save or close devices or files. 100 * to exit gracefully, e.g. save or close devices or files.
94 struct sigaction sa; 101 struct sigaction sa;
95 sa.sa_handler = ( void (*)(int) ) &segv_handler; 102 sa.sa_handler = ( void (*)(int) ) &segv_handler;
96 sa.sa_flags = SA_SIGINFO | SA_RESTART; 103 sa.sa_flags = SA_SIGINFO | SA_RESTART;
97 sigemptyset(&sa.sa_mask); 104 sigemptyset(&sa.sa_mask);
98 sigaction(SIGSEGV, &sa, NULL); 105 sigaction(SIGSEGV, &sa, NULL);
99 */ 106 */
100 } 107 }
101 else 108 else
102 { 109 {
103 ofatal << "OApplication: Can't create more than one OApplication object. Aborting." << oendl; 110 ofatal << "OApplication: Can't create more than one OApplication object. Aborting." << oendl;
104 //FIXME exit gracefully ? 111 //FIXME exit gracefully ?
105 ::exit( -1 ); 112 ::exit( -1 );
106 } 113 }
107} 114}
108 115
109 116
110void OApplication::showMainWidget( QWidget* widget, bool nomax ) 117void OApplication::showMainWidget( QWidget* widget, bool nomax )
111{ 118{
112 QPEApplication::showMainWidget( widget, nomax ); 119 QPEApplication::showMainWidget( widget, nomax );
113 widget->setCaption( _appname ); 120 widget->setCaption( _appname );
114} 121}
115 122
116 123
117void OApplication::setTitle( const QString& title ) const 124void OApplication::setTitle( const QString& title ) const
118{ 125{
119 if ( mainWidget() ) 126 if ( mainWidget() )
120 { 127 {
121 if ( !title.isNull() ) 128 if ( !title.isNull() )
122 mainWidget()->setCaption( QString(_appname) + QString( " - " ) + title ); 129 mainWidget()->setCaption( QString(_appname) + QString( " - " ) + title );
123 else 130 else
124 mainWidget()->setCaption( _appname ); 131 mainWidget()->setCaption( _appname );
125 } 132 }
126} 133}
127 134
135}
136}
diff --git a/libopie2/opiecore/oapplication.h b/libopie2/opiecore/oapplication.h
index cc506a2..c1e32a6 100644
--- a/libopie2/opiecore/oapplication.h
+++ b/libopie2/opiecore/oapplication.h
@@ -1,104 +1,111 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3              Copyright (C) 2003 Michael 'Mickey' Lauer <mickey@Vanille.de> 3              Copyright (C) 2003 Michael 'Mickey' Lauer <mickey@Vanille.de>
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#ifndef OAPPLICATION_H 30#ifndef OAPPLICATION_H
31#define OAPPLICATION_H 31#define OAPPLICATION_H
32 32
33#define oApp OApplication::oApplication() 33#define oApp Opie::Core::OApplication::oApplication()
34 34
35 35
36#include <qpe/qpeapplication.h> 36#include <qpe/qpeapplication.h>
37 37
38 38namespace Opie {
39namespace Core {
40namespace Private {
39class OApplicationPrivate; 41class OApplicationPrivate;
42} // private class
43
40class OConfig; 44class OConfig;
41 45
42 46
43class OApplication : public QPEApplication 47class OApplication : public QPEApplication
44{ 48{
45 Q_OBJECT 49 Q_OBJECT
46 50
47 public: 51 public:
48 /** 52 /**
49 * Constructor. Parses command-line arguments and sets the window caption. 53 * Constructor. Parses command-line arguments and sets the window caption.
50 * 54 *
51 * @param rAppName application name. Will be used for finding the 55 * @param rAppName application name. Will be used for finding the
52 * associated message, icon and configuration files 56 * associated message, icon and configuration files
53 * 57 *
54 */ 58 */
55 OApplication( int& argc, char** argv, const QCString& rAppName ); 59 OApplication( int& argc, char** argv, const QCString& rAppName );
56 /** 60 /**
57 * Destructor. Destroys the application object and its children. 61 * Destructor. Destroys the application object and its children.
58 */ 62 */
59 virtual ~OApplication(); 63 virtual ~OApplication();
60 /** 64 /**
61 * @returns the process-wide application object 65 * @returns the process-wide application object
62 * 66 *
63 * This is similar to the global @ref QApplication pointer qApp. It 67 * This is similar to the global @ref QApplication pointer qApp. It
64 * allows access to the single global OApplication object, since 68 * allows access to the single global OApplication object, since
65 * more than one cannot be created in the same application. It 69 * more than one cannot be created in the same application. It
66 * saves you the trouble of having to pass the pointer explicitly 70 * saves you the trouble of having to pass the pointer explicitly
67 * to every function that may require it. 71 * to every function that may require it.
68 */ 72 */
69 static OApplication* oApplication() { return _instance; }; 73 static OApplication* oApplication() { return _instance; };
70 /** 74 /**
71 * Returns the application name as given during creation. 75 * Returns the application name as given during creation.
72 * 76 *
73 * @returns a reference to the application name 77 * @returns a reference to the application name
74 */ 78 */
75 const QCString& appName() const { return _appname; }; 79 const QCString& appName() const { return _appname; };
76 /** 80 /**
77 * @returns the application session config object. 81 * @returns the application session config object.
78 * 82 *
79 * @see OConfig 83 * @see OConfig
80 */ 84 */
81 OConfig* config(); 85 OConfig* config();
82 /** 86 /**
83 * Shows the main @a widget and sets the name of the application as window caption. 87 * Shows the main @a widget and sets the name of the application as window caption.
84 */ 88 */
85 virtual void showMainWidget( QWidget* widget, bool nomax = false ); 89 virtual void showMainWidget( QWidget* widget, bool nomax = false );
86 /** 90 /**
87 * Set the application title. The application title will be concatenated 91 * Set the application title. The application title will be concatenated
88 * to the application name given in the constructor. 92 * to the application name given in the constructor.
89 * 93 *
90 * @param title the title. If not given, resets caption to appname 94 * @param title the title. If not given, resets caption to appname
91 */ 95 */
92 virtual void setTitle( const QString& title = QString::null ) const; 96 virtual void setTitle( const QString& title = QString::null ) const;
93 97
94 protected: 98 protected:
95 void init(); 99 void init();
96 100
97 private: 101 private:
98 const QCString _appname; 102 const QCString _appname;
99 static OApplication* _instance; 103 static OApplication* _instance;
100 OConfig* _config; 104 OConfig* _config;
101 OApplicationPrivate* d; 105 Private::OApplicationPrivate* d;
102}; 106};
103 107
108} // Core
109} // Opie
110
104#endif // OAPPLICATION_H 111#endif // OAPPLICATION_H
diff --git a/libopie2/opiecore/oconfig.cpp b/libopie2/opiecore/oconfig.cpp
index fb5eabb..05d8070 100644
--- a/libopie2/opiecore/oconfig.cpp
+++ b/libopie2/opiecore/oconfig.cpp
@@ -1,88 +1,90 @@
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 Lauer <mickey@tm.informatik.uni-frankfurt.de> 4 (C) 2003 Michael Lauer <mickey@tm.informatik.uni-frankfurt.de>
5 Inspired by the config classes from the KDE Project which are 5 Inspired by the config classes from the KDE Project which are
6 =. (C) 1997 Matthias Kalle Dalheimer <kalle@kde.org> 6 =. (C) 1997 Matthias Kalle Dalheimer <kalle@kde.org>
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/* QT */ 32/* QT */
33 33
34#include <qfont.h> 34#include <qfont.h>
35#include <qcolor.h> 35#include <qcolor.h>
36 36
37/* OPIE */ 37/* OPIE */
38 38
39#include <opie2/oconfig.h> 39#include <opie2/oconfig.h>
40 40
41using namespace Opie::Core;
42
41OConfig::OConfig( const QString &name, Domain domain ) 43OConfig::OConfig( const QString &name, Domain domain )
42 :Config( name, domain ) 44 :Config( name, domain )
43{ 45{
44 qDebug( "OConfig::OConfig()" ); 46 qDebug( "OConfig::OConfig()" );
45} 47}
46 48
47OConfig::~OConfig() 49OConfig::~OConfig()
48{ 50{
49 qDebug( "OConfig::~OConfig()" ); 51 qDebug( "OConfig::~OConfig()" );
50} 52}
51 53
52QColor OConfig::readColorEntry( const QString& key, const QColor* pDefault ) const 54QColor OConfig::readColorEntry( const QString& key, const QColor* pDefault ) const
53{ 55{
54 QColor aRetColor; 56 QColor aRetColor;
55 int nRed = 0, nGreen = 0, nBlue = 0; 57 int nRed = 0, nGreen = 0, nBlue = 0;
56 58
57 QString aValue = readEntry( key ); 59 QString aValue = readEntry( key );
58 if( !aValue.isEmpty() ) 60 if( !aValue.isEmpty() )
59 { 61 {
60 if ( aValue.at(0) == '#' ) 62 if ( aValue.at(0) == '#' )
61 { 63 {
62 aRetColor.setNamedColor(aValue); 64 aRetColor.setNamedColor(aValue);
63 } 65 }
64 else 66 else
65 { 67 {
66 bool bOK; 68 bool bOK;
67 69
68 // find first part (red) 70 // find first part (red)
69 int nIndex = aValue.find( ',' ); 71 int nIndex = aValue.find( ',' );
70 72
71 if( nIndex == -1 ) 73 if( nIndex == -1 )
72 { 74 {
73 // return a sensible default -- Bernd 75 // return a sensible default -- Bernd
74 if( pDefault ) 76 if( pDefault )
75 aRetColor = *pDefault; 77 aRetColor = *pDefault;
76 return aRetColor; 78 return aRetColor;
77 } 79 }
78 80
79 nRed = aValue.left( nIndex ).toInt( &bOK ); 81 nRed = aValue.left( nIndex ).toInt( &bOK );
80 82
81 // find second part (green) 83 // find second part (green)
82 int nOldIndex = nIndex; 84 int nOldIndex = nIndex;
83 nIndex = aValue.find( ',', nOldIndex+1 ); 85 nIndex = aValue.find( ',', nOldIndex+1 );
84 86
85 if( nIndex == -1 ) 87 if( nIndex == -1 )
86 { 88 {
87 // return a sensible default -- Bernd 89 // return a sensible default -- Bernd
88 if( pDefault ) 90 if( pDefault )
diff --git a/libopie2/opiecore/oconfig.h b/libopie2/opiecore/oconfig.h
index becf70d..29c1f86 100644
--- a/libopie2/opiecore/oconfig.h
+++ b/libopie2/opiecore/oconfig.h
@@ -1,141 +1,154 @@
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 Inspired by the config classes from the KDE Project which are 5 Inspired by the config classes from the KDE Project which are
6 =. (C) 1997 Matthias Kalle Dalheimer <kalle@kde.org> 6 =. (C) 1997 Matthias Kalle Dalheimer <kalle@kde.org>
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#ifndef OCONFIG_H 32#ifndef OCONFIG_H
33#define OCONFIG_H 33#define OCONFIG_H
34 34
35//FIXME: Implement for X11 or reuse libqpe/Config there also? 35//FIXME: Implement for X11 or reuse libqpe/Config there also?
36//FIXME: Or rather use QSettings also for libqpe? 36//FIXME: Or rather use QSettings also for libqpe?
37 37
38#include <qpe/config.h> 38#include <qpe/config.h>
39 39
40class QColor; 40class QColor;
41class QFont; 41class QFont;
42 42
43namespace Opie {
44namespace Core {
45
43/** 46/**
44 * A Configuration class based on the Qtopia @ref Config class 47 * A Configuration class based on the Qtopia @ref Config class
45 * featuring additional handling of color and font entries 48 * featuring additional handling of color and font entries
46 */ 49 */
47 50
48class OConfig : public Config 51class OConfig : public Config
49{ 52{
50 public: 53 public:
51 /** 54 /**
52 * Constructs a OConfig object with a @a name. 55 * Constructs a OConfig object with a @a name.
53 */ 56 */
54 OConfig( const QString &name, Domain domain = User ); 57 OConfig( const QString &name, Domain domain = User );
55 /** 58 /**
56 * Destructs the OConfig object. 59 * Destructs the OConfig object.
57 * 60 *
58 * Writes back any dirty configuration entries, and destroys 61 * Writes back any dirty configuration entries, and destroys
59 * dynamically created objects. 62 * dynamically created objects.
60 */ 63 */
61 virtual ~OConfig(); 64 virtual ~OConfig();
62 /** 65 /**
63 * @returns the name of the current group. 66 * @returns the name of the current group.
64 * The current group is used for searching keys and accessing entries. 67 * The current group is used for searching keys and accessing entries.
68 * @todo make const
65 */ 69 */
66 const QString& group() { return git.key(); }; 70 const QString& group() { return git.key(); };
67 /** 71 /**
68 * @returns a @ref QColor entry or a @a default value if the key is not found. 72 * @returns a @ref QColor entry or a @a default value if the key is not found.
69 */ 73 */
70 QColor readColorEntry( const QString& key, const QColor* pDefault ) const; 74 QColor readColorEntry( const QString& key, const QColor* pDefault ) const;
71 /** 75 /**
72 * @returns a @ref QFont value or a @a default value if the key is not found. 76 * @returns a @ref QFont value or a @a default value if the key is not found.
73 */ 77 */
74 QFont readFontEntry( const QString& key, const QFont* pDefault ) const; 78 QFont readFontEntry( const QString& key, const QFont* pDefault ) const;
79
80private:
81 class Private;
82 Private *d;
75}; 83};
76 84
77/** 85/**
78 * @brief Helper class for easier use of OConfig groups. 86 * @brief Helper class for easier use of OConfig groups.
79 * 87 *
80 * Careful programmers always set the group of a 88 * Careful programmers always set the group of a
81 * @ref OConfig object to the group they want to read from 89 * @ref OConfig object to the group they want to read from
82 * and set it back to the old one of afterwards. This is usually 90 * and set it back to the old one of afterwards. This is usually
83 * written as: 91 * written as:
84 * <pre> 92 * <pre>
85 * 93 *
86 * QString oldgroup config()->group(); 94 * QString oldgroup config()->group();
87 * config()->setGroup( "TheGroupThatIWant" ); 95 * config()->setGroup( "TheGroupThatIWant" );
88 * ... 96 * ...
89 * config()->writeEntry( "Blah", "Blubb" ); 97 * config()->writeEntry( "Blah", "Blubb" );
90 * 98 *
91 * config()->setGroup( oldgroup ); 99 * config()->setGroup( oldgroup );
92 * </pre> 100 * </pre>
93 * 101 *
94 * In order to facilitate this task, you can use 102 * In order to facilitate this task, you can use
95 * OConfigGroupSaver. Simply construct such an object ON THE STACK 103 * OConfigGroupSaver. Simply construct such an object ON THE STACK
96 * when you want to switch to a new group. Then, when the object goes 104 * when you want to switch to a new group. Then, when the object goes
97 * out of scope, the group will automatically be restored. If you 105 * out of scope, the group will automatically be restored. If you
98 * want to use several different groups within a function or method, 106 * want to use several different groups within a function or method,
99 * you can still use OConfigGroupSaver: Simply enclose all work with 107 * you can still use OConfigGroupSaver: Simply enclose all work with
100 * one group (including the creation of the OConfigGroupSaver object) 108 * one group (including the creation of the OConfigGroupSaver object)
101 * in one block. 109 * in one block.
102 * 110 *
103 * @author Matthias Kalle Dalheimer <Kalle@kde.org> 111 * @author Matthias Kalle Dalheimer <Kalle@kde.org>
104 * @version $Id$ 112 * @version $Id$
105 * @see OConfig 113 * @see OConfig
106 */ 114 */
107 115
108class OConfigGroupSaver 116class OConfigGroupSaver
109{ 117{
110 public: 118 public:
111 /** 119 /**
112 * Constructor. 120 * Constructor.
113 * Create the object giving a @config object and a @a group to become 121 * Create the object giving a @config object and a @a group to become
114 * the current group. 122 * the current group.
115 */ 123 */
116 OConfigGroupSaver( OConfig* config, QString group ) :_config(config), _oldgroup(config->group() ) 124 OConfigGroupSaver( OConfig* config, QString group ) :_config(config), _oldgroup(config->group() )
117 { _config->setGroup( group ); } 125 { _config->setGroup( group ); }
118 126
119 OConfigGroupSaver( OConfig* config, const char *group ) :_config(config), _oldgroup(config->group()) 127 OConfigGroupSaver( OConfig* config, const char *group ) :_config(config), _oldgroup(config->group())
120 { _config->setGroup( group ); } 128 { _config->setGroup( group ); }
121 129
122 OConfigGroupSaver( OConfig* config, const QCString &group ) : _config(config), _oldgroup(config->group()) 130 OConfigGroupSaver( OConfig* config, const QCString &group ) : _config(config), _oldgroup(config->group())
123 { _config->setGroup( group ); } 131 { _config->setGroup( group ); }
124 /** 132 /**
125 * Destructor. 133 * Destructor.
126 * Restores the last current group. 134 * Restores the last current group.
127 * @todo make it not inline for bc reasons. See KDE BC guide 135 * @todo make it not inline for bc reasons. See KDE BC guide
128 */ 136 */
129 ~OConfigGroupSaver() { _config->setGroup( _oldgroup ); } 137 ~OConfigGroupSaver() { _config->setGroup( _oldgroup ); }
130 138
131 OConfig* config() { return _config; }; 139 OConfig* config() { return _config; };
132 140
133 private: 141 private:
134 OConfig* _config; 142 OConfig* _config;
135 QString _oldgroup; 143 QString _oldgroup;
136 144
137 OConfigGroupSaver( const OConfigGroupSaver& ); 145 OConfigGroupSaver( const OConfigGroupSaver& );
138 OConfigGroupSaver& operator=( const OConfigGroupSaver& ); 146 OConfigGroupSaver& operator=( const OConfigGroupSaver& );
147
148 class Private;
149 Private *d;
139}; 150};
151}
152}
140 153
141#endif // OCONFIG_H 154#endif // OCONFIG_H
diff --git a/libopie2/opiecore/odebug.cpp b/libopie2/opiecore/odebug.cpp
index a40ef53..cac985b 100644
--- a/libopie2/opiecore/odebug.cpp
+++ b/libopie2/opiecore/odebug.cpp
@@ -20,97 +20,98 @@
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// Include this header without OPIE_NO_DEBUG defined to avoid having the oDebugInfo 32// Include this header without OPIE_NO_DEBUG defined to avoid having the oDebugInfo
33// functions inlined to noops (which would then conflict with their definition here). 33// functions inlined to noops (which would then conflict with their definition here).
34 34
35#include <opie2/odebug.h> 35#include <opie2/odebug.h>
36 36
37#ifdef OPIE_NO_DEBUG 37#ifdef OPIE_NO_DEBUG
38#undef odDebug 38#undef odDebug
39#undef odBacktrace 39#undef odBacktrace
40#endif 40#endif
41 41
42/* OPIE */ 42/* OPIE */
43 43
44#include <opie2/oapplication.h> 44#include <opie2/oapplication.h>
45#include <opie2/oglobalsettings.h> 45#include <opie2/oglobalsettings.h>
46#include <opie2/oconfig.h> 46#include <opie2/oconfig.h>
47 47
48/* QT */ 48/* QT */
49 49
50#include <qfile.h> 50#include <qfile.h>
51#include <qmessagebox.h> 51#include <qmessagebox.h>
52#include <qsocketdevice.h> 52#include <qsocketdevice.h>
53 53
54/* UNIX */ 54/* UNIX */
55 55
56#include <stdlib.h> // abort 56#include <stdlib.h> // abort
57#include <unistd.h> // getpid 57#include <unistd.h> // getpid
58#include <stdarg.h> // vararg stuff 58#include <stdarg.h> // vararg stuff
59#include <ctype.h> // isprint 59#include <ctype.h> // isprint
60#include <syslog.h> 60#include <syslog.h>
61#include <errno.h> 61#include <errno.h>
62#include <string.h> 62#include <string.h>
63 63
64#ifndef OPIE_NO_BACKTRACE 64#ifndef OPIE_NO_BACKTRACE
65#include <execinfo.h> 65#include <execinfo.h>
66#endif 66#endif
67 67
68 68namespace Opie {
69namespace Core {
69/*====================================================================================== 70/*======================================================================================
70 * debug levels 71 * debug levels
71 *======================================================================================*/ 72 *======================================================================================*/
72 73
73enum DebugLevels { 74enum DebugLevels {
74 ODEBUG_INFO = 0, 75 ODEBUG_INFO = 0,
75 ODEBUG_WARN = 1, 76 ODEBUG_WARN = 1,
76 ODEBUG_ERROR = 2, 77 ODEBUG_ERROR = 2,
77 ODEBUG_FATAL = 3 78 ODEBUG_FATAL = 3
78}; 79};
79 80
80/*====================================================================================== 81/*======================================================================================
81 * oDebug private data 82 * oDebug private data
82 *======================================================================================*/ 83 *======================================================================================*/
83 84
84/*====================================================================================== 85/*======================================================================================
85 * the main debug function 86 * the main debug function
86 *======================================================================================*/ 87 *======================================================================================*/
87 88
88static void oDebugBackend( unsigned short level, unsigned int area, const char *data) 89static void oDebugBackend( unsigned short level, unsigned int area, const char *data)
89{ 90{
90 //qDebug( "oDebugBackend: Level=%d, Area=%d, Data=%s", level, area, data ); 91 //qDebug( "oDebugBackend: Level=%d, Area=%d, Data=%s", level, area, data );
91 92
92 // ML: OPIE doesn't use areacodes at the moment. See the KDE debug classes for an 93 // ML: OPIE doesn't use areacodes at the moment. See the KDE debug classes for an
93 // ML: example use. I think it's not necessary to implement such a strategy here. 94 // ML: example use. I think it's not necessary to implement such a strategy here.
94 // ML: Comments? 95 // ML: Comments?
95 96
96 int priority = 0; 97 int priority = 0;
97 QString caption; 98 QString caption;
98 QString lev; 99 QString lev;
99 switch( level ) 100 switch( level )
100 { 101 {
101 case ODEBUG_INFO: lev = "(Info)"; caption = "Info"; priority = LOG_INFO; break; 102 case ODEBUG_INFO: lev = "(Info)"; caption = "Info"; priority = LOG_INFO; break;
102 case ODEBUG_WARN: lev = "(Warn)"; caption = "Warning"; priority = LOG_WARNING; break; 103 case ODEBUG_WARN: lev = "(Warn)"; caption = "Warning"; priority = LOG_WARNING; break;
103 case ODEBUG_FATAL: lev = "(Fatal)"; caption = "Fatal Error"; priority = LOG_CRIT; break; 104 case ODEBUG_FATAL: lev = "(Fatal)"; caption = "Fatal Error"; priority = LOG_CRIT; break;
104 default: qDebug( "oDebugBackend: Warning: Unknown debug level! - defaulting to ODEBUG_ERROR." ); 105 default: qDebug( "oDebugBackend: Warning: Unknown debug level! - defaulting to ODEBUG_ERROR." );
105 case ODEBUG_ERROR: lev = "(Error)"; caption = "Error"; priority = LOG_ERR; break; 106 case ODEBUG_ERROR: lev = "(Error)"; caption = "Error"; priority = LOG_ERR; break;
106 } 107 }
107 108
108 short output = OGlobalSettings::debugMode(); 109 short output = OGlobalSettings::debugMode();
109 if (!oApp && (output == 1)) 110 if (!oApp && (output == 1))
110 { 111 {
111 qDebug( "oDebugBackend: Warning: no oapplication object - can't use MsgBox" ); 112 qDebug( "oDebugBackend: Warning: no oapplication object - can't use MsgBox" );
112 output = 2; // need an application object to use MsgBox 113 output = 2; // need an application object to use MsgBox
113 } 114 }
114 115
115 // gcc 2.9x is dumb and sucks... can you hear it? 116 // gcc 2.9x is dumb and sucks... can you hear it?
116 //QString areaName = (oApp) ? oApp->appName() : "<unknown>"; 117 //QString areaName = (oApp) ? oApp->appName() : "<unknown>";
@@ -569,52 +570,56 @@ odbgstream& odbgstream::operator<<( const QBrush& b)
569 "DiagCrossPattern" }; 570 "DiagCrossPattern" };
570 571
571 *this <<"[ style: "; 572 *this <<"[ style: ";
572 *this <<s_brushStyles[ b.style() ]; 573 *this <<s_brushStyles[ b.style() ];
573 *this <<" color: "; 574 *this <<" color: ";
574 // can't use operator<<(str, b.color()) because that terminates a odbgstream (flushes) 575 // can't use operator<<(str, b.color()) because that terminates a odbgstream (flushes)
575 if ( b.color().isValid() ) 576 if ( b.color().isValid() )
576 *this <<b.color().name() ; 577 *this <<b.color().name() ;
577 else 578 else
578 *this <<"(invalid/default)"; 579 *this <<"(invalid/default)";
579 if ( b.pixmap() ) 580 if ( b.pixmap() )
580 *this <<" has a pixmap"; 581 *this <<" has a pixmap";
581 *this <<" ]"; 582 *this <<" ]";
582 return *this; 583 return *this;
583} 584}
584 585
585 586
586 587
587QString odBacktrace( int levels ) 588QString odBacktrace( int levels )
588{ 589{
589 QString s; 590 QString s;
590#ifndef OPIE_NO_BACKTRACE 591#ifndef OPIE_NO_BACKTRACE
591 void* trace[256]; 592 void* trace[256];
592 int n = backtrace(trace, 256); 593 int n = backtrace(trace, 256);
593 char** strings = backtrace_symbols (trace, n); 594 char** strings = backtrace_symbols (trace, n);
594 595
595 if ( levels != -1 ) 596 if ( levels != -1 )
596 n = QMIN( n, levels ); 597 n = QMIN( n, levels );
597 s = "[\n"; 598 s = "[\n";
598 599
599 for (int i = 0; i < n; ++i) 600 for (int i = 0; i < n; ++i)
600 s += QString::number(i) + 601 s += QString::number(i) +
601 QString::fromLatin1(": ") + 602 QString::fromLatin1(": ") +
602 QString::fromLatin1(strings[i]) + QString::fromLatin1("\n"); 603 QString::fromLatin1(strings[i]) + QString::fromLatin1("\n");
603 s += "]\n"; 604 s += "]\n";
604 free (strings); 605 free (strings);
605#endif 606#endif
606 return s; 607 return s;
607} 608}
608 609
609void odClearDebugConfig() 610void odClearDebugConfig()
610{ 611{
611 /* 612 /*
612 delete oDebug_data->config; 613 delete oDebug_data->config;
613 oDebug_data->config = 0; 614 oDebug_data->config = 0;
614 */ 615 */
615} 616}
616 617
618
617#ifdef OPIE_NO_DEBUG 619#ifdef OPIE_NO_DEBUG
618#define odDebug ondDebug 620#define odDebug ondDebug
619#define odBacktrace ondBacktrace 621#define odBacktrace ondBacktrace
620#endif 622#endif
623
624}
625} \ No newline at end of file
diff --git a/libopie2/opiecore/odebug.h b/libopie2/opiecore/odebug.h
index 85941fd..a5c9ded 100644
--- a/libopie2/opiecore/odebug.h
+++ b/libopie2/opiecore/odebug.h
@@ -2,96 +2,99 @@
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 (C) 2003 Michael 'Mickey' Lauer (mickey@tm.informatik.uni-frankfurt.de) 3 (C) 2003 Michael 'Mickey' Lauer (mickey@tm.informatik.uni-frankfurt.de)
4 Inspired by the KDE debug classes, which are 4 Inspired by the KDE debug classes, which are
5 (C) 1997 Matthias Kalle Dalheimer (kalle@kde.org) 5 (C) 1997 Matthias Kalle Dalheimer (kalle@kde.org)
6 (C) 2002 Holger Freyther (freyther@kde.org) 6 (C) 2002 Holger Freyther (freyther@kde.org)
7 =. 7 =.
8 .=l. 8 .=l.
9           .>+-= 9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 12:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
13.="- .-=="i,     .._ License as published by the Free Software 13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; Library General Public License for more 22..}^=.=       =       ; Library General Public License for more
23++=   -.     .`     .: details. 23++=   -.     .`     .: details.
24 :     =  ...= . :.=- 24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = Library General Public License along with 26  -_. . .   )=.  = Library General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31*/ 31*/
32 32
33#ifndef ODEBUG_H 33#ifndef ODEBUG_H
34#define ODEBUG_H 34#define ODEBUG_H
35 35
36#include <qstring.h> 36#include <qstring.h>
37 37
38class QWidget; 38class QWidget;
39class QDateTime; 39class QDateTime;
40class QDate; 40class QDate;
41class QTime; 41class QTime;
42class QPoint; 42class QPoint;
43class QSize; 43class QSize;
44class QRect; 44class QRect;
45class QRegion; 45class QRegion;
46class QStringList; 46class QStringList;
47class QColor; 47class QColor;
48class QBrush; 48class QBrush;
49 49
50namespace Opie {
51namespace Core {
52
50class odbgstream; 53class odbgstream;
51class ondbgstream; 54class ondbgstream;
52 55
53#ifdef __GNUC__ 56#ifdef __GNUC__
54#define o_funcinfo "[" << __PRETTY_FUNCTION__ << "] " 57#define o_funcinfo "[" << __PRETTY_FUNCTION__ << "] "
55#else 58#else
56#define o_funcinfo "[" << __FILE__ << ":" << __LINE__ << "] " 59#define o_funcinfo "[" << __FILE__ << ":" << __LINE__ << "] "
57#endif 60#endif
58 61
59#define o_lineinfo "[" << __FILE__ << ":" << __LINE__ << "] " 62#define o_lineinfo "[" << __FILE__ << ":" << __LINE__ << "] "
60 63
61#define owarn odWarning() 64#define owarn odWarning()
62#define oerr odError() 65#define oerr odError()
63#define odebug odDebug() 66#define odebug odDebug()
64#define ofatal odFatal() 67#define ofatal odFatal()
65#define oendl "\n" 68#define oendl "\n"
66 69
67class odbgstreamprivate; 70class odbgstreamprivate;
68/** 71/**
69 * odbgstream is a text stream that allows you to print debug messages. 72 * odbgstream is a text stream that allows you to print debug messages.
70 * Using the overloaded "<<" operator you can send messages. Usually 73 * Using the overloaded "<<" operator you can send messages. Usually
71 * you do not create the odbgstream yourself, but use @ref odDebug() (odebug) 74 * you do not create the odbgstream yourself, but use @ref odDebug() (odebug)
72 * @ref odWarning() (owarn), @ref odError() (oerr) or @ref odFatal (ofatal) to obtain one. 75 * @ref odWarning() (owarn), @ref odError() (oerr) or @ref odFatal (ofatal) to obtain one.
73 * 76 *
74 * Example: 77 * Example:
75 * <pre> 78 * <pre>
76 * int i = 5; 79 * int i = 5;
77 * odebug << "The value of i is " << i << oendl; 80 * odebug << "The value of i is " << i << oendl;
78 * </pre> 81 * </pre>
79 * @see odbgstream 82 * @see odbgstream
80 */ 83 */
81 84
82/*====================================================================================== 85/*======================================================================================
83 * odbgstream 86 * odbgstream
84 *======================================================================================*/ 87 *======================================================================================*/
85 88
86class odbgstream 89class odbgstream
87{ 90{
88 public: 91 public:
89 /** 92 /**
90 * @internal 93 * @internal
91 */ 94 */
92 odbgstream(unsigned int _area, unsigned int _level, bool _print = true); 95 odbgstream(unsigned int _area, unsigned int _level, bool _print = true);
93 odbgstream(const char * initialString, unsigned int _area, unsigned int _level, bool _print = true); 96 odbgstream(const char * initialString, unsigned int _area, unsigned int _level, bool _print = true);
94 odbgstream(odbgstream &str); 97 odbgstream(odbgstream &str);
95 odbgstream(const odbgstream &str); 98 odbgstream(const odbgstream &str);
96 virtual ~odbgstream(); 99 virtual ~odbgstream();
97 100
@@ -349,126 +352,132 @@ class ondbgstream {
349 */ 352 */
350 ondbgstream &operator<<(const char *) { return *this; } 353 ondbgstream &operator<<(const char *) { return *this; }
351 /** 354 /**
352 * Does nothing. 355 * Does nothing.
353 * @return this stream 356 * @return this stream
354 */ 357 */
355 ondbgstream& operator<<(const void *) { return *this; } 358 ondbgstream& operator<<(const void *) { return *this; }
356 /** 359 /**
357 * Does nothing. 360 * Does nothing.
358 * @return this stream 361 * @return this stream
359 */ 362 */
360 ondbgstream& operator<<(void *) { return *this; } 363 ondbgstream& operator<<(void *) { return *this; }
361 /** 364 /**
362 * Does nothing. 365 * Does nothing.
363 * @return this stream 366 * @return this stream
364 */ 367 */
365 ondbgstream& operator<<(double) { return *this; } 368 ondbgstream& operator<<(double) { return *this; }
366 /** 369 /**
367 * Does nothing. 370 * Does nothing.
368 * @return this stream 371 * @return this stream
369 */ 372 */
370 ondbgstream& operator<<(long) { return *this; } 373 ondbgstream& operator<<(long) { return *this; }
371 /** 374 /**
372 * Does nothing. 375 * Does nothing.
373 * @return this stream 376 * @return this stream
374 */ 377 */
375 ondbgstream& operator<<(unsigned long) { return *this; } 378 ondbgstream& operator<<(unsigned long) { return *this; }
376 /** 379 /**
377 * Does nothing. 380 * Does nothing.
378 * @return this stream 381 * @return this stream
379 */ 382 */
380 ondbgstream& operator << (QWidget*) { return *this; } 383 ondbgstream& operator << (QWidget*) { return *this; }
381 /** 384 /**
382 * Does nothing. 385 * Does nothing.
383 * @return this stream 386 * @return this stream
384 */ 387 */
385 ondbgstream &form(const char *, ...) { return *this; } 388 ondbgstream &form(const char *, ...) { return *this; }
386 389
387 ondbgstream& operator<<( const QDateTime& ) { return *this; } 390 ondbgstream& operator<<( const QDateTime& ) { return *this; }
388 ondbgstream& operator<<( const QDate& ) { return *this; } 391 ondbgstream& operator<<( const QDate& ) { return *this; }
389 ondbgstream& operator<<( const QTime& ) { return *this; } 392 ondbgstream& operator<<( const QTime& ) { return *this; }
390 ondbgstream& operator<<( const QPoint & ) { return *this; } 393 ondbgstream& operator<<( const QPoint & ) { return *this; }
391 ondbgstream& operator<<( const QSize & ) { return *this; } 394 ondbgstream& operator<<( const QSize & ) { return *this; }
392 ondbgstream& operator<<( const QRect & ) { return *this; } 395 ondbgstream& operator<<( const QRect & ) { return *this; }
393 ondbgstream& operator<<( const QRegion & ) { return *this; } 396 ondbgstream& operator<<( const QRegion & ) { return *this; }
394 ondbgstream& operator<<( const QStringList & ) { return *this; } 397 ondbgstream& operator<<( const QStringList & ) { return *this; }
395 ondbgstream& operator<<( const QColor & ) { return *this; } 398 ondbgstream& operator<<( const QColor & ) { return *this; }
396 ondbgstream& operator<<( const QBrush & ) { return *this; } 399 ondbgstream& operator<<( const QBrush & ) { return *this; }
400
401private:
402 class Private;
403 Private *d;
397}; 404};
398 405
399/*====================================================================================== 406/*======================================================================================
400 * related functions 407 * related functions
401 *======================================================================================*/ 408 *======================================================================================*/
402 409
403/** 410/**
404 * Does nothing. 411 * Does nothing.
405 * @param a stream 412 * @param a stream
406 * @return the given @p s 413 * @return the given @p s
407 */ 414 */
408inline ondbgstream& endl( ondbgstream & s) { return s; } 415inline ondbgstream& endl( ondbgstream & s) { return s; }
409/** 416/**
410 * Does nothing. 417 * Does nothing.
411 * @param a stream 418 * @param a stream
412 * @return the given @p s 419 * @return the given @p s
413 */ 420 */
414inline ondbgstream& flush( ondbgstream & s) { return s; } 421inline ondbgstream& flush( ondbgstream & s) { return s; }
415inline ondbgstream& perror( ondbgstream & s) { return s; } 422inline ondbgstream& perror( ondbgstream & s) { return s; }
416 423
417/** 424/**
418 * Returns a debug stream. You can use it to print debug 425 * Returns a debug stream. You can use it to print debug
419 * information. 426 * information.
420 * @param area an id to identify the output, 0 for default 427 * @param area an id to identify the output, 0 for default
421 */ 428 */
422odbgstream odDebug(int area = 0); 429odbgstream odDebug(int area = 0);
423odbgstream odDebug(bool cond, int area = 0); 430odbgstream odDebug(bool cond, int area = 0);
424/** 431/**
425 * Returns a backtrace. 432 * Returns a backtrace.
426 * @param levels the number of levels (-1 for unlimited) of the backtrace 433 * @param levels the number of levels (-1 for unlimited) of the backtrace
427 * @return a backtrace 434 * @return a backtrace
428 */ 435 */
429QString odBacktrace(int levels = -1); 436QString odBacktrace(int levels = -1);
430/** 437/**
431 * Returns a dummy debug stream. The stream does not print anything. 438 * Returns a dummy debug stream. The stream does not print anything.
432 * @param area an id to identify the output, 0 for default 439 * @param area an id to identify the output, 0 for default
433 * @see odDebug() 440 * @see odDebug()
434 */ 441 */
435inline ondbgstream ondDebug(int = 0) { return ondbgstream(); } 442inline ondbgstream ondDebug(int = 0) { return ondbgstream(); }
436inline ondbgstream ondDebug(bool , int = 0) { return ondbgstream(); } 443inline ondbgstream ondDebug(bool , int = 0) { return ondbgstream(); }
437inline QString ondBacktrace() { return QString::null; } 444inline QString ondBacktrace() { return QString::null; }
438inline QString ondBacktrace(int) { return QString::null; } 445inline QString ondBacktrace(int) { return QString::null; }
439 446
440/** 447/**
441 * Returns a warning stream. You can use it to print warning 448 * Returns a warning stream. You can use it to print warning
442 * information. 449 * information.
443 * @param area an id to identify the output, 0 for default 450 * @param area an id to identify the output, 0 for default
444 */ 451 */
445odbgstream odWarning(int area = 0); 452odbgstream odWarning(int area = 0);
446odbgstream odWarning(bool cond, int area = 0); 453odbgstream odWarning(bool cond, int area = 0);
447/** 454/**
448 * Returns an error stream. You can use it to print error 455 * Returns an error stream. You can use it to print error
449 * information. 456 * information.
450 * @param area an id to identify the output, 0 for default 457 * @param area an id to identify the output, 0 for default
451 */ 458 */
452odbgstream odError(int area = 0); 459odbgstream odError(int area = 0);
453odbgstream odError(bool cond, int area = 0); 460odbgstream odError(bool cond, int area = 0);
454/** 461/**
455 * Returns a fatal error stream. You can use it to print fatal error 462 * Returns a fatal error stream. You can use it to print fatal error
456 * information. 463 * information.
457 * @param area an id to identify the output, 0 for default 464 * @param area an id to identify the output, 0 for default
458 */ 465 */
459odbgstream odFatal(int area = 0); 466odbgstream odFatal(int area = 0);
460odbgstream odFatal(bool cond, int area = 0); 467odbgstream odFatal(bool cond, int area = 0);
461 468
462/** 469/**
463 * Deletes the odebugrc cache and therefore forces KDebug to reread the 470 * Deletes the odebugrc cache and therefore forces KDebug to reread the
464 * config file 471 * config file
465 */ 472 */
466void odClearDebugConfig(); 473void odClearDebugConfig();
467 474
468#ifdef OPIE_NO_DEBUG 475#ifdef OPIE_NO_DEBUG
469#define odDebug ondDebug 476#define odDebug ondDebug
470#define odBacktrace ondBacktrace 477#define odBacktrace ondBacktrace
471#endif 478#endif
472 479
473#endif 480#endif
474 481
482}
483}
diff --git a/libopie2/opiecore/oglobal.cpp b/libopie2/opiecore/oglobal.cpp
index 1aa206e..ea02058 100644
--- a/libopie2/opiecore/oglobal.cpp
+++ b/libopie2/opiecore/oglobal.cpp
@@ -1,88 +1,90 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) 2003 Michael 'Mickey' Lauer <mickey@Vanille.de> 3 Copyright (C) 2003 Michael 'Mickey' Lauer <mickey@Vanille.de>
4 =. Copyright (C) 2004 Holger 'zecke' Freyther <zecke@handhelds.org> 4 =. Copyright (C) 2004 Holger 'zecke' Freyther <zecke@handhelds.org>
5 .=l. 5 .=l.
6 .>+-= 6 .>+-=
7 _;:, .> :=|. This program is free software; you can 7 _;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under 8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11 - . .-<_> .<> Foundation; either version 2 of the License, 11 - . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_. 13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 20++= -. .` .: details.
21 : = ...= . :.=- 21 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU 22 -. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29 29
30#include <opie2/oglobal.h> 30#include <opie2/oglobal.h>
31 31
32#include <qtextstream.h> 32#include <qtextstream.h>
33#include <qdir.h> 33#include <qdir.h>
34#include <qpe/mimetype.h> 34#include <qpe/mimetype.h>
35#include <qpe/qpeapplication.h> 35#include <qpe/qpeapplication.h>
36#include <qpe/storage.h> 36#include <qpe/storage.h>
37 37
38#include <unistd.h> 38#include <unistd.h>
39#include <sys/types.h> 39#include <sys/types.h>
40 40
41using namespace Opie::Core;
42
41static const char Base64EncMap[64] = 43static const char Base64EncMap[64] =
42{ 44{
43 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 45 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48,
44 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 46 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50,
45 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 47 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58,
46 0x59, 0x5A, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 48 0x59, 0x5A, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66,
47 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 49 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E,
48 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 50 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76,
49 0x77, 0x78, 0x79, 0x7A, 0x30, 0x31, 0x32, 0x33, 51 0x77, 0x78, 0x79, 0x7A, 0x30, 0x31, 0x32, 0x33,
50 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x2B, 0x2F 52 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x2B, 0x2F
51}; 53};
52 54
53static char Base64DecMap[128] = 55static char Base64DecMap[128] =
54{ 56{
55 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 57 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
56 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 58 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
57 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 59 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
58 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 60 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
59 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 61 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
60 0x00, 0x00, 0x00, 0x3E, 0x00, 0x00, 0x00, 0x3F, 62 0x00, 0x00, 0x00, 0x3E, 0x00, 0x00, 0x00, 0x3F,
61 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 63 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B,
62 0x3C, 0x3D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 64 0x3C, 0x3D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
63 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 65 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06,
64 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 66 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E,
65 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 67 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16,
66 0x17, 0x18, 0x19, 0x00, 0x00, 0x00, 0x00, 0x00, 68 0x17, 0x18, 0x19, 0x00, 0x00, 0x00, 0x00, 0x00,
67 0x00, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 69 0x00, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20,
68 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 70 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28,
69 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30, 71 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30,
70 0x31, 0x32, 0x33, 0x00, 0x00, 0x00, 0x00, 0x00 72 0x31, 0x32, 0x33, 0x00, 0x00, 0x00, 0x00, 0x00
71}; 73};
72 74
73 75
74OConfig* OGlobal::_config = 0; 76OConfig* OGlobal::_config = 0;
75OConfig* OGlobal::_qpe_config = 0; 77OConfig* OGlobal::_qpe_config = 0;
76 78
77OConfig* OGlobal::config() 79OConfig* OGlobal::config()
78{ 80{
79 if ( !OGlobal::_config ) 81 if ( !OGlobal::_config )
80 { 82 {
81 // odebug classes are reading config, so can't use them here! 83 // odebug classes are reading config, so can't use them here!
82 qDebug( "OGlobal::creating global configuration instance." ); 84 qDebug( "OGlobal::creating global configuration instance." );
83 OGlobal::_config = new OConfig( "global" ); 85 OGlobal::_config = new OConfig( "global" );
84 } 86 }
85 return OGlobal::_config; 87 return OGlobal::_config;
86} 88}
87 89
88 90
@@ -267,108 +269,108 @@ QByteArray OGlobal::decodeBase64( const QByteArray& in) {
267 { 269 {
268 // Adhere to RFC 2045 and ignore characters 270 // Adhere to RFC 2045 and ignore characters
269 // that are not part of the encoding table. 271 // that are not part of the encoding table.
270 unsigned char ch = data[idx]; 272 unsigned char ch = data[idx];
271 if ( (ch > 47 && ch < 58) || (ch > 64 && ch < 91 ) || 273 if ( (ch > 47 && ch < 58) || (ch > 64 && ch < 91 ) ||
272 (ch > 96 && ch < 123)|| ch == '+' || ch == '/' || ch == '=') 274 (ch > 96 && ch < 123)|| ch == '+' || ch == '/' || ch == '=')
273 { 275 {
274 out[outIdx++] = Base64DecMap[ch]; 276 out[outIdx++] = Base64DecMap[ch];
275 } 277 }
276 else 278 else
277 { 279 {
278 len--; 280 len--;
279 tail--; 281 tail--;
280 } 282 }
281 } 283 }
282 284
283 // kdDebug() << "Tail size = " << tail << ", Length size = " << len << endl; 285 // kdDebug() << "Tail size = " << tail << ", Length size = " << len << endl;
284 286
285 // 4-byte to 3-byte conversion 287 // 4-byte to 3-byte conversion
286 len = (tail>(len/4)) ? tail-(len/4) : 0; 288 len = (tail>(len/4)) ? tail-(len/4) : 0;
287 unsigned int sidx = 0, didx = 0; 289 unsigned int sidx = 0, didx = 0;
288 if ( len > 1 ) 290 if ( len > 1 )
289 { 291 {
290 while (didx < len-2) 292 while (didx < len-2)
291 { 293 {
292 out[didx] = (((out[sidx] << 2) & 255) | ((out[sidx+1] >> 4) & 003)); 294 out[didx] = (((out[sidx] << 2) & 255) | ((out[sidx+1] >> 4) & 003));
293 out[didx+1] = (((out[sidx+1] << 4) & 255) | ((out[sidx+2] >> 2) & 017)); 295 out[didx+1] = (((out[sidx+1] << 4) & 255) | ((out[sidx+2] >> 2) & 017));
294 out[didx+2] = (((out[sidx+2] << 6) & 255) | (out[sidx+3] & 077)); 296 out[didx+2] = (((out[sidx+2] << 6) & 255) | (out[sidx+3] & 077));
295 sidx += 4; 297 sidx += 4;
296 didx += 3; 298 didx += 3;
297 } 299 }
298 } 300 }
299 301
300 if (didx < len) 302 if (didx < len)
301 out[didx] = (((out[sidx] << 2) & 255) | ((out[sidx+1] >> 4) & 003)); 303 out[didx] = (((out[sidx] << 2) & 255) | ((out[sidx+1] >> 4) & 003));
302 304
303 if (++didx < len ) 305 if (++didx < len )
304 out[didx] = (((out[sidx+1] << 4) & 255) | ((out[sidx+2] >> 2) & 017)); 306 out[didx] = (((out[sidx+1] << 4) & 255) | ((out[sidx+2] >> 2) & 017));
305 307
306 // Resize the output buffer 308 // Resize the output buffer
307 if ( len == 0 || len < out.size() ) 309 if ( len == 0 || len < out.size() )
308 out.resize(len); 310 out.resize(len);
309 311
310 return out; 312 return out;
311} 313}
312 314
313bool OGlobal::isAppLnkFileName( const QString& str ) 315bool OGlobal::isAppLnkFileName( const QString& str )
314{ 316{
315 if (str.length()==0||str.at(str.length()-1)==QDir::separator()) return false; 317 if (str.isEmpty()||str.at(str.length()-1)==QDir::separator()) return false;
316 return str.startsWith(MimeType::appsFolderName()+QDir::separator()); 318 return str.startsWith(MimeType::appsFolderName()+QDir::separator());
317} 319}
318 320
319/* ToDo: 321/* ToDo:
320 * This fun should check the document-path value for the mounted media 322 * This fun should check the document-path value for the mounted media
321 * which has to be implemented later. this moment we just check for a 323 * which has to be implemented later. this moment we just check for a
322 * mounted media name. 324 * mounted media name.
323 */ 325 */
324bool OGlobal::isDocumentFileName( const QString& file ) 326bool OGlobal::isDocumentFileName( const QString& file )
325{ 327{
326 if (file.length()==0||file.at(file.length()-1)==QDir::separator()) return false; 328 if (file.isEmpty()||file.at(file.length()-1)==QDir::separator()) return false;
327 if (file.startsWith(QPEApplication::documentDir()+QDir::separator())) return true; 329 if (file.startsWith(QPEApplication::documentDir()+QDir::separator())) return true;
328 StorageInfo si; 330 StorageInfo si;
329 QList< FileSystem > fl = si.fileSystems(); 331 QList< FileSystem > fl = si.fileSystems();
330 FileSystem*fs; 332 FileSystem*fs;
331 for (fs = fl.first();fs!=0;fs=fl.next()) { 333 for (fs = fl.first();fs!=0;fs=fl.next()) {
332 if (fs->isRemovable()&&file.startsWith(fs->name()+QDir::separator())) 334 if (fs->isRemovable()&&file.startsWith(fs->name()+QDir::separator()))
333 return true; 335 return true;
334 } 336 }
335 if (file.startsWith(homeDirPath())+"/Documents/") return true; 337 if (file.startsWith(homeDirPath())+"/Documents/") return true;
336 return false; 338 return false;
337} 339}
338 340
339QString OGlobal::tempDirPath() 341QString OGlobal::tempDirPath()
340{ 342{
341 static QString defstring="/tmp"; 343 static QString defstring="/tmp";
342 char * tmpp = 0; 344 char * tmpp = 0;
343 if ( (tmpp=getenv("TEMP"))) { 345 if ( (tmpp=getenv("TEMP"))) {
344 return tmpp; 346 return tmpp;
345 } 347 }
346 return defstring; 348 return defstring;
347} 349}
348 350
349QString OGlobal::homeDirPath() 351QString OGlobal::homeDirPath()
350{ 352{
351 char * tmpp = getenv("HOME"); 353 char * tmpp = getenv("HOME");
352 return (tmpp?tmpp:"/"); 354 return (tmpp?tmpp:"/");
353} 355}
354 356
355bool OGlobal::weekStartsOnMonday() 357bool OGlobal::weekStartsOnMonday()
356{ 358{
357 OConfig*conf=OGlobal::qpe_config(); 359 OConfig*conf=OGlobal::qpe_config();
358 if (!conf)return false; 360 if (!conf)return false;
359 conf->setGroup("Time"); 361 conf->setGroup("Time");
360 return conf->readBoolEntry("MONDAY",true); 362 return conf->readBoolEntry("MONDAY",true);
361} 363}
362 364
363void OGlobal::setWeekStartsOnMonday( bool what) 365void OGlobal::setWeekStartsOnMonday( bool what)
364{ 366{
365 OConfig*conf=OGlobal::qpe_config(); 367 OConfig*conf=OGlobal::qpe_config();
366 if (!conf)return; 368 if (!conf)return;
367 conf->setGroup("Time"); 369 conf->setGroup("Time");
368 return conf->writeEntry("MONDAY",what); 370 return conf->writeEntry("MONDAY",what);
369} 371}
370 372
371bool OGlobal::useAMPM() 373bool OGlobal::useAMPM()
372{ 374{
373 OConfig*conf=OGlobal::qpe_config(); 375 OConfig*conf=OGlobal::qpe_config();
374 if (!conf)return false; 376 if (!conf)return false;
diff --git a/libopie2/opiecore/oglobal.h b/libopie2/opiecore/oglobal.h
index aeee75e..e6a6c46 100644
--- a/libopie2/opiecore/oglobal.h
+++ b/libopie2/opiecore/oglobal.h
@@ -7,145 +7,153 @@
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#ifndef OGLOBAL_H 30#ifndef OGLOBAL_H
31#define OGLOBAL_H 31#define OGLOBAL_H
32 32
33 33
34#include <opie2/oconfig.h> 34#include <opie2/oconfig.h>
35 35
36#ifndef private 36#ifndef private
37#define HACK_DEFINED 37#define HACK_DEFINED
38#define private protected 38#define private protected
39#endif 39#endif
40#include <qpe/global.h> 40#include <qpe/global.h>
41#ifdef HACK_DEFINED 41#ifdef HACK_DEFINED
42#undef private 42#undef private
43#endif 43#endif
44 44
45#include <sys/types.h> 45#include <sys/types.h>
46 46
47//FIXME Is it wise or even necessary to inherit OGlobal from Global? 47//FIXME Is it wise or even necessary to inherit OGlobal from Global?
48// once we totally skip libqpe it should ideally swallow Global -zecke 48// once we totally skip libqpe it should ideally swallow Global -zecke
49// You're right. I deleted global as the base class. -mickeyl 49// You're right. I deleted global as the base class. -mickeyl
50 50
51 51
52class QFile; 52class QFile;
53class QString; 53class QString;
54class DateFormat; 54class DateFormat;
55
56
57
58namespace Opie {
59namespace Core {
55/** 60/**
56 *\brief OGlobal contains a list of generic functions 61 *\brief OGlobal contains a list of generic functions
57 * 62 *
58 * The class OGlobal contains small utility functions 63 * The class OGlobal contains small utility functions
59 * which might be useful for other applications to use. It features access 64 * which might be useful for other applications to use. It features access
60 * to the global device config and specialized functions to get information 65 * to the global device config and specialized functions to get information
61 * out of this config like Weekstart or Owner name. 66 * out of this config like Weekstart or Owner name.
62 * 67 *
63 * @todo ODP implement the things from Global which are good 68 * @todo ODP implement the things from Global which are good
64 * @author mickey,alwin,zecke 69 * @author mickey,alwin,zecke
65 * @version 0.1 70 * @version 0.1
66 */ 71 */
67class OGlobal : public Global 72class OGlobal : public Global
68{ 73{
69public: 74public:
70 75
71 // how do they relate to our Document Idea 76 // how do they relate to our Document Idea
72 /** @name Document System related functions 77 /** @name Document System related functions
73 * 78 *
74 */ 79 */
75 //@{ 80 //@{
76 static bool isAppLnkFileName( const QString& str ); 81 static bool isAppLnkFileName( const QString& str );
77 static bool isDocumentFileName( const QString& file ); 82 static bool isDocumentFileName( const QString& file );
78 //@} 83 //@}
79 84
80 /** @name File Operations 85 /** @name File Operations
81 * File operations provided by OGlobal 86 * File operations provided by OGlobal
82 */ 87 */
83 //@{ 88 //@{
84 /** the content of TEMP 89 /** the content of TEMP
85 * reads the environment variable TEMP and returns the content. 90 * reads the environment variable TEMP and returns the content.
86 * if not set returns "/tmp" 91 * if not set returns "/tmp"
87 * @return a string containing a dir without trailing slash! 92 * @return a string containing a dir without trailing slash!
88 */ 93 */
89 static QString tempDirPath(); 94 static QString tempDirPath();
90 /** the content of HOME 95 /** the content of HOME
91 * reads the environment variable HOME and returns the content. 96 * reads the environment variable HOME and returns the content.
92 * if not set returns "/" 97 * if not set returns "/"
93 * @return a string containing a dir without trailing slash! 98 * @return a string containing a dir without trailing slash!
94 */ 99 */
95 static QString homeDirPath(); 100 static QString homeDirPath();
96 static QString tempFileName( const QString& ); 101 static QString tempFileName( const QString& );
97 static bool renameFile( const QString& from, const QString& to ); 102 static bool renameFile( const QString& from, const QString& to );
98 static bool truncateFile( QFile &f, off_t size ); 103 static bool truncateFile( QFile &f, off_t size );
99 //@} 104 //@}
100 105
101 106
102 static QString generateUuid(); 107 static QString generateUuid();
103 108
104 /** @name Convert Content 109 /** @name Convert Content
105 * Convert Content of a QByteArray 110 * Convert Content of a QByteArray
106 */ 111 */
107 //@{ 112 //@{
108 static QByteArray encodeBase64(const QByteArray&, bool insertLF = false ); 113 static QByteArray encodeBase64(const QByteArray&, bool insertLF = false );
109 static QByteArray decodeBase64(const QByteArray& ); 114 static QByteArray decodeBase64(const QByteArray& );
110 //@} 115 //@}
111 116
112 //FIXME Do we want to put that into OApplication as in KApplication? -zecke 117 //FIXME Do we want to put that into OApplication as in KApplication? -zecke
113 // We already have a per-application config in OApplication 118 // We already have a per-application config in OApplication
114 // ( accessed through oApp->config() ), but this one is the global one! -mickeyl 119 // ( accessed through oApp->config() ), but this one is the global one! -mickeyl
115 /** @name Config and Owner related Information 120 /** @name Config and Owner related Information
116 * 121 *
117 */ 122 */
118 //@{ 123 //@{
119 static OConfig* config(); 124 static OConfig* config();
120 static OConfig* qpe_config(); 125 static OConfig* qpe_config();
121 static QString ownerName(); 126 static QString ownerName();
122 static bool weekStartsOnMonday(); 127 static bool weekStartsOnMonday();
123 static bool useAMPM(); 128 static bool useAMPM();
124#ifdef ODP 129#ifdef ODP
125#error "Fix dateFormat" 130#error "Fix dateFormat"
126 /** 131 /**
127 * For Qt3/Qt4 we can use QDate::toString(OGlobal::dateFormat) 132 * For Qt3/Qt4 we can use QDate::toString(OGlobal::dateFormat)
128 * See if we need to use the function with String in it 133 * See if we need to use the function with String in it
129 * Anyway this is the future 134 * Anyway this is the future
130 * for now still use TimeString! 135 * for now still use TimeString!
131 */ 136 */
132#endif 137#endif
133 static DateFormat dateFormat(); 138 static DateFormat dateFormat();
134 static void setDateFormat( const DateFormat& ); 139 static void setDateFormat( const DateFormat& );
135 140
136 141
137 static void setWeekStartsOnMonday( bool ); 142 static void setWeekStartsOnMonday( bool );
138 static void setUseAMPM( bool ); 143 static void setUseAMPM( bool );
139 //@} 144 //@}
140 145
141 //@{ 146 //@{
142 static Global::Command* builtinCommands(); 147 static Global::Command* builtinCommands();
143 static QGuardedPtr<QWidget>* builtinRunning(); 148 static QGuardedPtr<QWidget>* builtinRunning();
144 //@} 149 //@}
145 150
146private: 151private:
147 static OConfig* _config; 152 static OConfig* _config;
148 static OConfig* _qpe_config; 153 static OConfig* _qpe_config;
154 class Private;
155 Private *d;
149}; 156};
150 157}
158}
151#endif // OGLOBAL_H 159#endif // OGLOBAL_H
diff --git a/libopie2/opiecore/oglobalsettings.cpp b/libopie2/opiecore/oglobalsettings.cpp
index 192e55b..f34c531 100644
--- a/libopie2/opiecore/oglobalsettings.cpp
+++ b/libopie2/opiecore/oglobalsettings.cpp
@@ -1,94 +1,97 @@
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 Lauer <mickey@tm.informatik.uni-frankfurt.de> 4              Copyright (C) 2003 Michael Lauer <mickey@tm.informatik.uni-frankfurt.de>
5 Inspired by the KDE globalsettings which are 5 Inspired by the KDE globalsettings which are
6 Copyright (C) 2000 David Faure <faure@kde.org> 6 Copyright (C) 2000 David Faure <faure@kde.org>
7 =. 7 =.
8 .=l. 8 .=l.
9           .>+-= 9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 12:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
13.="- .-=="i,     .._ License as published by the Free Software 13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; Library General Public License for more 22..}^=.=       =       ; Library General Public License for more
23++=   -.     .`     .: details. 23++=   -.     .`     .: details.
24 :     =  ...= . :.=- 24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = Library General Public License along with 26  -_. . .   )=.  = Library General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31*/ 31*/
32 32
33/* OPIE */ 33/* OPIE */
34 34
35#include <opie2/oglobalsettings.h> 35#include <opie2/oglobalsettings.h>
36#include <opie2/oconfig.h> 36#include <opie2/oconfig.h>
37#include <opie2/oglobal.h> 37#include <opie2/oglobal.h>
38 38
39/* QT */ 39/* QT */
40 40
41#include <qdir.h> 41#include <qdir.h>
42 42
43/* UNIX */ 43/* UNIX */
44 44
45#include <stdlib.h> 45#include <stdlib.h>
46 46
47
48using namespace Opie::Core;
49
47QString* OGlobalSettings::s_desktopPath = 0; 50QString* OGlobalSettings::s_desktopPath = 0;
48QString* OGlobalSettings::s_autostartPath = 0; 51QString* OGlobalSettings::s_autostartPath = 0;
49QString* OGlobalSettings::s_trashPath = 0; 52QString* OGlobalSettings::s_trashPath = 0;
50QString* OGlobalSettings::s_documentPath = 0; 53QString* OGlobalSettings::s_documentPath = 0;
51QFont *OGlobalSettings::_generalFont = 0; 54QFont *OGlobalSettings::_generalFont = 0;
52QFont *OGlobalSettings::_fixedFont = 0; 55QFont *OGlobalSettings::_fixedFont = 0;
53QFont *OGlobalSettings::_toolBarFont = 0; 56QFont *OGlobalSettings::_toolBarFont = 0;
54QFont *OGlobalSettings::_menuFont = 0; 57QFont *OGlobalSettings::_menuFont = 0;
55QFont *OGlobalSettings::_windowTitleFont = 0; 58QFont *OGlobalSettings::_windowTitleFont = 0;
56QFont *OGlobalSettings::_taskbarFont = 0; 59QFont *OGlobalSettings::_taskbarFont = 0;
57 60
58QColor *OGlobalSettings::OpieGray = 0; 61QColor *OGlobalSettings::OpieGray = 0;
59QColor *OGlobalSettings::OpieHighlight = 0; 62QColor *OGlobalSettings::OpieHighlight = 0;
60QColor *OGlobalSettings::OpieAlternate = 0; 63QColor *OGlobalSettings::OpieAlternate = 0;
61 64
62OGlobalSettings::OMouseSettings *OGlobalSettings::s_mouseSettings = 0; 65OGlobalSettings::OMouseSettings *OGlobalSettings::s_mouseSettings = 0;
63 66
64//FIXME: Add manipulators to the accessors 67//FIXME: Add manipulators to the accessors
65 68
66int OGlobalSettings::dndEventDelay() 69int OGlobalSettings::dndEventDelay()
67{ 70{
68 OConfig *c = OGlobal::config(); 71 OConfig *c = OGlobal::config();
69 OConfigGroupSaver cgs( c, "General" ); 72 OConfigGroupSaver cgs( c, "General" );
70 return c->readNumEntry("DndDelay", 2); 73 return c->readNumEntry("DndDelay", 2);
71} 74}
72 75
73bool OGlobalSettings::singleClick() 76bool OGlobalSettings::singleClick()
74{ 77{
75 OConfig *c = OGlobal::config(); 78 OConfig *c = OGlobal::config();
76 OConfigGroupSaver cgs( c, "OPIE" ); 79 OConfigGroupSaver cgs( c, "OPIE" );
77 return c->readBoolEntry("SingleClick", OPIE_DEFAULT_SINGLECLICK); 80 return c->readBoolEntry("SingleClick", OPIE_DEFAULT_SINGLECLICK);
78} 81}
79 82
80bool OGlobalSettings::insertTearOffHandle() 83bool OGlobalSettings::insertTearOffHandle()
81{ 84{
82 OConfig *c = OGlobal::config(); 85 OConfig *c = OGlobal::config();
83 OConfigGroupSaver cgs( c, "OPIE" ); 86 OConfigGroupSaver cgs( c, "OPIE" );
84 return c->readBoolEntry("InsertTearOffHandle", OPIE_DEFAULT_INSERTTEAROFFHANDLES); 87 return c->readBoolEntry("InsertTearOffHandle", OPIE_DEFAULT_INSERTTEAROFFHANDLES);
85} 88}
86 89
87bool OGlobalSettings::changeCursorOverIcon() 90bool OGlobalSettings::changeCursorOverIcon()
88{ 91{
89 OConfig *c = OGlobal::config(); 92 OConfig *c = OGlobal::config();
90 OConfigGroupSaver cgs( c, "OPIE" ); 93 OConfigGroupSaver cgs( c, "OPIE" );
91 return c->readBoolEntry("ChangeCursor", OPIE_DEFAULT_CHANGECURSOR); 94 return c->readBoolEntry("ChangeCursor", OPIE_DEFAULT_CHANGECURSOR);
92} 95}
93 96
94bool OGlobalSettings::visualActivate() 97bool OGlobalSettings::visualActivate()
diff --git a/libopie2/opiecore/oglobalsettings.h b/libopie2/opiecore/oglobalsettings.h
index e3ac148..8eea709 100644
--- a/libopie2/opiecore/oglobalsettings.h
+++ b/libopie2/opiecore/oglobalsettings.h
@@ -1,99 +1,105 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3              Copyright (C) 2003 Michael Lauer <mickey@tm.informatik.uni-frankfurt.de> 3              Copyright (C) 2003 Michael Lauer <mickey@tm.informatik.uni-frankfurt.de>
4 Inspired by KDE OGlobalSettings 4 Inspired by KDE OGlobalSettings
5 Copyright (C) 2000 David Faure <faure@kde.org> 5 Copyright (C) 2000 David Faure <faure@kde.org>
6 =. 6 =.
7 .=l. 7 .=l.
8           .>+-= 8           .>+-=
9 _;:,     .>    :=|. This program is free software; you can 9 _;:,     .>    :=|. This program is free software; you can
10.> <`_,   >  .   <= redistribute it and/or modify it under 10.> <`_,   >  .   <= redistribute it and/or modify it under
11:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 11:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
12.="- .-=="i,     .._ License as published by the Free Software 12.="- .-=="i,     .._ License as published by the Free Software
13 - .   .-<_>     .<> Foundation; either version 2 of the License, 13 - .   .-<_>     .<> Foundation; either version 2 of the License,
14     ._= =}       : or (at your option) any later version. 14     ._= =}       : or (at your option) any later version.
15    .%`+i>       _;_. 15    .%`+i>       _;_.
16    .i_,=:_.      -<s. This program is distributed in the hope that 16    .i_,=:_.      -<s. This program is distributed in the hope that
17     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 17     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
18    : ..    .:,     . . . without even the implied warranty of 18    : ..    .:,     . . . without even the implied warranty of
19    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 19    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
20  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 20  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
21..}^=.=       =       ; Library General Public License for more 21..}^=.=       =       ; Library General Public License for more
22++=   -.     .`     .: details. 22++=   -.     .`     .: details.
23 :     =  ...= . :.=- 23 :     =  ...= . :.=-
24 -.   .:....=;==+<; You should have received a copy of the GNU 24 -.   .:....=;==+<; You should have received a copy of the GNU
25  -_. . .   )=.  = Library General Public License along with 25  -_. . .   )=.  = Library General Public License along with
26    --        :-=` this library; see the file COPYING.LIB. 26    --        :-=` this library; see the file COPYING.LIB.
27 If not, write to the Free Software Foundation, 27 If not, write to the Free Software Foundation,
28 Inc., 59 Temple Place - Suite 330, 28 Inc., 59 Temple Place - Suite 330,
29 Boston, MA 02111-1307, USA. 29 Boston, MA 02111-1307, USA.
30*/ 30*/
31 31
32#ifndef OGLOBALSETTINGS_H 32#ifndef OGLOBALSETTINGS_H
33#define OGLOBALSETTINGS_H 33#define OGLOBALSETTINGS_H
34 34
35#include <qstring.h> 35#include <qstring.h>
36#include <qcolor.h> 36#include <qcolor.h>
37#include <qfont.h> 37#include <qfont.h>
38 38
39/**
40 * \todo make real const values
41 */
39#define OPIE_DEFAULT_SINGLECLICK true 42#define OPIE_DEFAULT_SINGLECLICK true
40#define OPIE_DEFAULT_INSERTTEAROFFHANDLES true 43#define OPIE_DEFAULT_INSERTTEAROFFHANDLES true
41#define OPIE_DEFAULT_AUTOSELECTDELAY -1 44#define OPIE_DEFAULT_AUTOSELECTDELAY -1
42#define OPIE_DEFAULT_CHANGECURSOR true 45#define OPIE_DEFAULT_CHANGECURSOR true
43#define OPIE_DEFAULT_LARGE_CURSOR false 46#define OPIE_DEFAULT_LARGE_CURSOR false
44#define OPIE_DEFAULT_VISUAL_ACTIVATE true 47#define OPIE_DEFAULT_VISUAL_ACTIVATE true
45#define OPIE_DEFAULT_VISUAL_ACTIVATE_SPEED 50 48#define OPIE_DEFAULT_VISUAL_ACTIVATE_SPEED 50
46 49
47//FIXME: There's still a whole lot of stuff in here which has to be revised 50//FIXME: There's still a whole lot of stuff in here which has to be revised
48//FIXME: before public usage... lack of time to do it at once - so it will 51//FIXME: before public usage... lack of time to do it at once - so it will
49//FIXME: happen step-by-step. ML. 52//FIXME: happen step-by-step. ML.
50// we should not habe too much configure options!!!!!! -zecke 53// we should not habe too much configure options!!!!!! -zecke
51 54
55namespace Opie {
56namespace Core {
57
52/** 58/**
53 * Access the OPIE global configuration settings. 59 * Access the OPIE global configuration settings.
54 * 60 *
55 */ 61 */
56class OGlobalSettings 62class OGlobalSettings
57{ 63{
58 public: 64 public:
59 65
60 /** 66 /**
61 * Returns a threshold in pixels for drag & drop operations. 67 * Returns a threshold in pixels for drag & drop operations.
62 * As long as the mouse movement has not exceeded this number 68 * As long as the mouse movement has not exceeded this number
63 * of pixels in either X or Y direction no drag operation may 69 * of pixels in either X or Y direction no drag operation may
64 * be started. This prevents spurious drags when the user intended 70 * be started. This prevents spurious drags when the user intended
65 * to click on something but moved the mouse a bit while doing so. 71 * to click on something but moved the mouse a bit while doing so.
66 * 72 *
67 * For this to work you must save the position of the mouse (oldPos) 73 * For this to work you must save the position of the mouse (oldPos)
68 * in the @ref QWidget::mousePressEvent(). 74 * in the @ref QWidget::mousePressEvent().
69 * When the position of the mouse (newPos) 75 * When the position of the mouse (newPos)
70 * in a @ref QWidget::mouseMoveEvent() exceeds this threshold 76 * in a @ref QWidget::mouseMoveEvent() exceeds this threshold
71 * you may start a drag 77 * you may start a drag
72 * which should originate from oldPos. 78 * which should originate from oldPos.
73 * 79 *
74 * Example code: 80 * Example code:
75 * <pre> 81 * <pre>
76 * void OColorCells::mousePressEvent( QMouseEvent *e ) 82 * void OColorCells::mousePressEvent( QMouseEvent *e )
77 * { 83 * {
78 * mOldPos = e->pos(); 84 * mOldPos = e->pos();
79 * } 85 * }
80 * 86 *
81 * void OColorCells::mouseMoveEvent( QMouseEvent *e ) 87 * void OColorCells::mouseMoveEvent( QMouseEvent *e )
82 * { 88 * {
83 * if( !(e->state() && LeftButton)) return; 89 * if( !(e->state() && LeftButton)) return;
84 * 90 *
85 * int delay = OGlobalSettings::dndEventDelay(); 91 * int delay = OGlobalSettings::dndEventDelay();
86 * QPoint newPos = e->pos(); 92 * QPoint newPos = e->pos();
87 * if(newPos.x() > mOldPos.x()+delay || newPos.x() < mOldPos.x()-delay || 93 * if(newPos.x() > mOldPos.x()+delay || newPos.x() < mOldPos.x()-delay ||
88 * newPos.y() > mOldPos.y()+delay || newPos.y() < mOldPos.y()-delay) 94 * newPos.y() > mOldPos.y()+delay || newPos.y() < mOldPos.y()-delay)
89 * { 95 * {
90 * // Drag color object 96 * // Drag color object
91 * int cell = posToCell(mOldPos); // Find color at mOldPos 97 * int cell = posToCell(mOldPos); // Find color at mOldPos
92 * if ((cell != -1) && colors[cell].isValid()) 98 * if ((cell != -1) && colors[cell].isValid())
93 * { 99 * {
94 * OColorDrag *d = OColorDrag::makeDrag( colors[cell], this); 100 * OColorDrag *d = OColorDrag::makeDrag( colors[cell], this);
95 * d->dragCopy(); 101 * d->dragCopy();
96 * } 102 * }
97 * } 103 * }
98 * } 104 * }
99 * </pre> 105 * </pre>
@@ -323,51 +329,57 @@ class OGlobalSettings
323 * if the user wants OPIE to run on all of them or just on the primary 329 * if the user wants OPIE to run on all of them or just on the primary
324 */ 330 */
325 static bool isMultiHead(); 331 static bool isMultiHead();
326 332
327private: 333private:
328 /** 334 /**
329 * reads in all paths from kdeglobals 335 * reads in all paths from kdeglobals
330 */ 336 */
331 static void initStatic(); 337 static void initStatic();
332 /** 338 /**
333 * initialise kde2Blue 339 * initialise kde2Blue
334 */ 340 */
335 static void initColors(); 341 static void initColors();
336 /** 342 /**
337 * drop cached values for fonts (called by OApplication) 343 * drop cached values for fonts (called by OApplication)
338 */ 344 */
339 static void rereadFontSettings(); 345 static void rereadFontSettings();
340 /** 346 /**
341 * drop cached values for paths (called by OApplication) 347 * drop cached values for paths (called by OApplication)
342 */ 348 */
343 static void rereadPathSettings(); 349 static void rereadPathSettings();
344 /** 350 /**
345 * drop cached values for mouse settings (called by OApplication) 351 * drop cached values for mouse settings (called by OApplication)
346 */ 352 */
347 static void rereadMouseSettings(); 353 static void rereadMouseSettings();
348 354
349 355
350 static QString* s_desktopPath; 356 static QString* s_desktopPath;
351 static QString* s_autostartPath; 357 static QString* s_autostartPath;
352 static QString* s_trashPath; 358 static QString* s_trashPath;
353 static QString* s_documentPath; 359 static QString* s_documentPath;
354 static QFont *_generalFont; 360 static QFont *_generalFont;
355 static QFont *_fixedFont; 361 static QFont *_fixedFont;
356 static QFont *_toolBarFont; 362 static QFont *_toolBarFont;
357 static QFont *_menuFont; 363 static QFont *_menuFont;
358 static QFont *_windowTitleFont; 364 static QFont *_windowTitleFont;
359 static QFont *_taskbarFont; 365 static QFont *_taskbarFont;
360 static QColor * kde2Gray; 366 static QColor * kde2Gray;
361 static QColor * kde2Blue; 367 static QColor * kde2Blue;
362 static QColor * kde2AlternateColor; 368 static QColor * kde2AlternateColor;
363 static OMouseSettings *s_mouseSettings; 369 static OMouseSettings *s_mouseSettings;
364 370
365 static QColor * OpieGray; 371 static QColor * OpieGray;
366 static QColor * OpieBlue; 372 static QColor * OpieBlue;
367 static QColor * OpieAlternate; 373 static QColor * OpieAlternate;
368 static QColor * OpieHighlight; 374 static QColor * OpieHighlight;
369 375
370 friend class OApplication; 376 friend class OApplication;
377private:
378 class Private;
379 Private *d;
371}; 380};
372 381
382}
383}
384
373#endif 385#endif
diff --git a/libopie2/opiecore/opiecore.pro b/libopie2/opiecore/opiecore.pro
index 523d6a7..ff3c036 100644
--- a/libopie2/opiecore/opiecore.pro
+++ b/libopie2/opiecore/opiecore.pro
@@ -1,41 +1,39 @@
1TEMPLATE = lib 1TEMPLATE = lib
2CONFIG += qt warn_on debug 2CONFIG += qt warn_on debug
3DESTDIR = $(OPIEDIR)/lib 3DESTDIR = $(OPIEDIR)/lib
4HEADERS = oapplication.h \ 4HEADERS = oapplication.h \
5 oconfig.h \ 5 oconfig.h \
6 odebug.h \ 6 odebug.h \
7 oglobal.h \ 7 oglobal.h \
8 oglobalsettings.h \ 8 oglobalsettings.h \
9 oprocess.h \ 9 oprocess.h \
10 oprocctrl.h \ 10 oprocctrl.h \
11 osmartpointer.h \ 11 osmartpointer.h \
12 ostorageinfo.h \ 12 ostorageinfo.h
13 xmltree.h
14 13
15SOURCES = oapplication.cpp \ 14SOURCES = oapplication.cpp \
16 oconfig.cpp \ 15 oconfig.cpp \
17 odebug.cpp \ 16 odebug.cpp \
18 oglobal.cpp \ 17 oglobal.cpp \
19 oglobalsettings.cpp \ 18 oglobalsettings.cpp \
20 oprocess.cpp \ 19 oprocess.cpp \
21 oprocctrl.cpp \ 20 oprocctrl.cpp \
22 ostorageinfo.cpp \ 21 ostorageinfo.cpp
23 xmltree.cc
24 22
25include ( device/device.pro ) 23include ( device/device.pro )
26 24
27INTERFACES = 25INTERFACES =
28TARGET = opiecore2 26TARGET = opiecore2
29VERSION = 1.8.5 27VERSION = 1.9.0
30INCLUDEPATH += $(OPIEDIR)/include 28INCLUDEPATH += $(OPIEDIR)/include
31DEPENDPATH += $(OPIEDIR)/include 29DEPENDPATH += $(OPIEDIR)/include
32 30
33!contains( platform, x11 ) { 31!contains( platform, x11 ) {
34 LIBS = -lqpe 32 LIBS = -lqpe
35 include ( $(OPIEDIR)/include.pro ) 33 include ( $(OPIEDIR)/include.pro )
36} 34}
37 35
38contains( platform, x11 ) { 36contains( platform, x11 ) {
39 LIBS = -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib 37 LIBS = -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib
40} 38}
41 39
diff --git a/libopie2/opiecore/oprocctrl.cpp b/libopie2/opiecore/oprocctrl.cpp
index 0403526..46708ba 100644
--- a/libopie2/opiecore/oprocctrl.cpp
+++ b/libopie2/opiecore/oprocctrl.cpp
@@ -1,91 +1,93 @@
1/* This file is part of the KDE libraries 1/* This file is part of the KDE libraries
2 Copyright (C) 1997 Christian Czezakte (e9025461@student.tuwien.ac.at) 2 Copyright (C) 1997 Christian Czezakte (e9025461@student.tuwien.ac.at)
3 3
4 This library is free software; you can redistribute it and/or 4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public 5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either 6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version. 7 version 2 of the License, or (at your option) any later version.
8 8
9 This library is distributed in the hope that it will be useful, 9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details. 12 Library General Public License for more details.
13 13
14 You should have received a copy of the GNU Library General Public License 14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to 15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA. 17 Boston, MA 02111-1307, USA.
18*/ 18*/
19// 19//
20// KPROCESSCONTROLLER -- A helper class for KProcess 20// KPROCESSCONTROLLER -- A helper class for KProcess
21// 21//
22// version 0.3.1, Jan, 8th 1997 22// version 0.3.1, Jan, 8th 1997
23// 23//
24// (C) Christian Czezatke 24// (C) Christian Czezatke
25// e9025461@student.tuwien.ac.at 25// e9025461@student.tuwien.ac.at
26// Ported by Holger Freyther 26// Ported by Holger Freyther
27// 27//
28 28
29//#include <config.h> 29//#include <config.h>
30 30
31#include <sys/types.h> 31#include <sys/types.h>
32#include <sys/socket.h> 32#include <sys/socket.h>
33 33
34#include <errno.h> 34#include <errno.h>
35#include <fcntl.h> 35#include <fcntl.h>
36#include <stdio.h> 36#include <stdio.h>
37#include <string.h> 37#include <string.h>
38#include <unistd.h> 38#include <unistd.h>
39#include <assert.h> 39#include <assert.h>
40 40
41#include <qsocketnotifier.h> 41#include <qsocketnotifier.h>
42#include "oprocctrl.h" 42#include "oprocctrl.h"
43 43
44using namespace Opie::Core::Private;
45
44OProcessController *OProcessController::theOProcessController = 0; 46OProcessController *OProcessController::theOProcessController = 0;
45 47
46struct sigaction OProcessController::oldChildHandlerData; 48struct sigaction OProcessController::oldChildHandlerData;
47bool OProcessController::handlerSet = false; 49bool OProcessController::handlerSet = false;
48 50
49OProcessController::OProcessController() 51OProcessController::OProcessController()
50{ 52{
51 assert( theOProcessController == 0 ); 53 assert( theOProcessController == 0 );
52 54
53 if (0 > pipe(fd)) 55 if (0 > pipe(fd))
54 printf(strerror(errno)); 56 printf(strerror(errno));
55 57
56 notifier = new QSocketNotifier(fd[0], QSocketNotifier::Read); 58 notifier = new QSocketNotifier(fd[0], QSocketNotifier::Read);
57 notifier->setEnabled(true); 59 notifier->setEnabled(true);
58 QObject::connect(notifier, SIGNAL(activated(int)), 60 QObject::connect(notifier, SIGNAL(activated(int)),
59 this, SLOT(slotDoHousekeeping(int))); 61 this, SLOT(slotDoHousekeeping(int)));
60 connect( &delayedChildrenCleanupTimer, SIGNAL( timeout()), 62 connect( &delayedChildrenCleanupTimer, SIGNAL( timeout()),
61 SLOT( delayedChildrenCleanup())); 63 SLOT( delayedChildrenCleanup()));
62 64
63 theOProcessController = this; 65 theOProcessController = this;
64 66
65 setupHandlers(); 67 setupHandlers();
66} 68}
67 69
68 70
69void OProcessController::setupHandlers() 71void OProcessController::setupHandlers()
70{ 72{
71 if( handlerSet ) 73 if( handlerSet )
72 return; 74 return;
73 struct sigaction act; 75 struct sigaction act;
74 act.sa_handler=theSigCHLDHandler; 76 act.sa_handler=theSigCHLDHandler;
75 sigemptyset(&(act.sa_mask)); 77 sigemptyset(&(act.sa_mask));
76 sigaddset(&(act.sa_mask), SIGCHLD); 78 sigaddset(&(act.sa_mask), SIGCHLD);
77 // Make sure we don't block this signal. gdb tends to do that :-( 79 // Make sure we don't block this signal. gdb tends to do that :-(
78 sigprocmask(SIG_UNBLOCK, &(act.sa_mask), 0); 80 sigprocmask(SIG_UNBLOCK, &(act.sa_mask), 0);
79 81
80 act.sa_flags = SA_NOCLDSTOP; 82 act.sa_flags = SA_NOCLDSTOP;
81 83
82 // CC: take care of SunOS which automatically restarts interrupted system 84 // CC: take care of SunOS which automatically restarts interrupted system
83 // calls (and thus does not have SA_RESTART) 85 // calls (and thus does not have SA_RESTART)
84 86
85#ifdef SA_RESTART 87#ifdef SA_RESTART
86 act.sa_flags |= SA_RESTART; 88 act.sa_flags |= SA_RESTART;
87#endif 89#endif
88 90
89 sigaction( SIGCHLD, &act, &oldChildHandlerData ); 91 sigaction( SIGCHLD, &act, &oldChildHandlerData );
90 92
91 act.sa_handler=SIG_IGN; 93 act.sa_handler=SIG_IGN;
diff --git a/libopie2/opiecore/oprocctrl.h b/libopie2/opiecore/oprocctrl.h
index 44b8a48..4922ba2 100644
--- a/libopie2/opiecore/oprocctrl.h
+++ b/libopie2/opiecore/oprocctrl.h
@@ -1,121 +1,129 @@
1/* This file is part of the KDE libraries 1/* This file is part of the KDE libraries
2 Copyright (C) 1997 Christian Czezakte (e9025461@student.tuwien.ac.at) 2 Copyright (C) 1997 Christian Czezakte (e9025461@student.tuwien.ac.at)
3 3
4 This library is free software; you can redistribute it and/or 4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public 5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either 6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version. 7 version 2 of the License, or (at your option) any later version.
8 8
9 This library is distributed in the hope that it will be useful, 9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details. 12 Library General Public License for more details.
13 13
14 You should have received a copy of the GNU Library General Public License 14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to 15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA. 17 Boston, MA 02111-1307, USA.
18*/ 18*/
19// 19//
20// KPROCESSCONTROLLER -- A helper class for KProcess 20// KPROCESSCONTROLLER -- A helper class for KProcess
21// 21//
22// version 0.3.1, Jan 8th 1997 22// version 0.3.1, Jan 8th 1997
23// 23//
24// (C) Christian Czezatke 24// (C) Christian Czezatke
25// e9025461@student.tuwien.ac.at 25// e9025461@student.tuwien.ac.at
26// Ported by Holger Freyther 26// Ported by Holger Freyther
27// 27//
28 28
29#ifndef __KPROCCTRL_H__ 29#ifndef __KPROCCTRL_H__
30#define __KPROCCTRL_H__ 30#define __KPROCCTRL_H__
31 31
32#include <qvaluelist.h> 32#include <qvaluelist.h>
33#include <qtimer.h> 33#include <qtimer.h>
34 34
35#include "oprocess.h" 35#include "oprocess.h"
36 36
37class OProcessControllerPrivate;
38class QSocketNotifier; 37class QSocketNotifier;
39 38
39
40namespace Opie {
41namespace Core {
42namespace Private {
43class OProcessControllerPrivate;
44
40/** 45/**
41 * @short Used internally by @ref OProcess 46 * @short Used internally by @ref OProcess
42 * @internal 47 * @internal
43 * @author Christian Czezakte <e9025461@student.tuwien.ac.at> 48 * @author Christian Czezakte <e9025461@student.tuwien.ac.at>
44 * 49 *
45 * A class for internal use by OProcess only. -- Exactly one instance 50 * A class for internal use by OProcess only. -- Exactly one instance
46 * of this class is generated by the first instance of OProcess that is 51 * of this class is generated by the first instance of OProcess that is
47 * created (a pointer to it gets stored in @ref theOProcessController ). 52 * created (a pointer to it gets stored in @ref theOProcessController ).
48 * 53 *
49 * This class takes care of the actual (UN*X) signal handling. 54 * This class takes care of the actual (UN*X) signal handling.
50*/ 55*/
51class OProcessController : public QObject 56class OProcessController : public QObject
52{ 57{
53 Q_OBJECT 58 Q_OBJECT
54 59
55public: 60public:
56 OProcessController(); 61 OProcessController();
57 ~OProcessController(); 62 ~OProcessController();
58 //CC: WARNING! Destructor Not virtual (but you don't derive classes from this anyhow...) 63 //CC: WARNING! Destructor Not virtual (but you don't derive classes from this anyhow...)
59 64
60public: 65public:
61 66
62 /** 67 /**
63 * Only a single instance of this class is allowed at a time, 68 * Only a single instance of this class is allowed at a time,
64 * and this static variable is used to track the one instance. 69 * and this static variable is used to track the one instance.
65 */ 70 */
66 static OProcessController *theOProcessController; 71 static OProcessController *theOProcessController;
67 72
68 /** 73 /**
69 * Automatically called upon SIGCHLD. 74 * Automatically called upon SIGCHLD.
70 * 75 *
71 * Normally you do not need to do anything with this function but 76 * Normally you do not need to do anything with this function but
72 * if your application needs to disable SIGCHLD for some time for 77 * if your application needs to disable SIGCHLD for some time for
73 * reasons beyond your control, you should call this function afterwards 78 * reasons beyond your control, you should call this function afterwards
74 * to make sure that no SIGCHLDs where missed. 79 * to make sure that no SIGCHLDs where missed.
75 */ 80 */
76 static void theSigCHLDHandler(int signal); 81 static void theSigCHLDHandler(int signal);
77 // handler for sigchld 82 // handler for sigchld
78 83
79 /** 84 /**
80 * @internal 85 * @internal
81 */ 86 */
82 static void setupHandlers(); 87 static void setupHandlers();
83 /** 88 /**
84 * @internal 89 * @internal
85 */ 90 */
86 static void resetHandlers(); 91 static void resetHandlers();
87 /** 92 /**
88 * @internal 93 * @internal
89 */ 94 */
90 void addOProcess( OProcess* ); 95 void addOProcess( OProcess* );
91 /** 96 /**
92 * @internal 97 * @internal
93 */ 98 */
94 void removeOProcess( OProcess* ); 99 void removeOProcess( OProcess* );
95public slots: 100public slots:
96 /** 101 /**
97 * @internal 102 * @internal
98 */ 103 */
99 void slotDoHousekeeping(int socket); 104 void slotDoHousekeeping(int socket);
100 105
101private slots: 106private slots:
102 void delayedChildrenCleanup(); 107 void delayedChildrenCleanup();
103private: 108private:
104 int fd[2]; 109 int fd[2];
105 QSocketNotifier *notifier; 110 QSocketNotifier *notifier;
106 static struct sigaction oldChildHandlerData; 111 static struct sigaction oldChildHandlerData;
107 static bool handlerSet; 112 static bool handlerSet;
108 QValueList<OProcess*> processList; 113 QValueList<OProcess*> processList;
109 QTimer delayedChildrenCleanupTimer; 114 QTimer delayedChildrenCleanupTimer;
110 115
111 // Disallow assignment and copy-construction 116 // Disallow assignment and copy-construction
112 OProcessController( const OProcessController& ); 117 OProcessController( const OProcessController& );
113 OProcessController& operator= ( const OProcessController& ); 118 OProcessController& operator= ( const OProcessController& );
114 119
115 OProcessControllerPrivate *d; 120 OProcessControllerPrivate *d;
116}; 121};
117 122
123}
124}
125}
118 126
119 127
120#endif 128#endif
121 129
diff --git a/libopie2/opiecore/oprocess.cpp b/libopie2/opiecore/oprocess.cpp
index 6349c83..dfde74a 100644
--- a/libopie2/opiecore/oprocess.cpp
+++ b/libopie2/opiecore/oprocess.cpp
@@ -16,108 +16,113 @@ _;:,     .>    :=|. This program is free software; you can
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#include "oprocctrl.h" 31#include "oprocctrl.h"
32 32
33/* OPIE */ 33/* OPIE */
34#include <opie2/oprocess.h> 34#include <opie2/oprocess.h>
35 35
36/* QT */ 36/* QT */
37 37
38#include <qapplication.h> 38#include <qapplication.h>
39#include <qdir.h> 39#include <qdir.h>
40#include <qmap.h> 40#include <qmap.h>
41#include <qsocketnotifier.h> 41#include <qsocketnotifier.h>
42#include <qtextstream.h> 42#include <qtextstream.h>
43 43
44/* STD */ 44/* STD */
45#include <errno.h> 45#include <errno.h>
46#include <fcntl.h> 46#include <fcntl.h>
47#include <pwd.h> 47#include <pwd.h>
48#include <stdlib.h> 48#include <stdlib.h>
49#include <signal.h> 49#include <signal.h>
50#include <stdio.h> 50#include <stdio.h>
51#include <string.h> 51#include <string.h>
52#include <sys/time.h> 52#include <sys/time.h>
53#include <sys/types.h> 53#include <sys/types.h>
54#include <sys/stat.h> 54#include <sys/stat.h>
55#include <sys/socket.h> 55#include <sys/socket.h>
56#include <unistd.h> 56#include <unistd.h>
57#ifdef HAVE_SYS_SELECT_H 57#ifdef HAVE_SYS_SELECT_H
58#include <sys/select.h> 58#include <sys/select.h>
59#endif 59#endif
60#ifdef HAVE_INITGROUPS 60#ifdef HAVE_INITGROUPS
61#include <grp.h> 61#include <grp.h>
62#endif 62#endif
63 63
64using namespace Opie::Core::Private;
65
66namespace Opie {
67namespace Core {
68namespace Private {
64class OProcessPrivate 69class OProcessPrivate
65{ 70{
66public: 71public:
67 OProcessPrivate() : useShell( false ) 72 OProcessPrivate() : useShell( false )
68 { } 73 { }
69 74
70 bool useShell; 75 bool useShell;
71 QMap<QString, QString> env; 76 QMap<QString, QString> env;
72 QString wd; 77 QString wd;
73 QCString shell; 78 QCString shell;
74}; 79};
75 80}
76 81
77OProcess::OProcess( QObject *parent, const char *name ) 82OProcess::OProcess( QObject *parent, const char *name )
78 : QObject( parent, name ) 83 : QObject( parent, name )
79{ 84{
80 init ( ); 85 init ( );
81} 86}
82 87
83OProcess::OProcess( const QString &arg0, QObject *parent, const char *name ) 88OProcess::OProcess( const QString &arg0, QObject *parent, const char *name )
84 : QObject( parent, name ) 89 : QObject( parent, name )
85{ 90{
86 init ( ); 91 init ( );
87 *this << arg0; 92 *this << arg0;
88} 93}
89 94
90OProcess::OProcess( const QStringList &args, QObject *parent, const char *name ) 95OProcess::OProcess( const QStringList &args, QObject *parent, const char *name )
91 : QObject( parent, name ) 96 : QObject( parent, name )
92{ 97{
93 init ( ); 98 init ( );
94 *this << args; 99 *this << args;
95} 100}
96 101
97void OProcess::init ( ) 102void OProcess::init ( )
98{ 103{
99 run_mode = NotifyOnExit; 104 run_mode = NotifyOnExit;
100 runs = false; 105 runs = false;
101 pid_ = 0; 106 pid_ = 0;
102 status = 0; 107 status = 0;
103 keepPrivs = false; 108 keepPrivs = false;
104 innot = 0; 109 innot = 0;
105 outnot = 0; 110 outnot = 0;
106 errnot = 0; 111 errnot = 0;
107 communication = NoCommunication; 112 communication = NoCommunication;
108 input_data = 0; 113 input_data = 0;
109 input_sent = 0; 114 input_sent = 0;
110 input_total = 0; 115 input_total = 0;
111 d = 0; 116 d = 0;
112 117
113 if ( 0 == OProcessController::theOProcessController ) 118 if ( 0 == OProcessController::theOProcessController )
114 { 119 {
115 ( void ) new OProcessController(); 120 ( void ) new OProcessController();
116 CHECK_PTR( OProcessController::theOProcessController ); 121 CHECK_PTR( OProcessController::theOProcessController );
117 } 122 }
118 123
119 OProcessController::theOProcessController->addOProcess( this ); 124 OProcessController::theOProcessController->addOProcess( this );
120 out[ 0 ] = out[ 1 ] = -1; 125 out[ 0 ] = out[ 1 ] = -1;
121 in[ 0 ] = in[ 1 ] = -1; 126 in[ 0 ] = in[ 1 ] = -1;
122 err[ 0 ] = err[ 1 ] = -1; 127 err[ 0 ] = err[ 1 ] = -1;
123} 128}
@@ -896,48 +901,51 @@ bool OProcess::isExecutable( const QCString &filename )
896 ( S_ISCHR( fileinfo.st_mode ) ) || 901 ( S_ISCHR( fileinfo.st_mode ) ) ||
897 ( S_ISBLK( fileinfo.st_mode ) ) || 902 ( S_ISBLK( fileinfo.st_mode ) ) ||
898#ifdef S_ISSOCK 903#ifdef S_ISSOCK
899 // CC: SYSVR4 systems don't have that macro 904 // CC: SYSVR4 systems don't have that macro
900 ( S_ISSOCK( fileinfo.st_mode ) ) || 905 ( S_ISSOCK( fileinfo.st_mode ) ) ||
901#endif 906#endif
902 ( S_ISFIFO( fileinfo.st_mode ) ) || 907 ( S_ISFIFO( fileinfo.st_mode ) ) ||
903 ( S_ISDIR( fileinfo.st_mode ) ) ) 908 ( S_ISDIR( fileinfo.st_mode ) ) )
904 { 909 {
905 return false; 910 return false;
906 } 911 }
907 912
908 // CC: now check for permission to execute the file 913 // CC: now check for permission to execute the file
909 if ( access( filename.data(), X_OK ) != 0 ) 914 if ( access( filename.data(), X_OK ) != 0 )
910 return false; 915 return false;
911 916
912 // CC: we've passed all the tests... 917 // CC: we've passed all the tests...
913 return true; 918 return true;
914} 919}
915 920
916int OProcess::processPID( const QString& process ) 921int OProcess::processPID( const QString& process )
917{ 922{
918 QString line; 923 QString line;
919 QDir d = QDir( "/proc" ); 924 QDir d = QDir( "/proc" );
920 QStringList dirs = d.entryList( QDir::Dirs ); 925 QStringList dirs = d.entryList( QDir::Dirs );
921 QStringList::Iterator it; 926 QStringList::Iterator it;
922 for ( it = dirs.begin(); it != dirs.end(); ++it ) 927 for ( it = dirs.begin(); it != dirs.end(); ++it )
923 { 928 {
924 //qDebug( "next entry: %s", (const char*) *it ); 929 //qDebug( "next entry: %s", (const char*) *it );
925 QFile file( "/proc/"+*it+"/cmdline" ); 930 QFile file( "/proc/"+*it+"/cmdline" );
926 file.open( IO_ReadOnly ); 931 file.open( IO_ReadOnly );
927 if ( !file.isOpen() ) continue; 932 if ( !file.isOpen() ) continue;
928 QTextStream t( &file ); 933 QTextStream t( &file );
929 line = t.readLine(); 934 line = t.readLine();
930 //qDebug( "cmdline = %s", (const char*) line ); 935 //qDebug( "cmdline = %s", (const char*) line );
931 if ( line.contains( process ) ) break; //FIXME: That may find also other process, if the name is not long enough ;) 936 if ( line.contains( process ) ) break; //FIXME: That may find also other process, if the name is not long enough ;)
932 } 937 }
933 if ( line.contains( process ) ) 938 if ( line.contains( process ) )
934 { 939 {
935 //qDebug( "found process id #%d", (*it).toInt() ); 940 //qDebug( "found process id #%d", (*it).toInt() );
936 return (*it).toInt(); 941 return (*it).toInt();
937 } 942 }
938 else 943 else
939 { 944 {
940 //qDebug( "process '%s' not found", (const char*) process ); 945 //qDebug( "process '%s' not found", (const char*) process );
941 return 0; 946 return 0;
942 } 947 }
943} 948}
949
950}
951}
diff --git a/libopie2/opiecore/oprocess.h b/libopie2/opiecore/oprocess.h
index 1a2472d..eb56b03 100644
--- a/libopie2/opiecore/oprocess.h
+++ b/libopie2/opiecore/oprocess.h
@@ -1,94 +1,100 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3             Copyright (C) 2003-2004 Holger Freyther <zecke@handhelds.org> 3             Copyright (C) 2003-2004 Holger Freyther <zecke@handhelds.org>
4 Copyright (C) The Opie Team <opie-devel@handhelds.org> 4 Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 =. Based on KProcess (C) 1997 Christian Czezatke (e9025461@student.tuwien.ac.at) 5 =. Based on KProcess (C) 1997 Christian Czezatke (e9025461@student.tuwien.ac.at)
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#ifndef OPROCESS_H 31#ifndef OPROCESS_H
32#define OPROCESS_H 32#define OPROCESS_H
33 33
34/* QT */ 34/* QT */
35#include <qcstring.h> 35#include <qcstring.h>
36#include <qobject.h> 36#include <qobject.h>
37#include <qvaluelist.h> 37#include <qvaluelist.h>
38 38
39/* STD */ 39/* STD */
40#include <sys/types.h> // for pid_t 40#include <sys/types.h> // for pid_t
41#include <sys/wait.h> 41#include <sys/wait.h>
42#include <signal.h> 42#include <signal.h>
43#include <unistd.h> 43#include <unistd.h>
44 44
45class QSocketNotifier; 45class QSocketNotifier;
46
47namespace Opie {
48namespace Core {
49namespace Private {
50class OProcessController;
46class OProcessPrivate; 51class OProcessPrivate;
52}
47 53
48/** 54/**
49 * Child process invocation, monitoring and control. 55 * Child process invocation, monitoring and control.
50 * 56 *
51 * @sect General usage and features 57 * @sect General usage and features
52 * 58 *
53 *This class allows a KDE and OPIE application to start child processes without having 59 *This class allows a KDE and OPIE application to start child processes without having
54 *to worry about UN*X signal handling issues and zombie process reaping. 60 *to worry about UN*X signal handling issues and zombie process reaping.
55 * 61 *
56 *@see KProcIO 62 *@see KProcIO
57 * 63 *
58 *Basically, this class distinguishes three different ways of running 64 *Basically, this class distinguishes three different ways of running
59 *child processes: 65 *child processes:
60 * 66 *
61 *@li OProcess::DontCare -- The child process is invoked and both the child 67 *@li OProcess::DontCare -- The child process is invoked and both the child
62 *process and the parent process continue concurrently. 68 *process and the parent process continue concurrently.
63 * 69 *
64 *Starting a DontCare child process means that the application is 70 *Starting a DontCare child process means that the application is
65 *not interested in any notification to determine whether the 71 *not interested in any notification to determine whether the
66 *child process has already exited or not. 72 *child process has already exited or not.
67 * 73 *
68 *@li OProcess::NotifyOnExit -- The child process is invoked and both the 74 *@li OProcess::NotifyOnExit -- The child process is invoked and both the
69 *child and the parent process run concurrently. 75 *child and the parent process run concurrently.
70 * 76 *
71 *When the child process exits, the OProcess instance 77 *When the child process exits, the OProcess instance
72 *corresponding to it emits the Qt signal @ref processExited(). 78 *corresponding to it emits the Qt signal @ref processExited().
73 * 79 *
74 *Since this signal is @em not emitted from within a UN*X 80 *Since this signal is @em not emitted from within a UN*X
75 *signal handler, arbitrary function calls can be made. 81 *signal handler, arbitrary function calls can be made.
76 * 82 *
77 *Be aware: When the OProcess objects gets destructed, the child 83 *Be aware: When the OProcess objects gets destructed, the child
78 *process will be killed if it is still running! 84 *process will be killed if it is still running!
79 *This means in particular, that you cannot use a OProcess on the stack 85 *This means in particular, that you cannot use a OProcess on the stack
80 *with OProcess::NotifyOnExit. 86 *with OProcess::NotifyOnExit.
81 * 87 *
82 *@li OProcess::Block -- The child process starts and the parent process 88 *@li OProcess::Block -- The child process starts and the parent process
83 *is suspended until the child process exits. (@em Really not recommended 89 *is suspended until the child process exits. (@em Really not recommended
84 *for programs with a GUI.) 90 *for programs with a GUI.)
85 * 91 *
86 *OProcess also provides several functions for determining the exit status 92 *OProcess also provides several functions for determining the exit status
87 *and the pid of the child process it represents. 93 *and the pid of the child process it represents.
88 * 94 *
89 *Furthermore it is possible to supply command-line arguments to the process 95 *Furthermore it is possible to supply command-line arguments to the process
90 *in a clean fashion (no null -- terminated stringlists and such...) 96 *in a clean fashion (no null -- terminated stringlists and such...)
91 * 97 *
92 *A small usage example: 98 *A small usage example:
93 *<pre> 99 *<pre>
94 *OProcess *proc = new OProcess; 100 *OProcess *proc = new OProcess;
@@ -352,96 +358,97 @@ public:
352 * @li Transmission of data to the child process by a previous call to 358 * @li Transmission of data to the child process by a previous call to
353 * @ref writeStdin() is still in progress. 359 * @ref writeStdin() is still in progress.
354 * 360 *
355 * Please note that the data is sent to the client asynchronously, 361 * Please note that the data is sent to the client asynchronously,
356 * so when this function returns, the data might not have been 362 * so when this function returns, the data might not have been
357 * processed by the child process. 363 * processed by the child process.
358 * 364 *
359 * If all the data has been sent to the client, the signal 365 * If all the data has been sent to the client, the signal
360 * @ref wroteStdin() will be emitted. 366 * @ref wroteStdin() will be emitted.
361 * 367 *
362 * Please note that you must not free "buffer" or call @ref writeStdin() 368 * Please note that you must not free "buffer" or call @ref writeStdin()
363 * again until either a @ref wroteStdin() signal indicates that the 369 * again until either a @ref wroteStdin() signal indicates that the
364 * data has been sent or a @ref processHasExited() signal shows that 370 * data has been sent or a @ref processHasExited() signal shows that
365 * the child process is no longer alive... 371 * the child process is no longer alive...
366 **/ 372 **/
367 bool writeStdin( const char *buffer, int buflen ); 373 bool writeStdin( const char *buffer, int buflen );
368 374
369 void flushStdin(); 375 void flushStdin();
370 376
371 /** 377 /**
372 * This causes the stdin file descriptor of the child process to be 378 * This causes the stdin file descriptor of the child process to be
373 * closed indicating an "EOF" to the child. 379 * closed indicating an "EOF" to the child.
374 * 380 *
375 * @return @p false if no communication to the process's stdin 381 * @return @p false if no communication to the process's stdin
376 * had been specified in the call to @ref start(). 382 * had been specified in the call to @ref start().
377 */ 383 */
378 bool closeStdin(); 384 bool closeStdin();
379 385
380 /** 386 /**
381 * This causes the stdout file descriptor of the child process to be 387 * This causes the stdout file descriptor of the child process to be
382 * closed. 388 * closed.
383 * 389 *
384 * @return @p false if no communication to the process's stdout 390 * @return @p false if no communication to the process's stdout
385 * had been specified in the call to @ref start(). 391 * had been specified in the call to @ref start().
386 */ 392 */
387 bool closeStdout(); 393 bool closeStdout();
388 394
389 /** 395 /**
390 * This causes the stderr file descriptor of the child process to be 396 * This causes the stderr file descriptor of the child process to be
391 * closed. 397 * closed.
392 * 398 *
393 * @return @p false if no communication to the process's stderr 399 * @return @p false if no communication to the process's stderr
394 * had been specified in the call to @ref start(). 400 * had been specified in the call to @ref start().
395 */ 401 */
396 bool closeStderr(); 402 bool closeStderr();
397 403
398 /** 404 /**
399 * Lets you see what your arguments are for debugging. 405 * Lets you see what your arguments are for debugging.
406 * \todo make const
400 */ 407 */
401 408
402 const QValueList<QCString> &args() 409 const QValueList<QCString> &args()
403 { 410 {
404 return arguments; 411 return arguments;
405 } 412 }
406 413
407 /** 414 /**
408 * Controls whether the started process should drop any 415 * Controls whether the started process should drop any
409 * setuid/segid privileges or whether it should keep them 416 * setuid/segid privileges or whether it should keep them
410 * 417 *
411 * The default is @p false : drop privileges 418 * The default is @p false : drop privileges
412 */ 419 */
413 void setRunPrivileged( bool keepPrivileges ); 420 void setRunPrivileged( bool keepPrivileges );
414 421
415 /** 422 /**
416 * Returns whether the started process will drop any 423 * Returns whether the started process will drop any
417 * setuid/segid privileges or whether it will keep them 424 * setuid/segid privileges or whether it will keep them
418 */ 425 */
419 bool runPrivileged() const; 426 bool runPrivileged() const;
420 427
421 /** 428 /**
422 * Modifies the environment of the process to be started. 429 * Modifies the environment of the process to be started.
423 * This function must be called before starting the process. 430 * This function must be called before starting the process.
424 */ 431 */
425 void setEnvironment( const QString &name, const QString &value ); 432 void setEnvironment( const QString &name, const QString &value );
426 433
427 /** 434 /**
428 * Changes the current working directory (CWD) of the process 435 * Changes the current working directory (CWD) of the process
429 * to be started. 436 * to be started.
430 * This function must be called before starting the process. 437 * This function must be called before starting the process.
431 */ 438 */
432 void setWorkingDirectory( const QString &dir ); 439 void setWorkingDirectory( const QString &dir );
433 440
434 /** 441 /**
435 * Specify whether to start the command via a shell or directly. 442 * Specify whether to start the command via a shell or directly.
436 * The default is to start the command directly. 443 * The default is to start the command directly.
437 * If @p useShell is true @p shell will be used as shell, or 444 * If @p useShell is true @p shell will be used as shell, or
438 * if shell is empty, the standard shell is used. 445 * if shell is empty, the standard shell is used.
439 * @p quote A flag indicating whether to quote the arguments. 446 * @p quote A flag indicating whether to quote the arguments.
440 * 447 *
441 * When using a shell, the caller should make sure that all filenames etc. 448 * When using a shell, the caller should make sure that all filenames etc.
442 * are properly quoted when passed as argument. 449 * are properly quoted when passed as argument.
443 * @see quote() 450 * @see quote()
444 */ 451 */
445 void setUseShell( bool useShell, const char *shell = 0 ); 452 void setUseShell( bool useShell, const char *shell = 0 );
446 453
447 /** 454 /**
@@ -671,82 +678,84 @@ protected:
671 */ 678 */
672 virtual void commClose(); 679 virtual void commClose();
673 680
674 681
675 /** 682 /**
676 * the socket descriptors for stdin/stdout/stderr. 683 * the socket descriptors for stdin/stdout/stderr.
677 */ 684 */
678 int out[ 2 ]; 685 int out[ 2 ];
679 int in[ 2 ]; 686 int in[ 2 ];
680 int err[ 2 ]; 687 int err[ 2 ];
681 688
682 /** 689 /**
683 * The socket notifiers for the above socket descriptors. 690 * The socket notifiers for the above socket descriptors.
684 */ 691 */
685 QSocketNotifier *innot; 692 QSocketNotifier *innot;
686 QSocketNotifier *outnot; 693 QSocketNotifier *outnot;
687 QSocketNotifier *errnot; 694 QSocketNotifier *errnot;
688 695
689 /** 696 /**
690 * Lists the communication links that are activated for the child 697 * Lists the communication links that are activated for the child
691 * process. Should not be modified from derived classes. 698 * process. Should not be modified from derived classes.
692 */ 699 */
693 Communication communication; 700 Communication communication;
694 701
695 /** 702 /**
696 * Called by "slotChildOutput" this function copies data arriving from the 703 * Called by "slotChildOutput" this function copies data arriving from the
697 * child process's stdout to the respective buffer and emits the signal 704 * child process's stdout to the respective buffer and emits the signal
698 * "@ref receivedStderr". 705 * "@ref receivedStderr".
699 */ 706 */
700 int childOutput( int fdno ); 707 int childOutput( int fdno );
701 708
702 /** 709 /**
703 * Called by "slotChildOutput" this function copies data arriving from the 710 * Called by "slotChildOutput" this function copies data arriving from the
704 * child process's stdout to the respective buffer and emits the signal 711 * child process's stdout to the respective buffer and emits the signal
705 * "@ref receivedStderr" 712 * "@ref receivedStderr"
706 */ 713 */
707 int childError( int fdno ); 714 int childError( int fdno );
708 715
709 // information about the data that has to be sent to the child: 716 // information about the data that has to be sent to the child:
710 717
711 const char *input_data; // the buffer holding the data 718 const char *input_data; // the buffer holding the data
712 int input_sent; // # of bytes already transmitted 719 int input_sent; // # of bytes already transmitted
713 int input_total; // total length of input_data 720 int input_total; // total length of input_data
714 721
715 /** 722 /**
716 * @ref OProcessController is a friend of OProcess because it has to have 723 * @ref OProcessController is a friend of OProcess because it has to have
717 * access to various data members. 724 * access to various data members.
718 */ 725 */
719 friend class OProcessController; 726 friend class Private::OProcessController;
720 727
721private: 728private:
722 /** 729 /**
723 * Searches for a valid shell. 730 * Searches for a valid shell.
724 * Here is the algorithm used for finding an executable shell: 731 * Here is the algorithm used for finding an executable shell:
725 * 732 *
726 * @li Try the executable pointed to by the "SHELL" environment 733 * @li Try the executable pointed to by the "SHELL" environment
727 * variable with white spaces stripped off 734 * variable with white spaces stripped off
728 * 735 *
729 * @li If your process runs with uid != euid or gid != egid, a shell 736 * @li If your process runs with uid != euid or gid != egid, a shell
730 * not listed in /etc/shells will not used. 737 * not listed in /etc/shells will not used.
731 * 738 *
732 * @li If no valid shell could be found, "/bin/sh" is used as a last resort. 739 * @li If no valid shell could be found, "/bin/sh" is used as a last resort.
733 */ 740 */
734 QCString searchShell(); 741 QCString searchShell();
735 742
736 /** 743 /**
737 * Used by @ref searchShell in order to find out whether the shell found 744 * Used by @ref searchShell in order to find out whether the shell found
738 * is actually executable at all. 745 * is actually executable at all.
739 */ 746 */
740 bool isExecutable( const QCString &filename ); 747 bool isExecutable( const QCString &filename );
741 748
742 // Disallow assignment and copy-construction 749 // Disallow assignment and copy-construction
743 OProcess( const OProcess& ); 750 OProcess( const OProcess& );
744 OProcess& operator= ( const OProcess& ); 751 OProcess& operator= ( const OProcess& );
745 752
746private: 753private:
747 void init ( ); 754 void init ( );
748 OProcessPrivate *d; 755 Private::OProcessPrivate *d;
749}; 756};
757}
758}
750 759
751#endif 760#endif
752 761
diff --git a/libopie2/opiecore/osmartpointer.h b/libopie2/opiecore/osmartpointer.h
index 9000e71..8f9da7f 100644
--- a/libopie2/opiecore/osmartpointer.h
+++ b/libopie2/opiecore/osmartpointer.h
@@ -1,90 +1,91 @@
1// -*- Mode: C++; -*- 1// -*- Mode: C++; -*-
2/* 2/*
3 This file is part of the Opie Project 3 This file is part of the Opie Project
4 Copyright (C) 2004 Rajko Albrecht <alwin@handhelds.org> 4 Copyright (C) 2004 Rajko Albrecht <alwin@handhelds.org>
5 Copyright (C) The Opie Team <opie-devel@handhelds.org> 5 Copyright (C) The Opie Team <opie-devel@handhelds.org>
6 =. 6 =.
7 .=l. 7 .=l.
8 .>+-= 8 .>+-=
9_;:, .> :=|. This program is free software; you can 9_;:, .> :=|. This program is free software; you can
10.> <`_, > . <= redistribute it and/or modify it under 10.> <`_, > . <= redistribute it and/or modify it under
11:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 11:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
12.="- .-=="i, .._ License as published by the Free Software 12.="- .-=="i, .._ License as published by the Free Software
13- . .-<_> .<> Foundation; either version 2 of the License, 13- . .-<_> .<> Foundation; either version 2 of the License,
14 ._= =} : or (at your option) any later version. 14 ._= =} : or (at your option) any later version.
15 .%`+i> _;_. 15 .%`+i> _;_.
16 .i_,=:_. -<s. This program is distributed in the hope that 16 .i_,=:_. -<s. This program is distributed in the hope that
17 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 17 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
18 : .. .:, . . . without even the implied warranty of 18 : .. .:, . . . without even the implied warranty of
19 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 19 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
20 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 20 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
21..}^=.= = ; Library General Public License for more 21..}^=.= = ; Library General Public License for more
22++= -. .` .: details. 22++= -. .` .: details.
23: = ...= . :.=- 23: = ...= . :.=-
24-. .:....=;==+<; You should have received a copy of the GNU 24-. .:....=;==+<; You should have received a copy of the GNU
25 -_. . . )=. = Library General Public License along with 25 -_. . . )=. = Library General Public License along with
26 -- :-=` this library; see the file COPYING.LIB. 26 -- :-=` this library; see the file COPYING.LIB.
27 If not, write to the Free Software Foundation, 27 If not, write to the Free Software Foundation,
28 Inc., 59 Temple Place - Suite 330, 28 Inc., 59 Temple Place - Suite 330,
29 Boston, MA 02111-1307, USA. 29 Boston, MA 02111-1307, USA.
30*/ 30*/
31 31
32#ifndef _OSmartPointer_h 32#ifndef _OSmartPointer_h
33#define _OSmartPointer_h 33#define _OSmartPointer_h
34 34
35/*! 35/*!
36 * \file OSmartPointer.h 36 * \file OSmartPointer.h
37 * \brief smart pointer and reference counter 37 * \brief smart pointer and reference counter
38 * \author Rajko Albrecht 38 * \author Rajko Albrecht
39 * 39 *
40 */ 40 */
41 41
42namespace Opie { 42namespace Opie {
43namespace Core {
43 44
44//! simple reference counter class 45//! simple reference counter class
45class ORefCount { 46class ORefCount {
46protected: 47protected:
47 //! reference count member 48 //! reference count member
48 long m_RefCount; 49 long m_RefCount;
49public: 50public:
50 //! first reference must be added after "new" via Pointer() 51 //! first reference must be added after "new" via Pointer()
51 ORefCount() : m_RefCount(0) 52 ORefCount() : m_RefCount(0)
52 {} 53 {}
53 virtual ~ORefCount() {} 54 virtual ~ORefCount() {}
54 //! add a reference 55 //! add a reference
55 void Incr() { 56 void Incr() {
56 ++m_RefCount; 57 ++m_RefCount;
57 } 58 }
58 //! delete a reference 59 //! delete a reference
59 void Decr() { 60 void Decr() {
60 --m_RefCount; 61 --m_RefCount;
61 } 62 }
62 //! is it referenced 63 //! is it referenced
63 bool Shared() { return (m_RefCount > 0); } 64 bool Shared() { return (m_RefCount > 0); }
64}; 65};
65 66
66//! reference counting wrapper class 67//! reference counting wrapper class
67template<class T> class OSmartPointer { 68template<class T> class OSmartPointer {
68 //! pointer to object 69 //! pointer to object
69 /*! 70 /*!
70 * this object must contain Incr(), Decr() and Shared() 71 * this object must contain Incr(), Decr() and Shared()
71 * methode as public members. The best way is, that it will be a child 72 * methode as public members. The best way is, that it will be a child
72 * class of RefCount 73 * class of RefCount
73 */ 74 */
74 T *ptr; 75 T *ptr;
75public: 76public:
76 //! standart constructor 77 //! standart constructor
77 OSmartPointer() { ptr = NULL; } 78 OSmartPointer() { ptr = NULL; }
78 //! standart destructor 79 //! standart destructor
79 /*! 80 /*!
80 * release the reference, if it were the last reference, destroys 81 * release the reference, if it were the last reference, destroys
81 * ptr 82 * ptr
82 */ 83 */
83 ~OSmartPointer() 84 ~OSmartPointer()
84 { 85 {
85 if (ptr){ 86 if (ptr){
86 ptr->Decr(); 87 ptr->Decr();
87 if (!ptr->Shared()) 88 if (!ptr->Shared())
88 delete ptr; 89 delete ptr;
89 } 90 }
90 } 91 }
@@ -95,51 +96,52 @@ public:
95 { if (ptr = p.ptr) ptr->Incr(); } 96 { if (ptr = p.ptr) ptr->Incr(); }
96 //! pointer copy by assignment 97 //! pointer copy by assignment
97 OSmartPointer<T>& operator= (const OSmartPointer<T>& p) 98 OSmartPointer<T>& operator= (const OSmartPointer<T>& p)
98 { 99 {
99 // already same: nothing to do 100 // already same: nothing to do
100 if (ptr == p.ptr) return *this; 101 if (ptr == p.ptr) return *this;
101 // decouple reference 102 // decouple reference
102 if (ptr) { ptr->Decr(); if (!ptr->Shared()) delete ptr; } 103 if (ptr) { ptr->Decr(); if (!ptr->Shared()) delete ptr; }
103 // establish new reference 104 // establish new reference
104 if (ptr = p.ptr) ptr->Incr(); 105 if (ptr = p.ptr) ptr->Incr();
105 return *this; 106 return *this;
106 } 107 }
107 OSmartPointer<T>& operator= (T*p) 108 OSmartPointer<T>& operator= (T*p)
108 { 109 {
109 if (ptr==p)return *this; 110 if (ptr==p)return *this;
110 if (ptr) { 111 if (ptr) {
111 ptr->Decr(); 112 ptr->Decr();
112 if (!ptr->Shared()) delete ptr; 113 if (!ptr->Shared()) delete ptr;
113 } 114 }
114 if (ptr=p) ptr->Incr(); 115 if (ptr=p) ptr->Incr();
115 return *this; 116 return *this;
116 } 117 }
117 118
118 //! cast to conventional pointer 119 //! cast to conventional pointer
119 operator T* () const { return ptr; } 120 operator T* () const { return ptr; }
120 121
121 //! deref: fails for NULL pointer 122 //! deref: fails for NULL pointer
122 T& operator* () {return *ptr; } 123 T& operator* () {return *ptr; }
123 //! deref: fails for NULL pointer 124 //! deref: fails for NULL pointer
124 const T& operator* ()const {return *ptr; } 125 const T& operator* ()const {return *ptr; }
125 126
126 //! deref with method call 127 //! deref with method call
127 T* operator-> () {return ptr; } 128 T* operator-> () {return ptr; }
128 //! deref with const method call 129 //! deref with const method call
129 const T* operator-> ()const {return ptr; } 130 const T* operator-> ()const {return ptr; }
130 131
131 //! supports "if (pointer)" 132 //! supports "if (pointer)"
132 operator bool () const { return (ptr != NULL); } 133 operator bool () const { return (ptr != NULL); }
133 //! "if (pointer)" as non const 134 //! "if (pointer)" as non const
134 operator bool () { return ptr != NULL;} 135 operator bool () { return ptr != NULL;}
135 136
136 //! support if (!pointer)" 137 //! support if (!pointer)"
137 bool operator! () const { return (ptr == NULL); } 138 bool operator! () const { return (ptr == NULL); }
138 //! support if (!pointer)" as non const 139 //! support if (!pointer)" as non const
139 bool operator! () { return (ptr == NULL); } 140 bool operator! () { return (ptr == NULL); }
140}; 141};
141 142
142} 143}
144}
143 145
144#endif 146#endif
145 147
diff --git a/libopie2/opiecore/ostorageinfo.cpp b/libopie2/opiecore/ostorageinfo.cpp
index aa8d2fc..8fcf5fc 100644
--- a/libopie2/opiecore/ostorageinfo.cpp
+++ b/libopie2/opiecore/ostorageinfo.cpp
@@ -1,79 +1,81 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3              Copyright (C) 2004 Andreas 'ar' Richter <ar@oszine.de> 3              Copyright (C) 2004 Andreas 'ar' Richter <ar@oszine.de>
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 <opie2/ostorageinfo.h> 30#include <opie2/ostorageinfo.h>
31 31
32using namespace Opie::Core;
33
32OStorageInfo::OStorageInfo( QObject *parent ) 34OStorageInfo::OStorageInfo( QObject *parent )
33 : StorageInfo( parent ) 35 : StorageInfo( parent )
34{ 36{
35} 37}
36 38
37OStorageInfo::~OStorageInfo() 39OStorageInfo::~OStorageInfo()
38{ 40{
39} 41}
40 42
41QString OStorageInfo::cfPath()const 43QString OStorageInfo::cfPath()const
42{ 44{
43 QString r = ""; 45 QString r = "";
44 46
45 for (QListIterator<FileSystem> i( fileSystems() ); i.current(); ++i) 47 for (QListIterator<FileSystem> i( fileSystems() ); i.current(); ++i)
46 { 48 {
47 if ( (*i)->disk().left( 8 ) == "/dev/hda" ) 49 if ( (*i)->disk().left( 8 ) == "/dev/hda" )
48 { 50 {
49 r = (*i)->path(); 51 r = (*i)->path();
50 break; 52 break;
51 } 53 }
52 } 54 }
53 return r; 55 return r;
54} 56}
55 57
56QString OStorageInfo::sdPath()const 58QString OStorageInfo::sdPath()const
57{ 59{
58 QString r = ""; 60 QString r = "";
59 61
60 for (QListIterator<FileSystem> i( fileSystems() ); i.current(); ++i) 62 for (QListIterator<FileSystem> i( fileSystems() ); i.current(); ++i)
61 { 63 {
62 if ( (*i)->disk().left( 9 ) == "/dev/mmcd" ) 64 if ( (*i)->disk().left( 9 ) == "/dev/mmcd" )
63 { 65 {
64 r = (*i)->path(); 66 r = (*i)->path();
65 break; 67 break;
66 } 68 }
67 } 69 }
68 return r; 70 return r;
69} 71}
70 72
71QString OStorageInfo::mmcPath()const 73QString OStorageInfo::mmcPath()const
72{ 74{
73 QString r = ""; 75 QString r = "";
74 76
75 for (QListIterator<FileSystem> i( fileSystems() ); i.current(); ++i) 77 for (QListIterator<FileSystem> i( fileSystems() ); i.current(); ++i)
76 { 78 {
77 if ( (*i)->disk().left( 14 ) == "/dev/mmc/part1" ) 79 if ( (*i)->disk().left( 14 ) == "/dev/mmc/part1" )
78 { 80 {
79 r = (*i)->path(); 81 r = (*i)->path();
diff --git a/libopie2/opiecore/ostorageinfo.h b/libopie2/opiecore/ostorageinfo.h
index 740fa85..4e1097f 100644
--- a/libopie2/opiecore/ostorageinfo.h
+++ b/libopie2/opiecore/ostorageinfo.h
@@ -1,62 +1,70 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3              Copyright (C) 2004 Andreas 'ar' Richter <ar@oszine.de> 3              Copyright (C) 2004 Andreas 'ar' Richter <ar@oszine.de>
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#ifndef OSTORAGE_H 30#ifndef OSTORAGE_H
31#define OSTORAGE_H 31#define OSTORAGE_H
32 32
33#include <qpe/storage.h> 33#include <qpe/storage.h>
34 34
35namespace Opie {
36namespace Core {
37
35class OStorageInfo : public StorageInfo 38class OStorageInfo : public StorageInfo
36{ 39{
37 Q_OBJECT 40 Q_OBJECT
38 41
39 public: 42 public:
40 43
41 OStorageInfo( QObject *parent=0 ); 44 OStorageInfo( QObject *parent=0 );
42 ~OStorageInfo(); 45 ~OStorageInfo();
43 46
44 /** 47 /**
45 * @returns the mount path of the CF (Compact Flash) card 48 * @returns the mount path of the CF (Compact Flash) card
46 * 49 *
47 **/ 50 **/
48 QString cfPath() const; 51 QString cfPath() const;
49 /** 52 /**
50 * @returns the mount path of the SD (Secure Digital) card 53 * @returns the mount path of the SD (Secure Digital) card
51 * 54 *
52 **/ 55 **/
53 QString sdPath() const; 56 QString sdPath() const;
54 /** 57 /**
55 * @returns the mount path of the MMC (MultiMedia) card 58 * @returns the mount path of the MMC (MultiMedia) card
56 * 59 *
57 **/ 60 **/
58 QString mmcPath() const; 61 QString mmcPath() const;
62private:
63 class Private;
64 Private *d;
59}; 65};
60 66
67}
68}
61#endif // OSTORAGE_H 69#endif // OSTORAGE_H
62 70
diff --git a/libopie2/opiedb/TODO b/libopie2/opiedb/TODO
index ca04ac6..8b86187 100644
--- a/libopie2/opiedb/TODO
+++ b/libopie2/opiedb/TODO
@@ -1,9 +1,10 @@
1* something like Capabilities of a Driver 1* something like Capabilities of a Driver
2 - ROWID 2 - ROWID
3 - How to declare INTEGER PRIMARY KEY 3 - How to declare INTEGER PRIMARY KEY
4 - Abstract from implementation of some dbs 4 - Abstract from implementation of some dbs
5 - provides( Type::What ) 5 - provides( Type::What )
6 - emit signals directly on arriving of data
6 7
7 * OSQLDriver DriverVersion - DatabaseVersion 8 * OSQLDriver DriverVersion - DatabaseVersion
8 * Better OSQLQueries 9 * Better OSQLQueries
9 - more than OSQLRawQuery \ No newline at end of file 10 - more than OSQLRawQuery \ No newline at end of file
diff --git a/libopie2/opiedb/opiedb.pro b/libopie2/opiedb/opiedb.pro
index c773d6c..147435a 100644
--- a/libopie2/opiedb/opiedb.pro
+++ b/libopie2/opiedb/opiedb.pro
@@ -1,36 +1,36 @@
1TEMPLATE = lib 1TEMPLATE = lib
2CONFIG += qt warn_on debug 2CONFIG += qt warn_on debug
3DESTDIR = $(OPIEDIR)/lib 3DESTDIR = $(OPIEDIR)/lib
4HEADERS = osqlbackend.h \ 4HEADERS = osqlbackend.h \
5 osqldriver.h \ 5 osqldriver.h \
6 osqlerror.h \ 6 osqlerror.h \
7 osqlmanager.h \ 7 osqlmanager.h \
8 osqlquery.h \ 8 osqlquery.h \
9 osqlresult.h \ 9 osqlresult.h \
10 osqltable.h \ 10 osqltable.h \
11 osqlbackendmanager.h \ 11 osqlbackendmanager.h \
12 osqlitedriver.h 12 osqlitedriver.h
13SOURCES = osqlbackend.cpp \ 13SOURCES = osqlbackend.cpp \
14 osqldriver.cpp \ 14 osqldriver.cpp \
15 osqlerror.cpp \ 15 osqlerror.cpp \
16 osqlmanager.cpp \ 16 osqlmanager.cpp \
17 osqlquery.cpp \ 17 osqlquery.cpp \
18 osqlresult.cpp \ 18 osqlresult.cpp \
19 osqltable.cpp \ 19 osqltable.cpp \
20 osqlbackendmanager.cpp \ 20 osqlbackendmanager.cpp \
21 osqlitedriver.cpp 21 osqlitedriver.cpp
22INTERFACES = 22INTERFACES =
23TARGET = opiedb2 23TARGET = opiedb2
24VERSION = 1.8.2 24VERSION = 1.9.0
25INCLUDEPATH = $(OPIEDIR)/include 25INCLUDEPATH = $(OPIEDIR)/include
26DEPENDPATH = $(OPIEDIR)/include 26DEPENDPATH = $(OPIEDIR)/include
27LIBS += -lopiecore2 -lqpe -lsqlite 27LIBS += -lopiecore2 -lqpe -lsqlite
28 28
29!contains( platform, x11 ) { 29!contains( platform, x11 ) {
30 include ( $(OPIEDIR)/include.pro ) 30 include ( $(OPIEDIR)/include.pro )
31} 31}
32 32
33contains( platform, x11 ) { 33contains( platform, x11 ) {
34 LIBS += -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib 34 LIBS += -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib
35} 35}
36 36
diff --git a/libopie2/opiedb/osqlbackend.cpp b/libopie2/opiedb/osqlbackend.cpp
index d6c39a9..6e5159f 100644
--- a/libopie2/opiedb/osqlbackend.cpp
+++ b/libopie2/opiedb/osqlbackend.cpp
@@ -1,51 +1,53 @@
1 1
2#include "osqlbackend.h" 2#include "osqlbackend.h"
3 3
4using namespace Opie::DB;
5
4 6
5OSQLBackEnd::OSQLBackEnd( const QString& name, 7OSQLBackEnd::OSQLBackEnd( const QString& name,
6 const QString& vendor, 8 const QString& vendor,
7 const QString& license, 9 const QString& license,
8 const QCString& lib ) 10 const QCString& lib )
9 : m_name( name), m_vendor( vendor), m_license( license ), m_lib( lib ) 11 : m_name( name), m_vendor( vendor), m_license( license ), m_lib( lib )
10{ 12{
11 m_default = false; 13 m_default = false;
12 m_pref = -1; 14 m_pref = -1;
13} 15}
14OSQLBackEnd::OSQLBackEnd( const OSQLBackEnd& back ) { 16OSQLBackEnd::OSQLBackEnd( const OSQLBackEnd& back ) {
15 (*this) = back; 17 (*this) = back;
16} 18}
17OSQLBackEnd::~OSQLBackEnd() { 19OSQLBackEnd::~OSQLBackEnd() {
18} 20}
19bool OSQLBackEnd::operator==( const OSQLBackEnd& other ) { 21bool OSQLBackEnd::operator==( const OSQLBackEnd& other ) {
20 if ( m_pref != other.m_pref ) return false; 22 if ( m_pref != other.m_pref ) return false;
21 if ( m_default != other.m_default ) return false; 23 if ( m_default != other.m_default ) return false;
22 if ( m_name != other.m_name ) return false; 24 if ( m_name != other.m_name ) return false;
23 if ( m_vendor != other.m_vendor ) return false; 25 if ( m_vendor != other.m_vendor ) return false;
24 if ( m_license != other.m_license ) return false; 26 if ( m_license != other.m_license ) return false;
25 if ( m_lib != other.m_lib ) return false; 27 if ( m_lib != other.m_lib ) return false;
26 28
27 return true; 29 return true;
28} 30}
29OSQLBackEnd &OSQLBackEnd::operator=(const OSQLBackEnd& back ) { 31OSQLBackEnd &OSQLBackEnd::operator=(const OSQLBackEnd& back ) {
30 m_name = back.m_name; 32 m_name = back.m_name;
31 m_vendor = back.m_vendor; 33 m_vendor = back.m_vendor;
32 m_license = back.m_license; 34 m_license = back.m_license;
33 m_lib = back.m_lib; 35 m_lib = back.m_lib;
34 m_pref = back.m_pref; 36 m_pref = back.m_pref;
35 m_default = back.m_default; 37 m_default = back.m_default;
36 return *this; 38 return *this;
37} 39}
38QString OSQLBackEnd::name() const { 40QString OSQLBackEnd::name() const {
39 return m_name; 41 return m_name;
40} 42}
41QString OSQLBackEnd::vendor() const { 43QString OSQLBackEnd::vendor() const {
42 return m_vendor; 44 return m_vendor;
43} 45}
44QString OSQLBackEnd::license() const { 46QString OSQLBackEnd::license() const {
45 return m_license; 47 return m_license;
46} 48}
47QCString OSQLBackEnd::library() const { 49QCString OSQLBackEnd::library() const {
48 return m_lib; 50 return m_lib;
49} 51}
50bool OSQLBackEnd::isDefault()const { 52bool OSQLBackEnd::isDefault()const {
51 return m_default; 53 return m_default;
diff --git a/libopie2/opiedb/osqlbackend.h b/libopie2/opiedb/osqlbackend.h
index ad879a4..28451b6 100644
--- a/libopie2/opiedb/osqlbackend.h
+++ b/libopie2/opiedb/osqlbackend.h
@@ -1,75 +1,83 @@
1 1
2#ifndef OSQL_BACKEND_H 2#ifndef OSQL_BACKEND_H
3#define OSQL_BACKEND_H 3#define OSQL_BACKEND_H
4 4
5#include <qcstring.h> 5#include <qcstring.h>
6#include <qstring.h> 6#include <qstring.h>
7#include <qvaluelist.h> 7#include <qvaluelist.h>
8 8
9
10namespace Opie {
11namespace DB {
9/** 12/**
10 * OSQLBackEnd represents an available backend 13 * OSQLBackEnd represents an available backend
11 * to the Opie Database Service 14 * to the Opie Database Service
12 * It's used to easily extend OSQL services by 15 * It's used to easily extend OSQL services by
13 * 3rd party plugins. 16 * 3rd party plugins.
14 * It's used to show 17 * It's used to show
15 */ 18 */
16class OSQLBackEnd /*: public QShared */ { 19class OSQLBackEnd /*: public QShared */ {
17public: 20public:
18 typedef QValueList<OSQLBackEnd> ValueList; 21 typedef QValueList<OSQLBackEnd> ValueList;
19 /** 22 /**
20 * A basic c'tor 23 * A basic c'tor
21 * @param name the user visible name of the service 24 * @param name the user visible name of the service
22 * @param vendor the vendor of the service 25 * @param vendor the vendor of the service
23 * @param license the license of the service 26 * @param license the license of the service
24 * @param library what is the name of lib if builtin it's builtin 27 * @param library what is the name of lib if builtin it's builtin
25 */ 28 */
26 OSQLBackEnd( const QString& name = QString::null, 29 OSQLBackEnd( const QString& name = QString::null,
27 const QString& vendor = QString::null, 30 const QString& vendor = QString::null,
28 const QString& license = QString::null, 31 const QString& license = QString::null,
29 const QCString& library = QCString() ); 32 const QCString& library = QCString() );
30 OSQLBackEnd( const OSQLBackEnd& ); 33 OSQLBackEnd( const OSQLBackEnd& );
31 OSQLBackEnd &operator=( const OSQLBackEnd& ); 34 OSQLBackEnd &operator=( const OSQLBackEnd& );
32 bool operator==(const OSQLBackEnd& ); 35 bool operator==(const OSQLBackEnd& );
33 36
34 ~OSQLBackEnd(); 37 ~OSQLBackEnd();
35 38
36 /** @return the name */ 39 /** @return the name */
37 QString name()const; 40 QString name()const;
38 41
39 /** @return the vendor */ 42 /** @return the vendor */
40 QString vendor()const; 43 QString vendor()const;
41 44
42 /** @return the license */ 45 /** @return the license */
43 QString license()const; 46 QString license()const;
44 47
45 /** @return the name of the library */ 48 /** @return the name of the library */
46 QCString library() const; 49 QCString library() const;
47 50
48 bool isDefault()const; 51 bool isDefault()const;
49 int preference()const; 52 int preference()const;
50 53
51 /** @param name the name to set */ 54 /** @param name the name to set */
52 void setName( const QString& name ); 55 void setName( const QString& name );
53 56
54 /** @param vendor the vendor to set */ 57 /** @param vendor the vendor to set */
55 void setVendor( const QString& vendor ); 58 void setVendor( const QString& vendor );
56 59
57 /** @param license the license applied */ 60 /** @param license the license applied */
58 void setLicense( const QString& license ); 61 void setLicense( const QString& license );
59 62
60 /** @param the lib to set */ 63 /** @param the lib to set */
61 void setLibrary( const QCString& lib ); 64 void setLibrary( const QCString& lib );
62 65
63 void setDefault( bool ); 66 void setDefault( bool );
64 void setPreference( int ); 67 void setPreference( int );
65 68
66private: 69private:
67 QString m_name; 70 QString m_name;
68 QString m_vendor; 71 QString m_vendor;
69 QString m_license; 72 QString m_license;
70 QCString m_lib; 73 QCString m_lib;
71 bool m_default :1; 74 bool m_default :1;
72 int m_pref; 75 int m_pref;
76 class Private;
77 Private *d;
73}; 78};
74 79
80}
81}
82
75#endif 83#endif
diff --git a/libopie2/opiedb/osqlbackendmanager.cpp b/libopie2/opiedb/osqlbackendmanager.cpp
index 95ed77b..fc18e07 100644
--- a/libopie2/opiedb/osqlbackendmanager.cpp
+++ b/libopie2/opiedb/osqlbackendmanager.cpp
@@ -1,94 +1,102 @@
1#include <qdir.h> 1#include <qdir.h>
2#include <qmap.h> 2#include <qmap.h>
3 3
4#include "osqlbackendmanager.h" 4#include "osqlbackendmanager.h"
5 5
6/**
7 * \todo FIXME CONFIG!!!
8 */
9
6namespace { 10namespace {
7 class Config { 11 class Config {
8 typedef QMap<QString, QString> List; 12 typedef QMap<QString, QString> List;
9 public: 13 public:
10 Config( const QString& fileName ); 14 Config( const QString& fileName );
11 /** 15 /**
12 * Quite simple layout in nature 16 * Quite simple layout in nature
13 * BeginFile 17 * BeginFile
14 * Key = Value 18 * Key = Value
15 */ 19 */
16 bool load(); 20 bool load();
17 QString value( const QString& key ); 21 QString value( const QString& key );
18 private: 22 private:
19 List m_list; 23 List m_list;
20 QString m_fileName; 24 QString m_fileName;
21 }; 25 };
22 Config::Config( const QString& fileName ) 26 Config::Config( const QString& fileName )
23 : m_fileName( fileName ) { 27 : m_fileName( fileName ) {
24 } 28 }
25 29
26 bool Config::load() { 30 bool Config::load() {
27 if (!QFile::exists( m_fileName ) ) 31 if (!QFile::exists( m_fileName ) )
28 return false; 32 return false;
29 QFile file( m_fileName ); 33 QFile file( m_fileName );
30 if (!file.open(IO_ReadOnly ) ) 34 if (!file.open(IO_ReadOnly ) )
31 return false; 35 return false;
32 QStringList list = QStringList::split( '\n', file.readAll() ); 36 QStringList list = QStringList::split( '\n', file.readAll() );
33 QStringList::Iterator it; 37 QStringList::Iterator it;
34 QString line; 38 QString line;
35 for (it = list.begin(); it != list.end(); ++it ) { 39 for (it = list.begin(); it != list.end(); ++it ) {
36 line = (*it).stripWhiteSpace(); 40 line = (*it).stripWhiteSpace();
37 qWarning("Anonymous::Config:" + line ); 41 qWarning("Anonymous::Config:" + line );
38 QStringList test = QStringList::split(' ', line ); 42 QStringList test = QStringList::split(' ', line );
39 m_list.insert( test[0], test[2] ); 43 m_list.insert( test[0], test[2] );
40 } 44 }
41 return true; 45 return true;
42 } 46 }
43 QString Config::value( const QString& key ) { 47 QString Config::value( const QString& key ) {
44 return m_list[key]; 48 return m_list[key];
45 } 49 }
46}; 50};
51
52
53using namespace Opie::DB;
54
47OSQLBackEndManager::OSQLBackEndManager( const QStringList& path ) 55OSQLBackEndManager::OSQLBackEndManager( const QStringList& path )
48 :m_path( path ) 56 :m_path( path )
49{ 57{
50} 58}
51OSQLBackEndManager::~OSQLBackEndManager() { 59OSQLBackEndManager::~OSQLBackEndManager() {
52} 60}
53/** 61/**
54 * scan dirs 62 * scan dirs
55 */ 63 */
56OSQLBackEnd::ValueList OSQLBackEndManager::scan() { 64OSQLBackEnd::ValueList OSQLBackEndManager::scan() {
57 OSQLBackEnd::ValueList list; 65 OSQLBackEnd::ValueList list;
58 if (!m_path.isEmpty() ) { 66 if (!m_path.isEmpty() ) {
59 QStringList::Iterator it; 67 QStringList::Iterator it;
60 for ( it = m_path.begin(); it != m_path.end(); ++it ) { 68 for ( it = m_path.begin(); it != m_path.end(); ++it ) {
61 list += scanDir( (*it) ); 69 list += scanDir( (*it) );
62 } 70 }
63 } 71 }
64 return list; 72 return list;
65} 73}
66/** 74/**
67 * scan a specified dir for *.osql 75 * scan a specified dir for *.osql
68 */ 76 */
69OSQLBackEnd::ValueList OSQLBackEndManager::scanDir( const QString& dirName ) { 77OSQLBackEnd::ValueList OSQLBackEndManager::scanDir( const QString& dirName ) {
70 OSQLBackEnd::ValueList list; 78 OSQLBackEnd::ValueList list;
71 QDir dir( dirName ); 79 QDir dir( dirName );
72 if (dir.exists() ) { 80 if (dir.exists() ) {
73 QStringList files = dir.entryList( "*.osql" ); 81 QStringList files = dir.entryList( "*.osql" );
74 QStringList::Iterator it; 82 QStringList::Iterator it;
75 for ( it = files.begin(); it != files.end(); ++it ) { 83 for ( it = files.begin(); it != files.end(); ++it ) {
76 list.append( file2backend( (*it) ) ); 84 list.append( file2backend( (*it) ) );
77 } 85 }
78 } 86 }
79 return list; 87 return list;
80} 88}
81 89
82/** 90/**
83 * read a config file and convert it to a OSQLBackEnd 91 * read a config file and convert it to a OSQLBackEnd
84 */ 92 */
85OSQLBackEnd OSQLBackEndManager::file2backend( const QString& file ) { 93OSQLBackEnd OSQLBackEndManager::file2backend( const QString& file ) {
86 OSQLBackEnd end; 94 OSQLBackEnd end;
87 qWarning("fileName: " + file ); 95 qWarning("fileName: " + file );
88 Config cfg( file ); 96 Config cfg( file );
89 if (cfg.load() ) { 97 if (cfg.load() ) {
90 end.setName( cfg.value( "Name") ); 98 end.setName( cfg.value( "Name") );
91 end.setVendor( cfg.value("Vendor") ); 99 end.setVendor( cfg.value("Vendor") );
92 end.setLicense( cfg.value("License") ); 100 end.setLicense( cfg.value("License") );
93 end.setLibrary( cfg.value("Library").local8Bit() ); 101 end.setLibrary( cfg.value("Library").local8Bit() );
94 end.setDefault( cfg.value("Default").toInt() ); 102 end.setDefault( cfg.value("Default").toInt() );
diff --git a/libopie2/opiedb/osqlbackendmanager.h b/libopie2/opiedb/osqlbackendmanager.h
index bc357a9..00e81fc 100644
--- a/libopie2/opiedb/osqlbackendmanager.h
+++ b/libopie2/opiedb/osqlbackendmanager.h
@@ -1,20 +1,26 @@
1#ifndef OSQL_BACKEND_MANAGER_H 1#ifndef OSQL_BACKEND_MANAGER_H
2#define OSQL_BACKEND_MANAGER_H 2#define OSQL_BACKEND_MANAGER_H
3 3
4#include <qstringlist.h> 4#include <qstringlist.h>
5 5
6#include "osqlbackend.h" 6#include "osqlbackend.h"
7 7
8namespace Opie {
9namespace DB {
10
8class OSQLBackEndManager { 11class OSQLBackEndManager {
9public: 12public:
10 OSQLBackEndManager(const QStringList& path ); 13 OSQLBackEndManager(const QStringList& path );
11 ~OSQLBackEndManager(); 14 ~OSQLBackEndManager();
12 OSQLBackEnd::ValueList scan(); 15 OSQLBackEnd::ValueList scan();
13private: 16private:
14 OSQLBackEnd::ValueList scanDir( const QString& dir ); 17 OSQLBackEnd::ValueList scanDir( const QString& dir );
15 OSQLBackEnd file2backend( const QString& file ); 18 OSQLBackEnd file2backend( const QString& file );
16 class OSQLBackEndManagerPrivate; 19 class OSQLBackEndManagerPrivate;
17 OSQLBackEndManagerPrivate* d; 20 OSQLBackEndManagerPrivate* d;
18 QStringList m_path; 21 QStringList m_path;
19}; 22};
23}
24}
25
20#endif 26#endif
diff --git a/libopie2/opiedb/osqldriver.cpp b/libopie2/opiedb/osqldriver.cpp
index 258c116..a6dae77 100644
--- a/libopie2/opiedb/osqldriver.cpp
+++ b/libopie2/opiedb/osqldriver.cpp
@@ -1,13 +1,15 @@
1#include <qpe/qlibrary.h> 1#include <qpe/qlibrary.h>
2 2
3#include "osqldriver.h" 3#include "osqldriver.h"
4 4
5using namespace Opie::DB;
6
5OSQLDriver::OSQLDriver( QLibrary* lib ) 7OSQLDriver::OSQLDriver( QLibrary* lib )
6: QObject(), m_lib(lib) { 8: QObject(), m_lib(lib) {
7} 9}
8OSQLDriver::~OSQLDriver() { 10OSQLDriver::~OSQLDriver() {
9 delete m_lib; 11 delete m_lib;
10} 12}
11bool OSQLDriver::sync() { 13bool OSQLDriver::sync() {
12 return true; 14 return true;
13} 15}
diff --git a/libopie2/opiedb/osqldriver.h b/libopie2/opiedb/osqldriver.h
index 68d8ee6..492b8dd 100644
--- a/libopie2/opiedb/osqldriver.h
+++ b/libopie2/opiedb/osqldriver.h
@@ -1,87 +1,94 @@
1#ifndef OSQL_DRIVER_H 1#ifndef OSQL_DRIVER_H
2#define OSQL_DRIVER_H 2#define OSQL_DRIVER_H
3 3
4#include <qobject.h> 4#include <qobject.h>
5#include <qstring.h> 5#include <qstring.h>
6 6
7#include "osqltable.h" 7#include "osqltable.h"
8 8
9class QLibrary; 9class QLibrary;
10
11namespace Opie {
12namespace DB {
13
10class OSQLResult; 14class OSQLResult;
11class OSQLQuery; 15class OSQLQuery;
12class OSQLError; 16class OSQLError;
13 17
14/** 18/**
15 * A OSQLDriver implements the communication with 19 * A OSQLDriver implements the communication with
16 * a database. 20 * a database.
17 * After you queried and loaded a driver you can 21 * After you queried and loaded a driver you can
18 * set some informations and finally try to open 22 * set some informations and finally try to open
19 * the database 23 * the database
20 * 24 *
21 */ 25 */
22class OSQLDriver : public QObject{ 26class OSQLDriver : public QObject{
23 Q_OBJECT 27 Q_OBJECT
24public: 28public:
25 enum Capabilities { RowID=0 }; 29 enum Capabilities { RowID=0 };
26 /** 30 /**
27 * OSQLDriver constructor. It takes the QLibrary 31 * OSQLDriver constructor. It takes the QLibrary
28 * as parent. 32 * as parent.
29 * 33 *
30 */ 34 */
31 OSQLDriver( QLibrary* lib=0 ); 35 OSQLDriver( QLibrary* lib=0 );
32 36
33 virtual ~OSQLDriver(); 37 virtual ~OSQLDriver();
34 /** 38 /**
35 * Id returns the identifier of the OSQLDriver 39 * Id returns the identifier of the OSQLDriver
36 */ 40 */
37 virtual QString id()const = 0; 41 virtual QString id()const = 0;
38 42
39 /** 43 /**
40 * set the UserName to the database 44 * set the UserName to the database
41 */ 45 */
42 virtual void setUserName( const QString& ) = 0; 46 virtual void setUserName( const QString& ) = 0;
43 47
44 /** 48 /**
45 * set the PassWord to the database 49 * set the PassWord to the database
46 */ 50 */
47 virtual void setPassword( const QString& )= 0; 51 virtual void setPassword( const QString& )= 0;
48 52
49 /** 53 /**
50 * set the Url 54 * set the Url
51 */ 55 */
52 virtual void setUrl( const QString& ) = 0; 56 virtual void setUrl( const QString& ) = 0;
53 57
54 /** 58 /**
55 * setOptions 59 * setOptions
56 */ 60 */
57 virtual void setOptions( const QStringList& ) = 0; 61 virtual void setOptions( const QStringList& ) = 0;
58 62
59 /** 63 /**
60 * tries to open a connection to the database 64 * tries to open a connection to the database
61 */ 65 */
62 virtual bool open() = 0; 66 virtual bool open() = 0;
63 virtual bool close() = 0; 67 virtual bool close() = 0;
64 68
65 virtual OSQLError lastError() = 0; 69 virtual OSQLError lastError() = 0;
66 70
67 /** 71 /**
68 * Query the Database with a OSQLQuery 72 * Query the Database with a OSQLQuery
69 * OSQLResult holds the result 73 * OSQLResult holds the result
70 */ 74 */
71 virtual OSQLResult query( OSQLQuery* ) = 0; 75 virtual OSQLResult query( OSQLQuery* ) = 0;
72 76
73 /** 77 /**
74 * Get a list of tables 78 * Get a list of tables
75 */ 79 */
76 virtual OSQLTable::ValueList tables() const = 0l; 80 virtual OSQLTable::ValueList tables() const = 0l;
77 virtual bool sync(); 81 virtual bool sync();
78 82
79 83
80private: 84private:
81 QLibrary* m_lib; 85 QLibrary* m_lib;
82 class OSQLDriverPrivate; 86 class OSQLDriverPrivate;
83 OSQLDriverPrivate *d; 87 OSQLDriverPrivate *d;
84 88
85}; 89};
86 90
91}
92}
93
87#endif 94#endif
diff --git a/libopie2/opiedb/osqlerror.cpp b/libopie2/opiedb/osqlerror.cpp
index 3890a50..165ba65 100644
--- a/libopie2/opiedb/osqlerror.cpp
+++ b/libopie2/opiedb/osqlerror.cpp
@@ -1,23 +1,25 @@
1#include "osqlerror.h" 1#include "osqlerror.h"
2 2
3using namespace Opie::DB;
4
3OSQLError::OSQLError( const QString& driverText, 5OSQLError::OSQLError( const QString& driverText,
4 const QString& driverDatabaseText, 6 const QString& driverDatabaseText,
5 int type, int subType ) 7 int type, int subType )
6 : m_drvText( driverText ), m_drvDBText( driverDatabaseText ), 8 : m_drvText( driverText ), m_drvDBText( driverDatabaseText ),
7 m_type( type ), m_number( subType ) 9 m_type( type ), m_number( subType )
8{ 10{
9} 11}
10OSQLError::~OSQLError() { 12OSQLError::~OSQLError() {
11} 13}
12QString OSQLError::driverText()const { 14QString OSQLError::driverText()const {
13 return m_drvText; 15 return m_drvText;
14} 16}
15QString OSQLError::databaseText()const { 17QString OSQLError::databaseText()const {
16 return m_drvDBText; 18 return m_drvDBText;
17} 19}
18int OSQLError::type()const { 20int OSQLError::type()const {
19 return m_type; 21 return m_type;
20} 22}
21int OSQLError::subNumber()const { 23int OSQLError::subNumber()const {
22 return m_number; 24 return m_number;
23} 25}
diff --git a/libopie2/opiedb/osqlerror.h b/libopie2/opiedb/osqlerror.h
index 35a4368..8fa973d 100644
--- a/libopie2/opiedb/osqlerror.h
+++ b/libopie2/opiedb/osqlerror.h
@@ -1,59 +1,64 @@
1#ifndef OSQL_ERROR_H 1#ifndef OSQL_ERROR_H
2#define OSQL_ERROR_H 2#define OSQL_ERROR_H
3 3
4#include <qstring.h> 4#include <qstring.h>
5#include <qvaluelist.h> 5#include <qvaluelist.h>
6 6
7
8namespace Opie {
9namespace DB {
7/** 10/**
8 * OSQLError is the base class of all errors 11 * OSQLError is the base class of all errors
9 */ 12 */
10class OSQLError { 13class OSQLError {
11public: 14public:
12 typedef QValueList<OSQLError> ValueList; 15 typedef QValueList<OSQLError> ValueList;
13 enum Type { None = 0, // NoError 16 enum Type { None = 0, // NoError
14 Internal, // Internal Error in OSQL 17 Internal, // Internal Error in OSQL
15 Unknown, // Unknown Error 18 Unknown, // Unknown Error
16 Transaction, // Transaction Error 19 Transaction, // Transaction Error
17 Statement, // Wrong Statement 20 Statement, // Wrong Statement
18 Connection, // Connection Error( lost ) 21 Connection, // Connection Error( lost )
19 Driver // Driver Specefic error 22 Driver // Driver Specefic error
20 }; 23 };
21 enum DriverError { 24 enum DriverError {
22 DriverInternal=0, // internal DriverError 25 DriverInternal=0, // internal DriverError
23 Permission, // Permission Problem 26 Permission, // Permission Problem
24 Abort, // Abort of the SQL 27 Abort, // Abort of the SQL
25 Busy, // Busy Error 28 Busy, // Busy Error
26 Locked, // Locked 29 Locked, // Locked
27 NoMem, // No Memory 30 NoMem, // No Memory
28 ReadOnly, // Database is read only 31 ReadOnly, // Database is read only
29 Interrupt, // Interrupt 32 Interrupt, // Interrupt
30 IOErr, // IO Error 33 IOErr, // IO Error
31 Corrupt, // Database Corruption 34 Corrupt, // Database Corruption
32 NotFound, // Table not Found 35 NotFound, // Table not Found
33 Full, // Full 36 Full, // Full
34 CantOpen, // Can not open Table/Database 37 CantOpen, // Can not open Table/Database
35 Protocol, // internal protocol error 38 Protocol, // internal protocol error
36 Schema, // schema changed 39 Schema, // schema changed
37 TooBig, // Data too big 40 TooBig, // Data too big
38 Mismatch, // Type mismatch 41 Mismatch, // Type mismatch
39 Misuse // misuse 42 Misuse // misuse
40 }; 43 };
41 OSQLError( const QString& driverText = QString::null, 44 OSQLError( const QString& driverText = QString::null,
42 const QString& driverDatabaseText = QString::null, 45 const QString& driverDatabaseText = QString::null,
43 int type = None, int subNumber = -1 ); 46 int type = None, int subNumber = -1 );
44 ~OSQLError(); 47 ~OSQLError();
45 48
46 QString driverText()const; 49 QString driverText()const;
47 QString databaseText()const; 50 QString databaseText()const;
48 int type()const; 51 int type()const;
49 int subNumber()const; 52 int subNumber()const;
50private: 53private:
51 QString m_drvText; 54 QString m_drvText;
52 QString m_drvDBText; 55 QString m_drvDBText;
53 int m_type; 56 int m_type;
54 int m_number; 57 int m_number;
55 class OSQLErrorPrivate; 58 class OSQLErrorPrivate;
56 OSQLErrorPrivate* d; 59 OSQLErrorPrivate* d;
57}; 60};
58 61
62}
63}
59#endif 64#endif
diff --git a/libopie2/opiedb/osqlitedriver.cpp b/libopie2/opiedb/osqlitedriver.cpp
index 6141504..47bc250 100644
--- a/libopie2/opiedb/osqlitedriver.cpp
+++ b/libopie2/opiedb/osqlitedriver.cpp
@@ -1,177 +1,180 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3 3
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 30
31#include "osqlquery.h" 31#include "osqlquery.h"
32#include "osqlitedriver.h" 32#include "osqlitedriver.h"
33 33
34#include <opie2/odebug.h> 34#include <opie2/odebug.h>
35 35
36#include <stdlib.h> 36#include <stdlib.h>
37 37
38// fromLocal8Bit() does not work as expected. Thus it 38// fromLocal8Bit() does not work as expected. Thus it
39// is replaced by fromLatin1() (eilers) 39// is replaced by fromLatin1() (eilers)
40#define __BUGGY_LOCAL8BIT_ 40#define __BUGGY_LOCAL8BIT_
41 41
42 42
43using namespace Opie::DB;
44using namespace Opie::DB::Private;
45
43namespace { 46namespace {
44 struct Query { 47 struct Query {
45 OSQLError::ValueList errors; 48 OSQLError::ValueList errors;
46 OSQLResultItem::ValueList items; 49 OSQLResultItem::ValueList items;
47 OSQLiteDriver *driver; 50 OSQLiteDriver *driver;
48 }; 51 };
49} 52}
50 53
51 54
52OSQLiteDriver::OSQLiteDriver( QLibrary *lib ) 55OSQLiteDriver::OSQLiteDriver( QLibrary *lib )
53 : OSQLDriver( lib ) 56 : OSQLDriver( lib )
54{ 57{
55 m_sqlite = 0l; 58 m_sqlite = 0l;
56} 59}
57 60
58 61
59OSQLiteDriver::~OSQLiteDriver() { 62OSQLiteDriver::~OSQLiteDriver() {
60 close(); 63 close();
61} 64}
62 65
63 66
64QString OSQLiteDriver::id()const { 67QString OSQLiteDriver::id()const {
65 return QString::fromLatin1("SQLite"); 68 return QString::fromLatin1("SQLite");
66} 69}
67 70
68void OSQLiteDriver::setUserName( const QString& ) {} 71void OSQLiteDriver::setUserName( const QString& ) {}
69 72
70 73
71void OSQLiteDriver::setPassword( const QString& ) {} 74void OSQLiteDriver::setPassword( const QString& ) {}
72 75
73 76
74void OSQLiteDriver::setUrl( const QString& url ) { 77void OSQLiteDriver::setUrl( const QString& url ) {
75 m_url = url; 78 m_url = url;
76} 79}
77 80
78 81
79void OSQLiteDriver::setOptions( const QStringList& ) { 82void OSQLiteDriver::setOptions( const QStringList& ) {
80} 83}
81 84
82 85
83/* 86/*
84 * try to open a db specified via setUrl 87 * try to open a db specified via setUrl
85 * and options 88 * and options
86 */ 89 */
87bool OSQLiteDriver::open() { 90bool OSQLiteDriver::open() {
88 char *error; 91 char *error;
89 odebug << "OSQLiteDriver::open: about to open" << oendl; 92 qDebug("OSQLiteDriver::open: about to open");
90 m_sqlite = sqlite_open(m_url.local8Bit(), 93 m_sqlite = sqlite_open(m_url.local8Bit(),
91 0, 94 0,
92 &error ); 95 &error );
93 96
94 /* failed to open */ 97 /* failed to open */
95 if (m_sqlite == 0l ) { 98 if (m_sqlite == 0l ) {
96 // FIXME set the last error 99 // FIXME set the last error
97 owarn << "OSQLiteDriver::open: " << error << oendl; 100 qWarning("OSQLiteDriver::open: %s", error );
98 free( error ); 101 free( error );
99 return false; 102 return false;
100 } 103 }
101 return true; 104 return true;
102} 105}
103 106
104 107
105/* close the db 108/* close the db
106 * sqlite closes them without 109 * sqlite closes them without
107 * telling failure or success 110 * telling failure or success
108 */ 111 */
109bool OSQLiteDriver::close() { 112bool OSQLiteDriver::close() {
110 if (m_sqlite ) 113 if (m_sqlite )
111 sqlite_close( m_sqlite ), m_sqlite=0l; 114 sqlite_close( m_sqlite ), m_sqlite=0l;
112 115
113 return true; 116 return true;
114} 117}
115 118
116 119
117/* Query */ 120/* Query */
118OSQLResult OSQLiteDriver::query( OSQLQuery* qu) { 121OSQLResult OSQLiteDriver::query( OSQLQuery* qu) {
119 if ( !m_sqlite ) { 122 if ( !m_sqlite ) {
120 // FIXME set error code 123 // FIXME set error code
121 OSQLResult result( OSQLResult::Failure ); 124 OSQLResult result( OSQLResult::Failure );
122 return result; 125 return result;
123 } 126 }
124 Query query; 127 Query query;
125 query.driver = this; 128 query.driver = this;
126 char *err; 129 char *err;
127 /* SQLITE_OK 0 if return code > 0 == failure */ 130 /* SQLITE_OK 0 if return code > 0 == failure */
128 if ( sqlite_exec(m_sqlite, qu->query(),&call_back, &query, &err) > 0 ) { 131 if ( sqlite_exec(m_sqlite, qu->query(),&call_back, &query, &err) > 0 ) {
129 owarn << "OSQLiteDriver::query: Error while executing" << oendl; 132 qWarning("OSQLiteDriver::query: Error while executing");
130 free(err ); 133 free(err );
131 // FixMe Errors 134 // FixMe Errors
132 } 135 }
133 136
134 OSQLResult result(OSQLResult::Success, 137 OSQLResult result(OSQLResult::Success,
135 query.items, 138 query.items,
136 query.errors ); 139 query.errors );
137 return result; 140 return result;
138} 141}
139 142
140 143
141OSQLTable::ValueList OSQLiteDriver::tables() const { 144OSQLTable::ValueList OSQLiteDriver::tables() const {
142 145
143} 146}
144 147
145 148
146OSQLError OSQLiteDriver::lastError() { 149OSQLError OSQLiteDriver::lastError() {
147 OSQLError error; 150 OSQLError error;
148 return error; 151 return error;
149}; 152};
150 153
151 154
152/* handle a callback add the row to the global 155/* handle a callback add the row to the global
153 * OSQLResultItem 156 * OSQLResultItem
154 */ 157 */
155int OSQLiteDriver::handleCallBack( int, char**, char** ) { 158int OSQLiteDriver::handleCallBack( int, char**, char** ) {
156 return 0; 159 return 0;
157} 160}
158 161
159 162
160/* callback_handler add the values to the list*/ 163/* callback_handler add the values to the list*/
161int OSQLiteDriver::call_back( void* voi, int argc, 164int OSQLiteDriver::call_back( void* voi, int argc,
162 char** argv, char** columns) { 165 char** argv, char** columns) {
163 Query* qu = (Query*)voi; 166 Query* qu = (Query*)voi;
164 167
165 //copy them over to a OSQLResultItem 168 //copy them over to a OSQLResultItem
166 QMap<QString, QString> tableString; 169 QMap<QString, QString> tableString;
167 QMap<int, QString> tableInt; 170 QMap<int, QString> tableInt;
168 for (int i = 0; i < argc; i++ ) { 171 for (int i = 0; i < argc; i++ ) {
169 172
170#ifdef __BUGGY_LOCAL8BIT_ 173#ifdef __BUGGY_LOCAL8BIT_
171 tableInt.insert( i, QString::fromLatin1( argv[i] ) ); 174 tableInt.insert( i, QString::fromLatin1( argv[i] ) );
172 tableString.insert( QString::fromLatin1( columns[i] ), 175 tableString.insert( QString::fromLatin1( columns[i] ),
173 QString::fromLatin1( argv[i] ) ); 176 QString::fromLatin1( argv[i] ) );
174#else 177#else
175 tableInt.insert( i, QString::fromLocal8Bit( argv[i] ) ); 178 tableInt.insert( i, QString::fromLocal8Bit( argv[i] ) );
176 tableString.insert( QString::fromLocal8Bit( columns[i] ), 179 tableString.insert( QString::fromLocal8Bit( columns[i] ),
177 QString::fromLocal8Bit( argv[i] ) ); 180 QString::fromLocal8Bit( argv[i] ) );
diff --git a/libopie2/opiedb/osqlitedriver.h b/libopie2/opiedb/osqlitedriver.h
index 6984539..3e1325b 100644
--- a/libopie2/opiedb/osqlitedriver.h
+++ b/libopie2/opiedb/osqlitedriver.h
@@ -1,34 +1,42 @@
1#ifndef OSQL_LITE_DRIVER_H 1#ifndef OSQL_LITE_DRIVER_H
2#define OSQL_LITE_DRIVER_H 2#define OSQL_LITE_DRIVER_H
3 3
4#include <sqlite.h> 4#include <sqlite.h>
5 5
6#include "osqldriver.h" 6#include "osqldriver.h"
7#include "osqlerror.h" 7#include "osqlerror.h"
8#include "osqlresult.h" 8#include "osqlresult.h"
9 9
10namespace Opie {
11namespace DB {
12namespace Private {
13
10class OSQLiteDriver : public OSQLDriver { 14class OSQLiteDriver : public OSQLDriver {
11 Q_OBJECT 15 Q_OBJECT
12public: 16public:
13 OSQLiteDriver( QLibrary *lib = 0l ); 17 OSQLiteDriver( QLibrary *lib = 0l );
14 ~OSQLiteDriver(); 18 ~OSQLiteDriver();
15 QString id()const; 19 QString id()const;
16 void setUserName( const QString& ); 20 void setUserName( const QString& );
17 void setPassword( const QString& ); 21 void setPassword( const QString& );
18 void setUrl( const QString& url ); 22 void setUrl( const QString& url );
19 void setOptions( const QStringList& ); 23 void setOptions( const QStringList& );
20 bool open(); 24 bool open();
21 bool close(); 25 bool close();
22 OSQLError lastError(); 26 OSQLError lastError();
23 OSQLResult query( OSQLQuery* ); 27 OSQLResult query( OSQLQuery* );
24 OSQLTable::ValueList tables()const; 28 OSQLTable::ValueList tables()const;
25private: 29private:
26 OSQLError m_lastE; 30 OSQLError m_lastE;
27 OSQLResult m_result; 31 OSQLResult m_result;
28 OSQLResultItem m_items; 32 OSQLResultItem m_items;
29 int handleCallBack( int, char**, char** ); 33 int handleCallBack( int, char**, char** );
30 static int call_back( void*, int, char**, char** ); 34 static int call_back( void*, int, char**, char** );
31 QString m_url; 35 QString m_url;
32 sqlite *m_sqlite; 36 sqlite *m_sqlite;
33}; 37};
38}
39}
40}
41
34#endif 42#endif
diff --git a/libopie2/opiedb/osqlmanager.cpp b/libopie2/opiedb/osqlmanager.cpp
index 766ebe1..990d258 100644
--- a/libopie2/opiedb/osqlmanager.cpp
+++ b/libopie2/opiedb/osqlmanager.cpp
@@ -1,81 +1,83 @@
1 1
2#include <stdlib.h> 2#include <stdlib.h>
3 3
4#include "osqlmanager.h" 4#include "osqlmanager.h"
5#include "osqlbackendmanager.h" 5#include "osqlbackendmanager.h"
6#include "osqlitedriver.h" 6#include "osqlitedriver.h"
7 7
8using namespace Opie::DB;
9
8OSQLManager::OSQLManager() { 10OSQLManager::OSQLManager() {
9} 11}
10OSQLBackEnd::ValueList OSQLManager::queryBackEnd() { 12OSQLBackEnd::ValueList OSQLManager::queryBackEnd() {
11 m_list.clear(); 13 m_list.clear();
12 QString opie = QString::fromLatin1( getenv("OPIEDIR") ); 14 QString opie = QString::fromLatin1( getenv("OPIEDIR") );
13 QString qpe = QString::fromLatin1( getenv("QPEDIR") ); 15 QString qpe = QString::fromLatin1( getenv("QPEDIR") );
14 16
15 if ( !m_path.contains(opie) && !opie.isEmpty() ) 17 if ( !m_path.contains(opie) && !opie.isEmpty() )
16 m_path << opie; 18 m_path << opie;
17 if ( !m_path.contains(qpe) && !qpe.isEmpty() ) 19 if ( !m_path.contains(qpe) && !qpe.isEmpty() )
18 m_path << qpe; 20 m_path << qpe;
19 21
20 OSQLBackEndManager mng( m_path ); 22 OSQLBackEndManager mng( m_path );
21 m_list = mng.scan(); 23 m_list = mng.scan();
22 m_list += builtIn(); 24 m_list += builtIn();
23 25
24 return m_list; 26 return m_list;
25} 27}
26/* 28/*
27 * loading dso's is currently not enabled due problems with QLibrary 29 * loading dso's is currently not enabled due problems with QLibrary
28 * beeing in libqpe and not libqte 30 * beeing in libqpe and not libqte
29 */ 31 */
30OSQLDriver* OSQLManager::load( const QString& name ) { 32OSQLDriver* OSQLManager::load( const QString& name ) {
31 OSQLDriver* driver = 0l; 33 OSQLDriver* driver = 0l;
32 34
33 if ( name == "SQLite" ) { 35 if ( name == "SQLite" ) {
34 driver = new OSQLiteDriver(); 36 driver = new Opie::DB::Private::OSQLiteDriver;
35 } 37 }
36 return driver; 38 return driver;
37} 39}
38/* 40/*
39 * same as above 41 * same as above
40 */ 42 */
41OSQLDriver* OSQLManager::load( const OSQLBackEnd& end) { 43OSQLDriver* OSQLManager::load( const OSQLBackEnd& end) {
42 OSQLDriver *driver = 0l; 44 OSQLDriver *driver = 0l;
43 if ( end.library() == "builtin" && 45 if ( end.library() == "builtin" &&
44 end.name() == "SQLite" ) 46 end.name() == "SQLite" )
45 driver = new OSQLiteDriver(); 47 driver = new Opie::DB::Private::OSQLiteDriver;
46 48
47 return driver; 49 return driver;
48} 50}
49/* 51/*
50 * let's find the a default with the highes preference 52 * let's find the a default with the highes preference
51 */ 53 */
52OSQLDriver* OSQLManager::standard() { 54OSQLDriver* OSQLManager::standard() {
53 OSQLDriver* driver =0l; 55 OSQLDriver* driver =0l;
54 if ( m_list.isEmpty() ) queryBackEnd(); 56 if ( m_list.isEmpty() ) queryBackEnd();
55 OSQLBackEnd::ValueList::Iterator it; 57 OSQLBackEnd::ValueList::Iterator it;
56 OSQLBackEnd back; 58 OSQLBackEnd back;
57 for ( it = m_list.begin(); it != m_list.end(); ++it ) { 59 for ( it = m_list.begin(); it != m_list.end(); ++it ) {
58 if ( (*it).isDefault() && 60 if ( (*it).isDefault() &&
59 back.preference() < (*it).preference() ) { 61 back.preference() < (*it).preference() ) {
60 back = (*it); 62 back = (*it);
61 } 63 }
62 } 64 }
63 driver = load( back ); 65 driver = load( back );
64 return driver; 66 return driver;
65} 67}
66void OSQLManager::registerPath( const QString& path ) { 68void OSQLManager::registerPath( const QString& path ) {
67 m_path << path; 69 m_path << path;
68} 70}
69bool OSQLManager::unregisterPath( const QString& path ) { 71bool OSQLManager::unregisterPath( const QString& path ) {
70 m_path.remove( path ); 72 m_path.remove( path );
71 return true; 73 return true;
72} 74}
73OSQLBackEnd::ValueList OSQLManager::builtIn()const { 75OSQLBackEnd::ValueList OSQLManager::builtIn()const {
74 OSQLBackEnd::ValueList list; 76 OSQLBackEnd::ValueList list;
75 // create the OSQLiteBackend 77 // create the OSQLiteBackend
76 OSQLBackEnd back("SQLite","Opie e.V.","GPL", "builtin" ); 78 OSQLBackEnd back("SQLite","Opie e.V.","GPL", "builtin" );
77 back.setDefault( true ); 79 back.setDefault( true );
78 back.setPreference( 50 ); 80 back.setPreference( 50 );
79 list.append( back ); 81 list.append( back );
80 return list; 82 return list;
81} 83}
diff --git a/libopie2/opiedb/osqlmanager.h b/libopie2/opiedb/osqlmanager.h
index 5323b14..ca73c64 100644
--- a/libopie2/opiedb/osqlmanager.h
+++ b/libopie2/opiedb/osqlmanager.h
@@ -1,64 +1,70 @@
1 1
2#ifndef OSQL_MANAGER_H 2#ifndef OSQL_MANAGER_H
3#define OSQL_MANAGER_H 3#define OSQL_MANAGER_H
4 4
5#include <qobject.h> 5#include <qobject.h>
6#include <qstringlist.h> 6#include <qstringlist.h>
7 7
8#include "osqlbackend.h" 8#include "osqlbackend.h"
9 9
10 10
11namespace Opie {
12namespace DB {
11/** 13/**
12 * OSQLManager is responsible for loading 14 * OSQLManager is responsible for loading
13 * and unloading, querying different OSQL 15 * and unloading, querying different OSQL
14 * services 16 * services
15 * Load a OSQLDriver and delete it yourself 17 * Load a OSQLDriver and delete it yourself
16 * 18 *
17 */ 19 */
18class OSQLDriver; 20class OSQLDriver;
19class OSQLManager : public QObject { 21class OSQLManager : public QObject {
20 Q_OBJECT 22 Q_OBJECT
21public: 23public:
22 /** 24 /**
23 * Empty c'tor 25 * Empty c'tor
24 */ 26 */
25 OSQLManager(); 27 OSQLManager();
26 28
27 /** 29 /**
28 * Query the Manager for different backends 30 * Query the Manager for different backends
29 */ 31 */
30 OSQLBackEnd::ValueList queryBackEnd(); 32 OSQLBackEnd::ValueList queryBackEnd();
31 33
32 /** 34 /**
33 * Load a backend with it's name from param name 35 * Load a backend with it's name from param name
34 */ 36 */
35 OSQLDriver* load( const QString& name ); 37 OSQLDriver* load( const QString& name );
36 38
37 /** 39 /**
38 * Load a OSQLDevice from const reference of OSQLBackEnd 40 * Load a OSQLDevice from const reference of OSQLBackEnd
39 */ 41 */
40 OSQLDriver* load( const OSQLBackEnd& ); 42 OSQLDriver* load( const OSQLBackEnd& );
41 43
42 /** 44 /**
43 * loads the Opie standard backend 45 * loads the Opie standard backend
44 */ 46 */
45 OSQLDriver *standard(); 47 OSQLDriver *standard();
46 48
47 /** 49 /**
48 * register path to the search path list 50 * register path to the search path list
49 * When querying for services we scan all the 51 * When querying for services we scan all the
50 * registered path for backends 52 * registered path for backends
51 */ 53 */
52 void registerPath( const QString& path ); 54 void registerPath( const QString& path );
53 55
54 /** 56 /**
55 * unregisterPath from the search path list 57 * unregisterPath from the search path list
56 */ 58 */
57 bool unregisterPath( const QString& path ); 59 bool unregisterPath( const QString& path );
58private: 60private:
59 OSQLBackEnd::ValueList builtIn()const; 61 OSQLBackEnd::ValueList builtIn()const;
60 OSQLBackEnd::ValueList m_list; 62 OSQLBackEnd::ValueList m_list;
61 QStringList m_path; 63 QStringList m_path;
64 class Private;
65 Private *d;
62}; 66};
67}
68}
63 69
64#endif 70#endif
diff --git a/libopie2/opiedb/osqlquery.cpp b/libopie2/opiedb/osqlquery.cpp
index ecd53f2..8270c4c 100644
--- a/libopie2/opiedb/osqlquery.cpp
+++ b/libopie2/opiedb/osqlquery.cpp
@@ -1,17 +1,19 @@
1 1
2#include "osqlquery.h" 2#include "osqlquery.h"
3 3
4using namespace Opie::DB;
5
4OSQLQuery::OSQLQuery() { 6OSQLQuery::OSQLQuery() {
5} 7}
6OSQLQuery::~OSQLQuery() { 8OSQLQuery::~OSQLQuery() {
7} 9}
8 10
9OSQLRawQuery::OSQLRawQuery(const QString& query) 11OSQLRawQuery::OSQLRawQuery(const QString& query)
10 : OSQLQuery(), m_query( query ) { 12 : OSQLQuery(), m_query( query ) {
11 13
12} 14}
13OSQLRawQuery::~OSQLRawQuery() { 15OSQLRawQuery::~OSQLRawQuery() {
14} 16}
15QString OSQLRawQuery::query()const { 17QString OSQLRawQuery::query()const {
16 return m_query; 18 return m_query;
17} 19}
diff --git a/libopie2/opiedb/osqlquery.h b/libopie2/opiedb/osqlquery.h
index 63c26b0..0265d2b 100644
--- a/libopie2/opiedb/osqlquery.h
+++ b/libopie2/opiedb/osqlquery.h
@@ -1,122 +1,130 @@
1 1
2#ifndef OSQL_QUERY_H 2#ifndef OSQL_QUERY_H
3#define OSQL_QUERY_H 3#define OSQL_QUERY_H
4 4
5#include <qmap.h> 5#include <qmap.h>
6#include <qvaluelist.h> 6#include <qvaluelist.h>
7#include <qstring.h> 7#include <qstring.h>
8 8
9 9
10namespace Opie {
11namespace DB {
12
10/** I'm not happy with them 13/** I'm not happy with them
11class OSQLQueryOrder { 14class OSQLQueryOrder {
12public: 15public:
13 typedef QValueList<OSQLQueryOrder> ValueList; 16 typedef QValueList<OSQLQueryOrder> ValueList;
14 OSQLQueryOrder(const QString& table = QString::null ); 17 OSQLQueryOrder(const QString& table = QString::null );
15 OSQLQueryOrder( const OSQLQueryOrder& ); 18 OSQLQueryOrder( const OSQLQueryOrder& );
16 ~OSQLQueryOrder(); 19 ~OSQLQueryOrder();
17 void setOrderFields( const QStringList& list ); 20 void setOrderFields( const QStringList& list );
18 void setValue( const QString& fieldName, const QString& Value ); 21 void setValue( const QString& fieldName, const QString& Value );
19 void setValues( const QMap<QString, QString>& ); 22 void setValues( const QMap<QString, QString>& );
20 QMap<QString, QString> orders() const; 23 QMap<QString, QString> orders() const;
21 QString orderStatement()const; 24 QString orderStatement()const;
22 OSQLQueryOrder &operator=(const OSQLQueryOrder& ); 25 OSQLQueryOrder &operator=(const OSQLQueryOrder& );
23private: 26private:
24 QMap<QString, QString> m_fields; 27 QMap<QString, QString> m_fields;
25 class OSQLQueryOrderPrivate; 28 class OSQLQueryOrderPrivate;
26 OSQLQueryOrderPrivate* d; 29 OSQLQueryOrderPrivate* d;
27}; 30};
28class OSQLWhere { 31class OSQLWhere {
29public: 32public:
30 typedef QValueList<OSQLWhere> ValueList; 33 typedef QValueList<OSQLWhere> ValueList;
31 enum Vergleiche { Equal = 0, Like, Greater, GreaterEqual, 34 enum Vergleiche { Equal = 0, Like, Greater, GreaterEqual,
32 Smaller, SmallerEqual }; 35 Smaller, SmallerEqual };
33 OSQLWhere(const QString& table = QString::null ); 36 OSQLWhere(const QString& table = QString::null );
34 ~OSQLWhere(); 37 ~OSQLWhere();
35 void setExpression(const QString& key, enum Vergleiche, const QString& ); 38 void setExpression(const QString& key, enum Vergleiche, const QString& );
36 QString statement()const; 39 QString statement()const;
37private: 40private:
38 int m_vergleich; 41 int m_vergleich;
39 const QString& m_left; 42 const QString& m_left;
40 const QString& m_right; 43 const QString& m_right;
41 44
42}; 45};
43*/ 46*/
44class OSQLQuery { 47class OSQLQuery {
45public: 48public:
46 OSQLQuery(); 49 OSQLQuery();
47 virtual ~OSQLQuery(); 50 virtual ~OSQLQuery();
48 51
49 virtual QString query()const = 0; 52 virtual QString query()const = 0;
53private:
54 class Private;
55 Private *d;
50}; 56};
51 57
52class OSQLRawQuery : public OSQLQuery { 58class OSQLRawQuery : public OSQLQuery {
53public: 59public:
54 OSQLRawQuery( const QString& query ); 60 OSQLRawQuery( const QString& query );
55 ~OSQLRawQuery(); 61 ~OSQLRawQuery();
56 QString query() const; 62 QString query() const;
57private: 63private:
58 class OSQLRawQueryPrivate; 64 class OSQLRawQueryPrivate;
59 OSQLRawQueryPrivate* d; 65 OSQLRawQueryPrivate* d;
60 QString m_query; 66 QString m_query;
61 67
62}; 68};
63/* I'm not happy with them again 69/* I'm not happy with them again
64class OSQLSelectQuery : public OSQLQuery { 70class OSQLSelectQuery : public OSQLQuery {
65public: 71public:
66 OSQLSelectQuery(); 72 OSQLSelectQuery();
67 ~OSQLSelectQuery(); 73 ~OSQLSelectQuery();
68 void setTables( const QStringList& allTablesToQuery ); 74 void setTables( const QStringList& allTablesToQuery );
69 void setValues( const QString& table, const QStringList& columns ); 75 void setValues( const QString& table, const QStringList& columns );
70 void setOrder( const OSQLSelectQuery& ); 76 void setOrder( const OSQLSelectQuery& );
71 void setOrderList( const OSQLQueryOrder::ValueList& ); 77 void setOrderList( const OSQLQueryOrder::ValueList& );
72 void setWhereList( const OSQLWhere& ); 78 void setWhereList( const OSQLWhere& );
73 void setWhereList( const OSQLWhere::ValueList& ); 79 void setWhereList( const OSQLWhere::ValueList& );
74 QString query()const; 80 QString query()const;
75private: 81private:
76 QStringList m_tables; 82 QStringList m_tables;
77 QMap<QString, QStringList> m_values; 83 QMap<QString, QStringList> m_values;
78 OSQLQueryOrder::ValueList m_order; 84 OSQLQueryOrder::ValueList m_order;
79 OSQLWhere::ValueList m_where; 85 OSQLWhere::ValueList m_where;
80 class OSQLSelectQueryPrivate; 86 class OSQLSelectQueryPrivate;
81 OSQLSelectQueryPrivate* d; 87 OSQLSelectQueryPrivate* d;
82}; 88};
83class OSQLInsertQuery : public OSQLQuery { 89class OSQLInsertQuery : public OSQLQuery {
84public: 90public:
85 OSQLInsertQuery(const QString& table); 91 OSQLInsertQuery(const QString& table);
86 ~OSQLInsertQuery(); 92 ~OSQLInsertQuery();
87 void setInserFields( const QStringList& ); 93 void setInserFields( const QStringList& );
88 void setValue( const QString& field, const QString& value ); 94 void setValue( const QString& field, const QString& value );
89 void setValues(const QMap<QString, QString>& ); 95 void setValues(const QMap<QString, QString>& );
90 QString query()const; 96 QString query()const;
91private: 97private:
92 QString m_table; 98 QString m_table;
93 QStringList m_fields; 99 QStringList m_fields;
94 QMap<QString, QString> m_values; 100 QMap<QString, QString> m_values;
95}; 101};
96class OSQLDeleteQuery : public OSQLQuery { 102class OSQLDeleteQuery : public OSQLQuery {
97public: 103public:
98 OSQLDeleteQuery(const QString& table); 104 OSQLDeleteQuery(const QString& table);
99 ~OSQLDeleteQuery(); 105 ~OSQLDeleteQuery();
100 void setWhere( const OSQLWhere& ); 106 void setWhere( const OSQLWhere& );
101 void setWheres( const OSQLWhere::ValueList& ); 107 void setWheres( const OSQLWhere::ValueList& );
102 QString query()const; 108 QString query()const;
103private: 109private:
104 QString m_table; 110 QString m_table;
105 OSQLWhere::ValueList m_where; 111 OSQLWhere::ValueList m_where;
106 112
107}; 113};
108class OSQLUpdateQuery : public OSQLQuery { 114class OSQLUpdateQuery : public OSQLQuery {
109public: 115public:
110 OSQLUpdateQuery( const QString& table ); 116 OSQLUpdateQuery( const QString& table );
111 ~OSQLUpdateQuery(); 117 ~OSQLUpdateQuery();
112 void setWhere( const OSQLWhere& ); 118 void setWhere( const OSQLWhere& );
113 void setWheres( const OSQLWhere::ValueList& ); 119 void setWheres( const OSQLWhere::ValueList& );
114 */ 120 */
115 /* replaces all previous set Values */ 121 /* replaces all previous set Values */
116 /* 122 /*
117 void setValue( const QString& field, const QString& value ); 123 void setValue( const QString& field, const QString& value );
118 void setValue( const QMap<QString, QString> &fields ); 124 void setValue( const QMap<QString, QString> &fields );
119 QString query() const; 125 QString query() const;
120}; 126};
121*/ 127*/
128}
129}
122#endif 130#endif
diff --git a/libopie2/opiedb/osqlresult.cpp b/libopie2/opiedb/osqlresult.cpp
index 42da356..bad7d8b 100644
--- a/libopie2/opiedb/osqlresult.cpp
+++ b/libopie2/opiedb/osqlresult.cpp
@@ -1,51 +1,53 @@
1 1
2#include "osqlresult.h" 2#include "osqlresult.h"
3 3
4using namespace Opie::DB;
5
4OSQLResultItem::OSQLResultItem( const TableString& string, 6OSQLResultItem::OSQLResultItem( const TableString& string,
5 const TableInt& Int) 7 const TableInt& Int)
6 : m_string( string ), m_int( Int ) 8 : m_string( string ), m_int( Int )
7{ 9{
8 10
9} 11}
10OSQLResultItem::~OSQLResultItem() { 12OSQLResultItem::~OSQLResultItem() {
11} 13}
12OSQLResultItem::OSQLResultItem( const OSQLResultItem& item) { 14OSQLResultItem::OSQLResultItem( const OSQLResultItem& item) {
13 *this = item; 15 *this = item;
14} 16}
15OSQLResultItem &OSQLResultItem::operator=( const OSQLResultItem& other) { 17OSQLResultItem &OSQLResultItem::operator=( const OSQLResultItem& other) {
16 m_string = other.m_string; 18 m_string = other.m_string;
17 m_int = other.m_int; 19 m_int = other.m_int;
18 return *this; 20 return *this;
19} 21}
20OSQLResultItem::TableString OSQLResultItem::tableString()const{ 22OSQLResultItem::TableString OSQLResultItem::tableString()const{
21 return m_string; 23 return m_string;
22} 24}
23OSQLResultItem::TableInt OSQLResultItem::tableInt()const { 25OSQLResultItem::TableInt OSQLResultItem::tableInt()const {
24 return m_int; 26 return m_int;
25} 27}
26QString OSQLResultItem::data( const QString& columnName, bool *ok ) { 28QString OSQLResultItem::data( const QString& columnName, bool *ok ) {
27 TableString::Iterator it = m_string.find( columnName ); 29 TableString::Iterator it = m_string.find( columnName );
28 30
29 /* if found */ 31 /* if found */
30 if ( it != m_string.end() ) { 32 if ( it != m_string.end() ) {
31 if ( ok ) *ok = true; 33 if ( ok ) *ok = true;
32 return it.data(); 34 return it.data();
33 }else{ 35 }else{
34 if ( ok ) *ok = false; 36 if ( ok ) *ok = false;
35 return QString::null; 37 return QString::null;
36 } 38 }
37 39
38} 40}
39QString OSQLResultItem::data( int column, bool *ok ) { 41QString OSQLResultItem::data( int column, bool *ok ) {
40 TableInt::Iterator it = m_int.find( column ); 42 TableInt::Iterator it = m_int.find( column );
41 43
42 /* if found */ 44 /* if found */
43 if ( it != m_int.end() ) { 45 if ( it != m_int.end() ) {
44 if ( ok ) *ok = true; 46 if ( ok ) *ok = true;
45 return it.data(); 47 return it.data();
46 }else{ 48 }else{
47 if ( ok ) *ok = false; 49 if ( ok ) *ok = false;
48 return QString::null; 50 return QString::null;
49 } 51 }
50} 52}
51/* 53/*
diff --git a/libopie2/opiedb/osqlresult.h b/libopie2/opiedb/osqlresult.h
index 9c9efa2..fc6f01a 100644
--- a/libopie2/opiedb/osqlresult.h
+++ b/libopie2/opiedb/osqlresult.h
@@ -1,57 +1,61 @@
1#ifndef OSQL_RESULT_H 1#ifndef OSQL_RESULT_H
2#define OSQL_RESULT_H 2#define OSQL_RESULT_H
3 3
4#include <qdatetime.h> 4#include <qdatetime.h>
5#include <qmap.h> 5#include <qmap.h>
6#include <qvaluelist.h> 6#include <qvaluelist.h>
7 7
8 8
9#include "osqlerror.h" 9#include "osqlerror.h"
10
11namespace Opie {
12namespace DB {
13
10/** 14/**
11 * ResultItem represents one row of the resulting answer 15 * ResultItem represents one row of the resulting answer
12 */ 16 */
13class OSQLResultItem { 17class OSQLResultItem {
14public: 18public:
15 typedef QValueList<OSQLResultItem> ValueList; 19 typedef QValueList<OSQLResultItem> ValueList;
16 /** 20 /**
17 * TableString is used to establish the relations 21 * TableString is used to establish the relations
18 * between the column name and the real item 22 * between the column name and the real item
19 */ 23 */
20 typedef QMap<QString, QString> TableString; 24 typedef QMap<QString, QString> TableString;
21 25
22 /** 26 /**
23 * TableInt is used to establish a relation between a 27 * TableInt is used to establish a relation between a
24 * position of a column and the row value 28 * position of a column and the row value
25 */ 29 */
26 typedef QMap<int, QString> TableInt; 30 typedef QMap<int, QString> TableInt;
27 31
28 /** 32 /**
29 * Default c'tor. It has a TableString and a TableInt 33 * Default c'tor. It has a TableString and a TableInt
30 */ 34 */
31 OSQLResultItem(const TableString& = TableString(), 35 OSQLResultItem(const TableString& = TableString(),
32 const TableInt& = TableInt() ); 36 const TableInt& = TableInt() );
33 OSQLResultItem( const OSQLResultItem& ); 37 OSQLResultItem( const OSQLResultItem& );
34 ~OSQLResultItem(); 38 ~OSQLResultItem();
35 OSQLResultItem &operator=( const OSQLResultItem& ); 39 OSQLResultItem &operator=( const OSQLResultItem& );
36 /** 40 /**
37 * returns the TableString 41 * returns the TableString
38 */ 42 */
39 TableString tableString()const; 43 TableString tableString()const;
40 44
41 /** 45 /**
42 * returns the TableInt 46 * returns the TableInt
43 */ 47 */
44 TableInt tableInt() const; 48 TableInt tableInt() const;
45 49
46 /** 50 /**
47 * retrieves the Data from columnName 51 * retrieves the Data from columnName
48 * 52 *
49 */ 53 */
50 QString data( const QString& columnName, bool *ok = 0); 54 QString data( const QString& columnName, bool *ok = 0);
51 55
52 /** 56 /**
53 * QString for column number 57 * QString for column number
54 */ 58 */
55 QString data(int columnNumber, bool *ok = 0); 59 QString data(int columnNumber, bool *ok = 0);
56 60
57 /** 61 /**
@@ -62,51 +66,55 @@ public:
62 /** 66 /**
63 * Date conversion from column-number 67 * Date conversion from column-number
64 */ 68 */
65 QDate dataToDate( int columnNumber, bool *ok = 0 ); 69 QDate dataToDate( int columnNumber, bool *ok = 0 );
66 70
67 QDateTime dataToDateTime( const QString& columName, bool *ok = 0 ); 71 QDateTime dataToDateTime( const QString& columName, bool *ok = 0 );
68 QDateTime dataToDateTime( int columnNumber, bool *ok = 0 ); 72 QDateTime dataToDateTime( int columnNumber, bool *ok = 0 );
69private: 73private:
70 TableString m_string; 74 TableString m_string;
71 TableInt m_int; 75 TableInt m_int;
72}; 76};
73 77
74/** 78/**
75 * the OSQLResult 79 * the OSQLResult
76 * either a SQL statement failed or succeeded 80 * either a SQL statement failed or succeeded
77 */ 81 */
78class OSQLResult { 82class OSQLResult {
79public: 83public:
80 /** The State of a Result */ 84 /** The State of a Result */
81 enum State{ Success = 0, Failure,Undefined }; 85 enum State{ Success = 0, Failure,Undefined };
82 86
83 /** 87 /**
84 * default c'tor 88 * default c'tor
85 * @param state The State of the Result 89 * @param state The State of the Result
86 * @param r ResultItems 90 * @param r ResultItems
87 * @prarm errors the Errors a OSQLResult created 91 * @prarm errors the Errors a OSQLResult created
88 */ 92 */
89 OSQLResult( enum State state = Undefined, 93 OSQLResult( enum State state = Undefined,
90 const OSQLResultItem::ValueList& r= OSQLResultItem::ValueList(), 94 const OSQLResultItem::ValueList& r= OSQLResultItem::ValueList(),
91 const OSQLError::ValueList& errors = OSQLError::ValueList() ); 95 const OSQLError::ValueList& errors = OSQLError::ValueList() );
92 ~OSQLResult(); 96 ~OSQLResult();
93 State state()const; 97 State state()const;
94 OSQLError::ValueList errors()const; 98 OSQLError::ValueList errors()const;
95 OSQLResultItem::ValueList results()const; 99 OSQLResultItem::ValueList results()const;
96 100
97 void setState( enum State state ); 101 void setState( enum State state );
98 void setErrors( const OSQLError::ValueList& error ); 102 void setErrors( const OSQLError::ValueList& error );
99 void setResults( const OSQLResultItem::ValueList& result ); 103 void setResults( const OSQLResultItem::ValueList& result );
100 104
101 OSQLResultItem first(); 105 OSQLResultItem first();
102 OSQLResultItem next(); 106 OSQLResultItem next();
103 bool atEnd(); 107 bool atEnd();
104 OSQLResultItem::ValueList::ConstIterator iterator()const; 108 OSQLResultItem::ValueList::ConstIterator iterator()const;
105private: 109private:
106 enum State m_state; 110 enum State m_state;
107 OSQLResultItem::ValueList m_list; 111 OSQLResultItem::ValueList m_list;
108 OSQLError::ValueList m_error; 112 OSQLError::ValueList m_error;
109 OSQLResultItem::ValueList::Iterator it; 113 OSQLResultItem::ValueList::Iterator it;
114 class Private;
115 Private *d;
110}; 116};
111 117
118}
119}
112#endif 120#endif
diff --git a/libopie2/opiedb/osqltable.cpp b/libopie2/opiedb/osqltable.cpp
index cde40f4..117cf21 100644
--- a/libopie2/opiedb/osqltable.cpp
+++ b/libopie2/opiedb/osqltable.cpp
@@ -1,46 +1,48 @@
1#include "osqltable.h" 1#include "osqltable.h"
2 2
3using namespace Opie::DB;
4
3OSQLTableItem::OSQLTableItem() {} 5OSQLTableItem::OSQLTableItem() {}
4OSQLTableItem::OSQLTableItem( enum Type type, 6OSQLTableItem::OSQLTableItem( enum Type type,
5 const QString& field, 7 const QString& field,
6 const QVariant& var) 8 const QVariant& var)
7 : m_type( type ), m_field( field ), m_var( var ) 9 : m_type( type ), m_field( field ), m_var( var )
8{ 10{
9 11
10} 12}
11OSQLTableItem::~OSQLTableItem() {} 13OSQLTableItem::~OSQLTableItem() {}
12OSQLTableItem::OSQLTableItem( const OSQLTableItem& item) { 14OSQLTableItem::OSQLTableItem( const OSQLTableItem& item) {
13 *this = item; 15 *this = item;
14} 16}
15OSQLTableItem &OSQLTableItem::operator=(const OSQLTableItem& other) { 17OSQLTableItem &OSQLTableItem::operator=(const OSQLTableItem& other) {
16 m_var = other.m_var; 18 m_var = other.m_var;
17 m_field = other.m_field; 19 m_field = other.m_field;
18 m_type = other.m_type; 20 m_type = other.m_type;
19 return *this; 21 return *this;
20} 22}
21QString OSQLTableItem::fieldName()const{ 23QString OSQLTableItem::fieldName()const{
22 return m_field; 24 return m_field;
23} 25}
24OSQLTableItem::Type OSQLTableItem::type()const { 26OSQLTableItem::Type OSQLTableItem::type()const {
25 return m_type; 27 return m_type;
26} 28}
27QVariant OSQLTableItem::more()const { 29QVariant OSQLTableItem::more()const {
28 return m_var; 30 return m_var;
29} 31}
30 32
31OSQLTable::OSQLTable( const QString& tableName ) 33OSQLTable::OSQLTable( const QString& tableName )
32 : m_table( tableName ) 34 : m_table( tableName )
33{ 35{
34 36
35} 37}
36OSQLTable::~OSQLTable() { 38OSQLTable::~OSQLTable() {
37} 39}
38void OSQLTable::setColumns( const OSQLTableItem::ValueList& list) { 40void OSQLTable::setColumns( const OSQLTableItem::ValueList& list) {
39 m_list = list; 41 m_list = list;
40} 42}
41OSQLTableItem::ValueList OSQLTable::columns()const { 43OSQLTableItem::ValueList OSQLTable::columns()const {
42 return m_list; 44 return m_list;
43} 45}
44QString OSQLTable::tableName()const { 46QString OSQLTable::tableName()const {
45 return m_table; 47 return m_table;
46} 48}
diff --git a/libopie2/opiedb/osqltable.h b/libopie2/opiedb/osqltable.h
index 87f7e74..86c30dd 100644
--- a/libopie2/opiedb/osqltable.h
+++ b/libopie2/opiedb/osqltable.h
@@ -1,95 +1,102 @@
1#ifndef OSQL_TABLE_H 1#ifndef OSQL_TABLE_H
2#define OSQL_TABLE_H 2#define OSQL_TABLE_H
3 3
4#include <qstring.h> 4#include <qstring.h>
5#include <qvaluelist.h> 5#include <qvaluelist.h>
6#include <qvariant.h> 6#include <qvariant.h>
7 7
8namespace Opie {
9namespace DB {
8/** 10/**
9 * OSQLTableItem saves one column of a complete 11 * OSQLTableItem saves one column of a complete
10 * table 12 * table
11 */ 13 */
12class OSQLTableItem { 14class OSQLTableItem {
13public: 15public:
14 typedef QValueList<OSQLTableItem> ValueList; 16 typedef QValueList<OSQLTableItem> ValueList;
15 /** 17 /**
16 * Type kinds ( to be extended ) 18 * Type kinds ( to be extended )
17 */ 19 */
18 enum Type { Undefined=-1, Integer=0, BigInteger =1, 20 enum Type { Undefined=-1, Integer=0, BigInteger =1,
19 Float = 2, VarChar = 4 }; 21 Float = 2, VarChar = 4 };
20 /** 22 /**
21 * A constructor 23 * A constructor
22 * @param type the Type of the Column 24 * @param type the Type of the Column
23 * @param fieldName the Name of the Column 25 * @param fieldName the Name of the Column
24 * @param var a Variant 26 * @param var a Variant
25 */ 27 */
26 OSQLTableItem(); 28 OSQLTableItem();
27 OSQLTableItem( enum Type type, 29 OSQLTableItem( enum Type type,
28 const QString& fieldName, 30 const QString& fieldName,
29 const QVariant& var= QVariant() ); 31 const QVariant& var= QVariant() );
30 32
31 /** 33 /**
32 * copy c'tor 34 * copy c'tor
33 */ 35 */
34 OSQLTableItem( const OSQLTableItem& ); 36 OSQLTableItem( const OSQLTableItem& );
35 37
36 /** 38 /**
37 * d'tor 39 * d'tor
38 */ 40 */
39 ~OSQLTableItem(); 41 ~OSQLTableItem();
40 42
41 OSQLTableItem& operator=( const OSQLTableItem& ); 43 OSQLTableItem& operator=( const OSQLTableItem& );
42 44
43 /** 45 /**
44 * the fieldName 46 * the fieldName
45 */ 47 */
46 QString fieldName() const; 48 QString fieldName() const;
47 49
48 /** 50 /**
49 * the field Type 51 * the field Type
50 */ 52 */
51 Type type() const; 53 Type type() const;
52 QVariant more() const; 54 QVariant more() const;
53private: 55private:
54 class OSQLTableItemPrivate; 56 class OSQLTableItemPrivate;
55 OSQLTableItemPrivate* d; 57 OSQLTableItemPrivate* d;
56 Type m_type; 58 Type m_type;
57 QString m_field; 59 QString m_field;
58 QVariant m_var; 60 QVariant m_var;
59}; 61};
60 62
61/** 63/**
62 * A OSQLTable consists of OSQLTableItems 64 * A OSQLTable consists of OSQLTableItems
63 */ 65 */
64class OSQLTable { 66class OSQLTable {
65public: 67public:
66 typedef QValueList<OSQLTable> ValueList; 68 typedef QValueList<OSQLTable> ValueList;
67 69
68 /** 70 /**
69 * @param tableName the Name of the Table 71 * @param tableName the Name of the Table
70 */ 72 */
71 OSQLTable(const QString& tableName); 73 OSQLTable(const QString& tableName);
72 74
73 /** 75 /**
74 * d'tor 76 * d'tor
75 */ 77 */
76 ~OSQLTable(); 78 ~OSQLTable();
77 79
78 /** 80 /**
79 * setColumns sets the Columns of the Table 81 * setColumns sets the Columns of the Table
80 */ 82 */
81 void setColumns( const OSQLTableItem::ValueList& ); 83 void setColumns( const OSQLTableItem::ValueList& );
82 84
83 /** 85 /**
84 * returns all columns of the table 86 * returns all columns of the table
85 */ 87 */
86 OSQLTableItem::ValueList columns() const; 88 OSQLTableItem::ValueList columns() const;
87 89
88 QString tableName()const; 90 QString tableName()const;
89 91
90private: 92private:
91 QString m_table; 93 QString m_table;
92 OSQLTableItem::ValueList m_list; 94 OSQLTableItem::ValueList m_list;
95 class Private;
96 Private *d;
93}; 97};
94 98
99}
100}
101
95#endif 102#endif
diff --git a/libopie2/opiemm/opiemm.pro b/libopie2/opiemm/opiemm.pro
index d6f54ee..ce30dfb 100644
--- a/libopie2/opiemm/opiemm.pro
+++ b/libopie2/opiemm/opiemm.pro
@@ -1,18 +1,18 @@
1TEMPLATE = lib 1TEMPLATE = lib
2CONFIG += qt warn_on debug 2CONFIG += qt warn_on debug
3DESTDIR = $(OPIEDIR)/lib 3DESTDIR = $(OPIEDIR)/lib
4HEADERS = osoundsystem.h 4HEADERS = osoundsystem.h
5SOURCES = osoundsystem.cpp 5SOURCES = osoundsystem.cpp
6INTERFACES = 6INTERFACES =
7TARGET = opiemm2 7TARGET = opiemm2
8VERSION = 1.8.2 8VERSION = 1.9.0
9INCLUDEPATH += $(OPIEDIR)/include 9INCLUDEPATH += $(OPIEDIR)/include
10DEPENDPATH += $(OPIEDIR)/include 10DEPENDPATH += $(OPIEDIR)/include
11 11
12!contains( platform, x11 ) { 12!contains( platform, x11 ) {
13 include ( $(OPIEDIR)/include.pro ) 13 include ( $(OPIEDIR)/include.pro )
14} 14}
15 15
16contains( platform, x11 ) { 16contains( platform, x11 ) {
17 LIBS = -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib 17 LIBS = -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib
18} 18}
diff --git a/libopie2/opiemm/osoundsystem.cpp b/libopie2/opiemm/osoundsystem.cpp
index 51e088c..07f26c0 100644
--- a/libopie2/opiemm/osoundsystem.cpp
+++ b/libopie2/opiemm/osoundsystem.cpp
@@ -1,91 +1,93 @@
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 =. 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/osoundsystem.h> 32#include <opie2/osoundsystem.h>
33#include <opie2/odebug.h> 33#include <opie2/odebug.h>
34 34
35#include <errno.h> 35#include <errno.h>
36#include <fcntl.h> 36#include <fcntl.h>
37#include <string.h> 37#include <string.h>
38#include <sys/ioctl.h> 38#include <sys/ioctl.h>
39#include <sys/types.h> 39#include <sys/types.h>
40#include <sys/soundcard.h> 40#include <sys/soundcard.h>
41#include <sys/stat.h> 41#include <sys/stat.h>
42 42
43 43
44using namespace Opie::Core;
45using namespace Opie::MM;
44/*====================================================================================== 46/*======================================================================================
45 * OSoundSystem 47 * OSoundSystem
46 *======================================================================================*/ 48 *======================================================================================*/
47 49
48OSoundSystem* OSoundSystem::_instance = 0; 50OSoundSystem* OSoundSystem::_instance = 0;
49 51
50OSoundSystem::OSoundSystem() 52OSoundSystem::OSoundSystem()
51{ 53{
52 odebug << "OSoundSystem::OSoundSystem()" << oendl; 54 odebug << "OSoundSystem::OSoundSystem()" << oendl;
53 synchronize(); 55 synchronize();
54} 56}
55 57
56void OSoundSystem::synchronize() 58void OSoundSystem::synchronize()
57{ 59{
58 // gather available interfaces by inspecting /dev 60 // gather available interfaces by inspecting /dev
59 //FIXME: we could use SIOCGIFCONF here, but we aren't interested in virtual (e.g. eth0:0) devices 61 //FIXME: we could use SIOCGIFCONF here, but we aren't interested in virtual (e.g. eth0:0) devices
60 //FIXME: Use SIOCGIFCONF anway, because we can disable listing of aliased devices 62 //FIXME: Use SIOCGIFCONF anway, because we can disable listing of aliased devices
61 63
62 _interfaces.clear(); 64 _interfaces.clear();
63 _interfaces.insert( "soundcard", new OSoundCard( this, "soundcard" ) ); 65 _interfaces.insert( "soundcard", new OSoundCard( this, "soundcard" ) );
64 66
65 67
66 /* 68 /*
67 69
68 QString str; 70 QString str;
69 QFile f( "/dev/sound" ); 71 QFile f( "/dev/sound" );
70 bool hasFile = f.open( IO_ReadOnly ); 72 bool hasFile = f.open( IO_ReadOnly );
71 if ( !hasFile ) 73 if ( !hasFile )
72 { 74 {
73 odebug << "OSoundSystem: /dev/sound not existing. No sound devices available" << oendl; 75 odebug << "OSoundSystem: /dev/sound not existing. No sound devices available" << oendl;
74 return; 76 return;
75 } 77 }
76 QTextStream s( &f ); 78 QTextStream s( &f );
77 s.readLine(); 79 s.readLine();
78 s.readLine(); 80 s.readLine();
79 while ( !s.atEnd() ) 81 while ( !s.atEnd() )
80 { 82 {
81 s >> str; 83 s >> str;
82 str.truncate( str.find( ':' ) ); 84 str.truncate( str.find( ':' ) );
83 qDebug( "OSoundSystem: found interface '%s'", (const char*) str ); 85 qDebug( "OSoundSystem: found interface '%s'", (const char*) str );
84 OAudioInterface* iface; 86 OAudioInterface* iface;
85 iface = new OAudioInterface( this, (const char*) str ); 87 iface = new OAudioInterface( this, (const char*) str );
86 88
87 _interfaces.insert( str, iface ); 89 _interfaces.insert( str, iface );
88 s.readLine(); 90 s.readLine();
89 } 91 }
90*/ 92*/
91} 93}
diff --git a/libopie2/opiemm/osoundsystem.h b/libopie2/opiemm/osoundsystem.h
index 096d397..3c3b622 100644
--- a/libopie2/opiemm/osoundsystem.h
+++ b/libopie2/opiemm/osoundsystem.h
@@ -1,216 +1,233 @@
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 =. 5 =.
6 .=l. 6 .=l.
7           .>+-= 7           .>+-=
8 _;:,     .>    :=|. This program is free software; you can 8 _;:,     .>    :=|. This program is free software; you can
9.> <`_,   >  .   <= redistribute it and/or modify it under 9.> <`_,   >  .   <= redistribute it and/or modify it under
10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
11.="- .-=="i,     .._ License as published by the Free Software 11.="- .-=="i,     .._ License as published by the Free Software
12 - .   .-<_>     .<> Foundation; either version 2 of the License, 12 - .   .-<_>     .<> Foundation; either version 2 of the License,
13     ._= =}       : or (at your option) any later version. 13     ._= =}       : or (at your option) any later version.
14    .%`+i>       _;_. 14    .%`+i>       _;_.
15    .i_,=:_.      -<s. This program is distributed in the hope that 15    .i_,=:_.      -<s. This program is distributed in the hope that
16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
17    : ..    .:,     . . . without even the implied warranty of 17    : ..    .:,     . . . without even the implied warranty of
18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.=       =       ; Library General Public License for more 20..}^=.=       =       ; Library General Public License for more
21++=   -.     .`     .: details. 21++=   -.     .`     .: details.
22 :     =  ...= . :.=- 22 :     =  ...= . :.=-
23 -.   .:....=;==+<; You should have received a copy of the GNU 23 -.   .:....=;==+<; You should have received a copy of the GNU
24  -_. . .   )=.  = Library General Public License along with 24  -_. . .   )=.  = Library General Public License along with
25    --        :-=` this library; see the file COPYING.LIB. 25    --        :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation, 26 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330, 27 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA. 28 Boston, MA 02111-1307, USA.
29 29
30*/ 30*/
31 31
32#ifndef OSOUNDSYSTEM_H 32#ifndef OSOUNDSYSTEM_H
33#define OSOUNDSYSTEM_H 33#define OSOUNDSYSTEM_H
34 34
35#include <qobject.h> 35#include <qobject.h>
36#include <qdict.h> 36#include <qdict.h>
37#include <qmap.h> 37#include <qmap.h>
38 38
39namespace Opie {
40namespace MM {
41
39class OAudioInterface; 42class OAudioInterface;
40class OMixerInterface; 43class OMixerInterface;
41class OSoundCard; 44class OSoundCard;
42 45
43/*====================================================================================== 46/*======================================================================================
44 * OSoundSystem 47 * OSoundSystem
45 *======================================================================================*/ 48 *======================================================================================*/
46 49
47/** 50/**
48 * @brief A container class for all audio interfaces 51 * @brief A container class for all audio interfaces
49 * 52 *
50 * This class provides access to all available audio/midi/sequencer interfaces of your computer. 53 * This class provides access to all available audio/midi/sequencer interfaces of your computer.
51 * 54 *
52 * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> 55 * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
53 */ 56 */
54class OSoundSystem : public QObject 57class OSoundSystem : public QObject
55{ 58{
56 Q_OBJECT 59 Q_OBJECT
57 60
58 public: 61 public:
59 typedef QDict<OSoundCard> CardMap; 62 typedef QDict<OSoundCard> CardMap;
60 typedef QDictIterator<OSoundCard> CardIterator; 63 typedef QDictIterator<OSoundCard> CardIterator;
61 64
62 public: 65 public:
63 /** 66 /**
64 * @returns the number of available interfaces 67 * @returns the number of available interfaces
65 */ 68 */
66 int count() const; 69 int count() const;
67 /** 70 /**
68 * @returns a pointer to the (one and only) @ref ONetwork instance. 71 * @returns a pointer to the (one and only) @ref ONetwork instance.
69 */ 72 */
70 static OSoundSystem* instance(); 73 static OSoundSystem* instance();
71 /** 74 /**
72 * @returns an iterator usable for iterating through all network interfaces. 75 * @returns an iterator usable for iterating through all network interfaces.
73 */ 76 */
74 CardIterator iterator() const; 77 CardIterator iterator() const;
75 /** 78 /**
76 * @returns a pointer to the @ref OAudioInterface object for the specified @a interface or 0, if not found 79 * @returns a pointer to the @ref OAudioInterface object for the specified @a interface or 0, if not found
77 * @see OAudioInterface 80 * @see OAudioInterface
78 */ 81 */
79 OSoundCard* card( const QString& interface ) const; 82 OSoundCard* card( const QString& interface ) const;
80 /** 83 /**
81 * @internal Rebuild the internal interface database 84 * @internal Rebuild the internal interface database
82 * @note Sometimes it might be useful to call this from client code, 85 * @note Sometimes it might be useful to call this from client code,
83 * e.g. after issuing a cardctl insert 86 * e.g. after issuing a cardctl insert
84 */ 87 */
85 void synchronize(); 88 void synchronize();
86 89
87 protected: 90 protected:
88 OSoundSystem(); 91 OSoundSystem();
89 92
90 private: 93 private:
91 static OSoundSystem* _instance; 94 static OSoundSystem* _instance;
92 CardMap _interfaces; 95 CardMap _interfaces;
96 class Private;
97 Private *d;
93}; 98};
94 99
95 100
96/*====================================================================================== 101/*======================================================================================
97 * OSoundCard 102 * OSoundCard
98 *======================================================================================*/ 103 *======================================================================================*/
99 104
100class OSoundCard : public QObject 105class OSoundCard : public QObject
101{ 106{
102 Q_OBJECT 107 Q_OBJECT
103 108
104 public: 109 public:
105 /** 110 /**
106 * Constructor. Normally you don't create @ref OSoundCard objects yourself, 111 * Constructor. Normally you don't create @ref OSoundCard objects yourself,
107 * but access them via @ref OSoundSystem::card(). 112 * but access them via @ref OSoundSystem::card().
108 */ 113 */
109 OSoundCard( QObject* parent, const char* name ); 114 OSoundCard( QObject* parent, const char* name );
110 /** 115 /**
111 * Destructor. 116 * Destructor.
112 */ 117 */
113 virtual ~OSoundCard(); 118 virtual ~OSoundCard();
114 119
115 bool hasMixer() const { return _audio; }; 120 bool hasMixer() const { return _audio; };
116 bool hasAudio() const { return _mixer; }; 121 bool hasAudio() const { return _mixer; };
117 122
118 OAudioInterface* audio() const { return _audio; }; 123 OAudioInterface* audio() const { return _audio; };
119 OMixerInterface* mixer() const { return _mixer; }; 124 OMixerInterface* mixer() const { return _mixer; };
120 125
121 protected: 126 protected:
122 OAudioInterface* _audio; 127 OAudioInterface* _audio;
123 OMixerInterface* _mixer; 128 OMixerInterface* _mixer;
124 129
125 private: 130 private:
126 void init(); 131 void init();
132 private:
133 class Private;
134 Private *d;
127}; 135};
128 136
129/*====================================================================================== 137/*======================================================================================
130 * OAudioInterface 138 * OAudioInterface
131 *======================================================================================*/ 139 *======================================================================================*/
132 140
133class OAudioInterface : public QObject 141class OAudioInterface : public QObject
134{ 142{
135 Q_OBJECT 143 Q_OBJECT
136 144
137 public: 145 public:
138 /** 146 /**
139 * Constructor. Normally you don't create @ref OAudioInterface objects yourself, 147 * Constructor. Normally you don't create @ref OAudioInterface objects yourself,
140 * but access them via the @ref OSoundCard interface. 148 * but access them via the @ref OSoundCard interface.
141 */ 149 */
142 OAudioInterface( QObject* parent, const char* name ); 150 OAudioInterface( QObject* parent, const char* name );
143 /** 151 /**
144 * Destructor. 152 * Destructor.
145 */ 153 */
146 virtual ~OAudioInterface(); 154 virtual ~OAudioInterface();
147 155
148 protected: 156 protected:
149 const int _sfd; 157 const int _sfd;
150 158
151 private: 159 private:
152 void init(); 160 void init();
161 private:
162 class Private;
163 Private *d;
153}; 164};
154 165
155 166
156/*====================================================================================== 167/*======================================================================================
157 * OMixerInterface 168 * OMixerInterface
158 *======================================================================================*/ 169 *======================================================================================*/
159 170
160class OMixerInterface : public QObject 171class OMixerInterface : public QObject
161{ 172{
162 Q_OBJECT 173 Q_OBJECT
163 174
164 public: 175 public:
165 176
166 typedef QMap<QString,int>::ConstIterator ChannelIterator; 177 typedef QMap<QString,int>::ConstIterator ChannelIterator;
167 178
168 /** 179 /**
169 * Constructor. Normally you don't create @ref OMixerInterface objects yourself, 180 * Constructor. Normally you don't create @ref OMixerInterface objects yourself,
170 * but access them via the @ref OSoundCard interface. 181 * but access them via the @ref OSoundCard interface.
171 */ 182 */
172 OMixerInterface( QObject* parent, const char* name ); 183 OMixerInterface( QObject* parent, const char* name );
173 /** 184 /**
174 * Destructor. 185 * Destructor.
175 */ 186 */
176 virtual ~OMixerInterface(); 187 virtual ~OMixerInterface();
177 188
178 /** 189 /**
179 * @returns all available channels. 190 * @returns all available channels.
180 */ 191 */
181 QStringList allChannels() const; 192 QStringList allChannels() const;
182 /** 193 /**
183 * @returns recordable channels. 194 * @returns recordable channels.
184 */ 195 */
185 QStringList recChannels() const; 196 QStringList recChannels() const;
186 /** 197 /**
187 * @returns playable channels. 198 * @returns playable channels.
188 */ 199 */
189 QStringList playChannels() const; 200 QStringList playChannels() const;
190 201
191 /** 202 /**
192 * @returns true, if @a channel exists. 203 * @returns true, if @a channel exists.
193 */ 204 */
194 bool hasChannel( const QString& channel ); 205 bool hasChannel( const QString& channel );
195 206
196 /** 207 /**
197 * Set the @a left and @a right volumes for @a channel. 208 * Set the @a left and @a right volumes for @a channel.
198 * If no value for right is given, the value for left is taken for that. 209 * If no value for right is given, the value for left is taken for that.
199 */ 210 */
200 void setVolume( const QString& channel, int left, int right = -1 ); 211 void setVolume( const QString& channel, int left, int right = -1 );
201 /** 212 /**
202 * @returns the volume of @a channel or -1, if the channel doesn't exist. 213 * @returns the volume of @a channel or -1, if the channel doesn't exist.
203 * @note You might want to use @ref hasChannel() to check if a channel exists. 214 * @note You might want to use @ref hasChannel() to check if a channel exists.
204 */ 215 */
205 int volume( const QString& channel ) const; 216 int volume( const QString& channel ) const;
206 217
207 protected: 218 protected:
208 int _fd; 219 int _fd;
209 QMap<QString, int> _channels; 220 QMap<QString, int> _channels;
210 221
211 private: 222 private:
212 void init(); 223 void init();
224 private:
225 class Private;
226 Private *d;
213}; 227};
214 228
229}
230}
231
215#endif // OSOUNDSYSTEM_H 232#endif // OSOUNDSYSTEM_H
216 233
diff --git a/libopie2/opienet/802_11_user.h b/libopie2/opienet/802_11_user.h
index 7ae27c5..1a9a7a0 100644
--- a/libopie2/opienet/802_11_user.h
+++ b/libopie2/opienet/802_11_user.h
@@ -410,49 +410,50 @@ struct ctrl_cts_t {
410 u_int8_tfcs[4]; 410 u_int8_tfcs[4];
411}; 411};
412 412
413 #define CTRL_CTS_LEN(2+2+6+4) 413 #define CTRL_CTS_LEN(2+2+6+4)
414 414
415struct ctrl_ack_t { 415struct ctrl_ack_t {
416 u_int16_tfc; 416 u_int16_tfc;
417 u_int16_tduration; 417 u_int16_tduration;
418 u_int8_tra[6]; 418 u_int8_tra[6];
419 u_int8_tfcs[4]; 419 u_int8_tfcs[4];
420}; 420};
421 421
422 #define CTRL_ACK_LEN(2+2+6+4) 422 #define CTRL_ACK_LEN(2+2+6+4)
423 423
424struct ctrl_ps_poll_t { 424struct ctrl_ps_poll_t {
425 u_int16_tfc; 425 u_int16_tfc;
426 u_int16_taid; 426 u_int16_taid;
427 u_int8_tbssid[6]; 427 u_int8_tbssid[6];
428 u_int8_tta[6]; 428 u_int8_tta[6];
429 u_int8_tfcs[4]; 429 u_int8_tfcs[4];
430}; 430};
431 431
432 #define CTRL_PS_POLL_LEN(2+2+6+6+4) 432 #define CTRL_PS_POLL_LEN(2+2+6+6+4)
433 433
434struct ctrl_end_t { 434struct ctrl_end_t {
435 u_int16_tfc; 435 u_int16_tfc;
436 u_int16_tduration; 436 u_int16_tduration;
437 u_int8_tra[6]; 437 u_int8_tra[6];
438 u_int8_tbssid[6]; 438 u_int8_tbssid[6];
439 u_int8_tfcs[4]; 439 u_int8_tfcs[4];
440}; 440};
441 441
442 #define CTRL_END_LEN(2+2+6+6+4) 442 #define CTRL_END_LEN(2+2+6+6+4)
443 443
444struct ctrl_end_ack_t { 444struct ctrl_end_ack_t {
445 u_int16_tfc; 445 u_int16_tfc;
446 u_int16_tduration; 446 u_int16_tduration;
447 u_int8_tra[6]; 447 u_int8_tra[6];
448 u_int8_tbssid[6]; 448 u_int8_tbssid[6];
449 u_int8_tfcs[4]; 449 u_int8_tfcs[4];
450}; 450};
451 451
452 #define CTRL_END_ACK_LEN(2+2+6+6+4) 452 #define CTRL_END_ACK_LEN(2+2+6+6+4)
453 453
454 #define IV_IV(iv)((iv) & 0xFFFFFF) 454 #define IV_IV(iv)((iv) & 0xFFFFFF)
455 #define IV_PAD(iv)(((iv) >> 24) & 0x3F) 455 #define IV_PAD(iv)(((iv) >> 24) & 0x3F)
456 #define IV_KEYID(iv)(((iv) >> 30) & 0x03) 456 #define IV_KEYID(iv)(((iv) >> 30) & 0x03)
457 457
458
458#endif 459#endif
diff --git a/libopie2/opienet/dhcp.h b/libopie2/opienet/dhcp.h
index 368e375..6ba4c53 100644
--- a/libopie2/opienet/dhcp.h
+++ b/libopie2/opienet/dhcp.h
@@ -1,92 +1,93 @@
1/* dhcp.h 1/* dhcp.h
2 2
3 Protocol structures... */ 3 Protocol structures... */
4 4
5/* 5/*
6 * Copyright (c) 1995-2001 The Internet Software Consortium. 6 * Copyright (c) 1995-2001 The Internet Software Consortium.
7 * All rights reserved. 7 * All rights reserved.
8 * 8 *
9 * Redistribution and use in source and binary forms, with or without 9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions 10 * modification, are permitted provided that the following conditions
11 * are met: 11 * are met:
12 * 12 *
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright 15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the 16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution. 17 * documentation and/or other materials provided with the distribution.
18 * 3. Neither the name of The Internet Software Consortium nor the names 18 * 3. Neither the name of The Internet Software Consortium nor the names
19 * of its contributors may be used to endorse or promote products derived 19 * of its contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission. 20 * from this software without specific prior written permission.
21 * 21 *
22 * THIS SOFTWARE IS PROVIDED BY THE INTERNET SOFTWARE CONSORTIUM AND 22 * THIS SOFTWARE IS PROVIDED BY THE INTERNET SOFTWARE CONSORTIUM AND
23 * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, 23 * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
24 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 24 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
25 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 25 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26 * DISCLAIMED. IN NO EVENT SHALL THE INTERNET SOFTWARE CONSORTIUM OR 26 * DISCLAIMED. IN NO EVENT SHALL THE INTERNET SOFTWARE CONSORTIUM OR
27 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 27 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 28 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 29 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
30 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 30 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 31 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
33 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE. 34 * SUCH DAMAGE.
35 * 35 *
36 * This software has been written for the Internet Software Consortium 36 * This software has been written for the Internet Software Consortium
37 * by Ted Lemon in cooperation with Vixie Enterprises. To learn more 37 * by Ted Lemon in cooperation with Vixie Enterprises. To learn more
38 * about the Internet Software Consortium, see ``http://www.isc.org''. 38 * about the Internet Software Consortium, see ``http://www.isc.org''.
39 * To learn more about Vixie Enterprises, see ``http://www.vix.com''. 39 * To learn more about Vixie Enterprises, see ``http://www.vix.com''.
40 */ 40 */
41 41
42#ifndef DHCP_H 42#ifndef DHCP_H
43#define DHCP_H 43#define DHCP_H
44 44
45
45 #define DHCP_UDP_OVERHEAD (14 + /* Ethernet header */ \ 46 #define DHCP_UDP_OVERHEAD (14 + /* Ethernet header */ \
46 20 + /* IP header */ \ 47 20 + /* IP header */ \
47 8) /* UDP header */ 48 8) /* UDP header */
48 #define DHCP_SNAME_LEN 64 49 #define DHCP_SNAME_LEN 64
49 #define DHCP_FILE_LEN 128 50 #define DHCP_FILE_LEN 128
50 #define DHCP_FIXED_NON_UDP236 51 #define DHCP_FIXED_NON_UDP236
51 #define DHCP_FIXED_LEN (DHCP_FIXED_NON_UDP + DHCP_UDP_OVERHEAD) 52 #define DHCP_FIXED_LEN (DHCP_FIXED_NON_UDP + DHCP_UDP_OVERHEAD)
52 /* Everything but options. */ 53 /* Everything but options. */
53 #define DHCP_MTU_MAX 1500 54 #define DHCP_MTU_MAX 1500
54 #define DHCP_OPTION_LEN (DHCP_MTU_MAX - DHCP_FIXED_LEN) 55 #define DHCP_OPTION_LEN (DHCP_MTU_MAX - DHCP_FIXED_LEN)
55 56
56 #define BOOTP_MIN_LEN 300 57 #define BOOTP_MIN_LEN 300
57#define DHCP_MIN_LEN 548 58#define DHCP_MIN_LEN 548
58 59
59struct dhcp_packet { 60struct dhcp_packet {
60 u_int8_t op; /* 0: Message opcode/type */ 61 u_int8_t op; /* 0: Message opcode/type */
61 u_int8_t htype;/* 1: Hardware addr type (net/if_types.h) */ 62 u_int8_t htype;/* 1: Hardware addr type (net/if_types.h) */
62 u_int8_t hlen; /* 2: Hardware addr length */ 63 u_int8_t hlen; /* 2: Hardware addr length */
63 u_int8_t hops; /* 3: Number of relay agent hops from client */ 64 u_int8_t hops; /* 3: Number of relay agent hops from client */
64 u_int32_t xid; /* 4: Transaction ID */ 65 u_int32_t xid; /* 4: Transaction ID */
65 u_int16_t secs; /* 8: Seconds since client started looking */ 66 u_int16_t secs; /* 8: Seconds since client started looking */
66 u_int16_t flags;/* 10: Flag bits */ 67 u_int16_t flags;/* 10: Flag bits */
67 struct in_addr ciaddr;/* 12: Client IP address (if already in use) */ 68 struct in_addr ciaddr;/* 12: Client IP address (if already in use) */
68 struct in_addr yiaddr;/* 16: Client IP address */ 69 struct in_addr yiaddr;/* 16: Client IP address */
69 struct in_addr siaddr;/* 18: IP address of next server to talk to */ 70 struct in_addr siaddr;/* 18: IP address of next server to talk to */
70 struct in_addr giaddr;/* 20: DHCP relay agent IP address */ 71 struct in_addr giaddr;/* 20: DHCP relay agent IP address */
71 unsigned char chaddr [16];/* 24: Client hardware address */ 72 unsigned char chaddr [16];/* 24: Client hardware address */
72 char sname [DHCP_SNAME_LEN];/* 40: Server name */ 73 char sname [DHCP_SNAME_LEN];/* 40: Server name */
73 char file [DHCP_FILE_LEN];/* 104: Boot filename */ 74 char file [DHCP_FILE_LEN];/* 104: Boot filename */
74 unsigned char options [DHCP_OPTION_LEN]; 75 unsigned char options [DHCP_OPTION_LEN];
75 /* 212: Optional parameters 76 /* 212: Optional parameters
76 (actual length dependent on MTU). */ 77 (actual length dependent on MTU). */
77}; 78};
78 79
79/* BOOTP (rfc951) message types */ 80/* BOOTP (rfc951) message types */
80 #define BOOTREQUEST1 81 #define BOOTREQUEST1
81 #define BOOTREPLY2 82 #define BOOTREPLY2
82 83
83/* Possible values for flags field... */ 84/* Possible values for flags field... */
84#define BOOTP_BROADCAST 32768L 85#define BOOTP_BROADCAST 32768L
85 86
86/* Possible values for hardware type (htype) field... */ 87/* Possible values for hardware type (htype) field... */
87 #define HTYPE_ETHER1 /* Ethernet 10Mbps */ 88 #define HTYPE_ETHER1 /* Ethernet 10Mbps */
88 #define HTYPE_IEEE802 6 /* IEEE 802.2 Token Ring...*/ 89 #define HTYPE_IEEE802 6 /* IEEE 802.2 Token Ring...*/
89 #define HTYPE_FDDI 8 /* FDDI... */ 90 #define HTYPE_FDDI 8 /* FDDI... */
90 91
91/* Magic cookie validating dhcp options field (and bootp vendor 92/* Magic cookie validating dhcp options field (and bootp vendor
92 extensions field). */ 93 extensions field). */
@@ -152,50 +153,51 @@ struct dhcp_packet {
152 #define DHO_DHCP_PARAMETER_REQUEST_LIST55 153 #define DHO_DHCP_PARAMETER_REQUEST_LIST55
153 #define DHO_DHCP_MESSAGE 56 154 #define DHO_DHCP_MESSAGE 56
154 #define DHO_DHCP_MAX_MESSAGE_SIZE57 155 #define DHO_DHCP_MAX_MESSAGE_SIZE57
155 #define DHO_DHCP_RENEWAL_TIME 58 156 #define DHO_DHCP_RENEWAL_TIME 58
156 #define DHO_DHCP_REBINDING_TIME 59 157 #define DHO_DHCP_REBINDING_TIME 59
157 #define DHO_VENDOR_CLASS_IDENTIFIER60 158 #define DHO_VENDOR_CLASS_IDENTIFIER60
158 #define DHO_DHCP_CLIENT_IDENTIFIER61 159 #define DHO_DHCP_CLIENT_IDENTIFIER61
159 #define DHO_NWIP_DOMAIN_NAME 62 160 #define DHO_NWIP_DOMAIN_NAME 62
160 #define DHO_NWIP_SUBOPTIONS 63 161 #define DHO_NWIP_SUBOPTIONS 63
161 #define DHO_USER_CLASS 77 162 #define DHO_USER_CLASS 77
162 #define DHO_FQDN 81 163 #define DHO_FQDN 81
163 #define DHO_DHCP_AGENT_OPTIONS 82 164 #define DHO_DHCP_AGENT_OPTIONS 82
164 #define DHO_SUBNET_SELECTION 118 /* RFC3011! */ 165 #define DHO_SUBNET_SELECTION 118 /* RFC3011! */
165/* The DHO_AUTHENTICATE option is not a standard yet, so I've 166/* The DHO_AUTHENTICATE option is not a standard yet, so I've
166 allocated an option out of the "local" option space for it on a 167 allocated an option out of the "local" option space for it on a
167 temporary basis. Once an option code number is assigned, I will 168 temporary basis. Once an option code number is assigned, I will
168 immediately and shamelessly break this, so don't count on it 169 immediately and shamelessly break this, so don't count on it
169 continuing to work. */ 170 continuing to work. */
170 #define DHO_AUTHENTICATE 210 171 #define DHO_AUTHENTICATE 210
171 172
172 #define DHO_END 255 173 #define DHO_END 255
173 174
174/* DHCP message types. */ 175/* DHCP message types. */
175 #define DHCPDISCOVER1 176 #define DHCPDISCOVER1
176 #define DHCPOFFER2 177 #define DHCPOFFER2
177 #define DHCPREQUEST3 178 #define DHCPREQUEST3
178 #define DHCPDECLINE4 179 #define DHCPDECLINE4
179 #define DHCPACK 5 180 #define DHCPACK 5
180 #define DHCPNAK 6 181 #define DHCPNAK 6
181 #define DHCPRELEASE7 182 #define DHCPRELEASE7
182 #define DHCPINFORM8 183 #define DHCPINFORM8
183 184
184/* Relay Agent Information option subtypes: */ 185/* Relay Agent Information option subtypes: */
185 #define RAI_CIRCUIT_ID1 186 #define RAI_CIRCUIT_ID1
186 #define RAI_REMOTE_ID2 187 #define RAI_REMOTE_ID2
187 #define RAI_AGENT_ID3 188 #define RAI_AGENT_ID3
188 189
189/* FQDN suboptions: */ 190/* FQDN suboptions: */
190 #define FQDN_NO_CLIENT_UPDATE 1 191 #define FQDN_NO_CLIENT_UPDATE 1
191 #define FQDN_SERVER_UPDATE 2 192 #define FQDN_SERVER_UPDATE 2
192 #define FQDN_ENCODED 3 193 #define FQDN_ENCODED 3
193 #define FQDN_RCODE1 4 194 #define FQDN_RCODE1 4
194 #define FQDN_RCODE2 5 195 #define FQDN_RCODE2 5
195 #define FQDN_HOSTNAME 6 196 #define FQDN_HOSTNAME 6
196 #define FQDN_DOMAINNAME 7 197 #define FQDN_DOMAINNAME 7
197 #define FQDN_FQDN 8 198 #define FQDN_FQDN 8
198 #define FQDN_SUBOPTION_COUNT 8 199 #define FQDN_SUBOPTION_COUNT 8
199 200
201
200#endif 202#endif
201 203
diff --git a/libopie2/opienet/odebugmapper.cpp b/libopie2/opienet/odebugmapper.cpp
index 7e4ab2b..f679afb 100644
--- a/libopie2/opienet/odebugmapper.cpp
+++ b/libopie2/opienet/odebugmapper.cpp
@@ -1,57 +1,63 @@
1 1
2/* 2/*
3 * debug value mapper - generated by regen.py - (C) Michael 'Mickey' Lauer <mickey@vanille.de> 3 * debug value mapper - generated by regen.py - (C) Michael 'Mickey' Lauer <mickey@vanille.de>
4 */ 4 */
5 5
6#include <opie2/odebug.h> 6#include <opie2/odebug.h>
7 7
8#include "odebugmapper.h" 8#include "odebugmapper.h"
9 9
10using namespace Opie::Core;
11
12namespace Opie {
13namespace Net {
14namespace Private {
15
10DebugMapper::DebugMapper() 16DebugMapper::DebugMapper()
11{ 17{
12 odebug << "DebugMapper::DebugMapper()" << oendl; 18 odebug << "DebugMapper::DebugMapper()" << oendl;
13 19
14 20
15 _map.insert( 0x8902, new QString("SIOCSPGRP") ); 21 _map.insert( 0x8902, new QString("SIOCSPGRP") );
16 _map.insert( 0x8904, new QString("SIOCGPGRP") ); 22 _map.insert( 0x8904, new QString("SIOCGPGRP") );
17 _map.insert( 0x8905, new QString("SIOCATMARK") ); 23 _map.insert( 0x8905, new QString("SIOCATMARK") );
18 _map.insert( 0x8906, new QString("SIOCGSTAMP") ); 24 _map.insert( 0x8906, new QString("SIOCGSTAMP") );
19 _map.insert( 0x890B, new QString("SIOCADDRT") ); 25 _map.insert( 0x890B, new QString("SIOCADDRT") );
20 _map.insert( 0x890C, new QString("SIOCDELRT") ); 26 _map.insert( 0x890C, new QString("SIOCDELRT") );
21 _map.insert( 0x890D, new QString("SIOCRTMSG") ); 27 _map.insert( 0x890D, new QString("SIOCRTMSG") );
22 _map.insert( 0x8910, new QString("SIOCGIFNAME") ); 28 _map.insert( 0x8910, new QString("SIOCGIFNAME") );
23 _map.insert( 0x8911, new QString("SIOCSIFLINK") ); 29 _map.insert( 0x8911, new QString("SIOCSIFLINK") );
24 _map.insert( 0x8912, new QString("SIOCGIFCONF") ); 30 _map.insert( 0x8912, new QString("SIOCGIFCONF") );
25 _map.insert( 0x8913, new QString("SIOCGIFFLAGS") ); 31 _map.insert( 0x8913, new QString("SIOCGIFFLAGS") );
26 _map.insert( 0x8914, new QString("SIOCSIFFLAGS") ); 32 _map.insert( 0x8914, new QString("SIOCSIFFLAGS") );
27 _map.insert( 0x8915, new QString("SIOCGIFADDR") ); 33 _map.insert( 0x8915, new QString("SIOCGIFADDR") );
28 _map.insert( 0x8916, new QString("SIOCSIFADDR") ); 34 _map.insert( 0x8916, new QString("SIOCSIFADDR") );
29 _map.insert( 0x8917, new QString("SIOCGIFDSTADDR") ); 35 _map.insert( 0x8917, new QString("SIOCGIFDSTADDR") );
30 _map.insert( 0x8918, new QString("SIOCSIFDSTADDR") ); 36 _map.insert( 0x8918, new QString("SIOCSIFDSTADDR") );
31 _map.insert( 0x8919, new QString("SIOCGIFBRDADDR") ); 37 _map.insert( 0x8919, new QString("SIOCGIFBRDADDR") );
32 _map.insert( 0x891a, new QString("SIOCSIFBRDADDR") ); 38 _map.insert( 0x891a, new QString("SIOCSIFBRDADDR") );
33 _map.insert( 0x891b, new QString("SIOCGIFNETMASK") ); 39 _map.insert( 0x891b, new QString("SIOCGIFNETMASK") );
34 _map.insert( 0x891c, new QString("SIOCSIFNETMASK") ); 40 _map.insert( 0x891c, new QString("SIOCSIFNETMASK") );
35 _map.insert( 0x891d, new QString("SIOCGIFMETRIC") ); 41 _map.insert( 0x891d, new QString("SIOCGIFMETRIC") );
36 _map.insert( 0x891e, new QString("SIOCSIFMETRIC") ); 42 _map.insert( 0x891e, new QString("SIOCSIFMETRIC") );
37 _map.insert( 0x891f, new QString("SIOCGIFMEM") ); 43 _map.insert( 0x891f, new QString("SIOCGIFMEM") );
38 _map.insert( 0x8920, new QString("SIOCSIFMEM") ); 44 _map.insert( 0x8920, new QString("SIOCSIFMEM") );
39 _map.insert( 0x8921, new QString("SIOCGIFMTU") ); 45 _map.insert( 0x8921, new QString("SIOCGIFMTU") );
40 _map.insert( 0x8922, new QString("SIOCSIFMTU") ); 46 _map.insert( 0x8922, new QString("SIOCSIFMTU") );
41 _map.insert( 0x8923, new QString("SIOCSIFNAME") ); 47 _map.insert( 0x8923, new QString("SIOCSIFNAME") );
42 _map.insert( 0x8924, new QString("SIOCSIFHWADDR") ); 48 _map.insert( 0x8924, new QString("SIOCSIFHWADDR") );
43 _map.insert( 0x8925, new QString("SIOCGIFENCAP") ); 49 _map.insert( 0x8925, new QString("SIOCGIFENCAP") );
44 _map.insert( 0x8926, new QString("SIOCSIFENCAP") ); 50 _map.insert( 0x8926, new QString("SIOCSIFENCAP") );
45 _map.insert( 0x8927, new QString("SIOCGIFHWADDR") ); 51 _map.insert( 0x8927, new QString("SIOCGIFHWADDR") );
46 _map.insert( 0x8929, new QString("SIOCGIFSLAVE") ); 52 _map.insert( 0x8929, new QString("SIOCGIFSLAVE") );
47 _map.insert( 0x8930, new QString("SIOCSIFSLAVE") ); 53 _map.insert( 0x8930, new QString("SIOCSIFSLAVE") );
48 _map.insert( 0x8931, new QString("SIOCADDMULTI") ); 54 _map.insert( 0x8931, new QString("SIOCADDMULTI") );
49 _map.insert( 0x8932, new QString("SIOCDELMULTI") ); 55 _map.insert( 0x8932, new QString("SIOCDELMULTI") );
50 _map.insert( 0x8933, new QString("SIOCGIFINDEX") ); 56 _map.insert( 0x8933, new QString("SIOCGIFINDEX") );
51 _map.insert( 0x8934, new QString("SIOCSIFPFLAGS") ); 57 _map.insert( 0x8934, new QString("SIOCSIFPFLAGS") );
52 _map.insert( 0x8935, new QString("SIOCGIFPFLAGS") ); 58 _map.insert( 0x8935, new QString("SIOCGIFPFLAGS") );
53 _map.insert( 0x8936, new QString("SIOCDIFADDR") ); 59 _map.insert( 0x8936, new QString("SIOCDIFADDR") );
54 _map.insert( 0x8937, new QString("SIOCSIFHWBROADCAST") ); 60 _map.insert( 0x8937, new QString("SIOCSIFHWBROADCAST") );
55 _map.insert( 0x8938, new QString("SIOCGIFCOUNT") ); 61 _map.insert( 0x8938, new QString("SIOCGIFCOUNT") );
56 _map.insert( 0x8940, new QString("SIOCGIFBR") ); 62 _map.insert( 0x8940, new QString("SIOCGIFBR") );
57 _map.insert( 0x8941, new QString("SIOCSIFBR") ); 63 _map.insert( 0x8941, new QString("SIOCSIFBR") );
@@ -167,49 +173,51 @@ DebugMapper::DebugMapper()
167 _map.insert( 0x8948, new QString("SIOCGMIIREG") ); 173 _map.insert( 0x8948, new QString("SIOCGMIIREG") );
168 _map.insert( 0x8949, new QString("SIOCSMIIREG") ); 174 _map.insert( 0x8949, new QString("SIOCSMIIREG") );
169 _map.insert( 0x894A, new QString("SIOCWANDEV") ); 175 _map.insert( 0x894A, new QString("SIOCWANDEV") );
170 _map.insert( 0x8953, new QString("SIOCDARP") ); 176 _map.insert( 0x8953, new QString("SIOCDARP") );
171 _map.insert( 0x8954, new QString("SIOCGARP") ); 177 _map.insert( 0x8954, new QString("SIOCGARP") );
172 _map.insert( 0x8955, new QString("SIOCSARP") ); 178 _map.insert( 0x8955, new QString("SIOCSARP") );
173 _map.insert( 0x8960, new QString("SIOCDRARP") ); 179 _map.insert( 0x8960, new QString("SIOCDRARP") );
174 _map.insert( 0x8961, new QString("SIOCGRARP") ); 180 _map.insert( 0x8961, new QString("SIOCGRARP") );
175 _map.insert( 0x8962, new QString("SIOCSRARP") ); 181 _map.insert( 0x8962, new QString("SIOCSRARP") );
176 _map.insert( 0x8970, new QString("SIOCGIFMAP") ); 182 _map.insert( 0x8970, new QString("SIOCGIFMAP") );
177 _map.insert( 0x8971, new QString("SIOCSIFMAP") ); 183 _map.insert( 0x8971, new QString("SIOCSIFMAP") );
178 _map.insert( 0x8980, new QString("SIOCADDDLCI") ); 184 _map.insert( 0x8980, new QString("SIOCADDDLCI") );
179 _map.insert( 0x8981, new QString("SIOCDELDLCI") ); 185 _map.insert( 0x8981, new QString("SIOCDELDLCI") );
180 _map.insert( 0x8982, new QString("SIOCGIFVLAN") ); 186 _map.insert( 0x8982, new QString("SIOCGIFVLAN") );
181 _map.insert( 0x8983, new QString("SIOCSIFVLAN") ); 187 _map.insert( 0x8983, new QString("SIOCSIFVLAN") );
182 _map.insert( 0x8990, new QString("SIOCBONDENSLAVE") ); 188 _map.insert( 0x8990, new QString("SIOCBONDENSLAVE") );
183 _map.insert( 0x8991, new QString("SIOCBONDRELEASE") ); 189 _map.insert( 0x8991, new QString("SIOCBONDRELEASE") );
184 _map.insert( 0x8992, new QString("SIOCBONDSETHWADDR") ); 190 _map.insert( 0x8992, new QString("SIOCBONDSETHWADDR") );
185 _map.insert( 0x8993, new QString("SIOCBONDSLAVEINFOQUERY") ); 191 _map.insert( 0x8993, new QString("SIOCBONDSLAVEINFOQUERY") );
186 _map.insert( 0x8994, new QString("SIOCBONDINFOQUERY") ); 192 _map.insert( 0x8994, new QString("SIOCBONDINFOQUERY") );
187 _map.insert( 0x8995, new QString("SIOCBONDCHANGEACTIVE") ); 193 _map.insert( 0x8995, new QString("SIOCBONDCHANGEACTIVE") );
188 _map.insert( 0x89F0, new QString("SIOCDEVPRIVATE") ); 194 _map.insert( 0x89F0, new QString("SIOCDEVPRIVATE") );
189 _map.insert( 0x89E0, new QString("SIOCPROTOPRIVATE") ); 195 _map.insert( 0x89E0, new QString("SIOCPROTOPRIVATE") );
190 196
191}; 197};
192 198
193 199
194DebugMapper::~DebugMapper() 200DebugMapper::~DebugMapper()
195{ 201{
196 odebug << "DebugMapper::~DebugMapper()" << oendl; 202 odebug << "DebugMapper::~DebugMapper()" << oendl;
197} 203}
198 204
199 205
200const QString& DebugMapper::map( int value ) const 206const QString& DebugMapper::map( int value ) const
201{ 207{
202 QString* result = _map[ value ]; 208 QString* result = _map[ value ];
203 209
204 if ( !result ) 210 if ( !result )
205 { 211 {
206 owarn << "DebugMapper::map() - value " << value << " is not found." << oendl; 212 owarn << "DebugMapper::map() - value " << value << " is not found." << oendl;
207 return QString::null; 213 return QString::null;
208 } 214 }
209 else 215 else
210 { 216 {
211 return *result; 217 return *result;
212 } 218 }
213} 219}
214 220
215 221}
222}
223}
diff --git a/libopie2/opienet/odebugmapper.h b/libopie2/opienet/odebugmapper.h
index 66b331d..f47db47 100644
--- a/libopie2/opienet/odebugmapper.h
+++ b/libopie2/opienet/odebugmapper.h
@@ -1,26 +1,36 @@
1 1
2/* 2/*
3 * debug value mapper - generated by regen.py - (C) Michael 'Mickey' Lauer <mickey@vanille.de> 3 * debug value mapper - generated by regen.py - (C) Michael 'Mickey' Lauer <mickey@vanille.de>
4 */ 4 */
5 5
6#ifndef DEBUGMAPPER_H 6#ifndef DEBUGMAPPER_H
7#define DEBUGMAPPER_H 7#define DEBUGMAPPER_H
8 8
9#include <qstring.h> 9#include <qstring.h>
10#include <qintdict.h> 10#include <qintdict.h>
11 11
12namespace Opie {
13namespace Net {
14namespace Private {
15
12typedef QIntDict<QString> IntStringMap; 16typedef QIntDict<QString> IntStringMap;
13 17
14class DebugMapper 18class DebugMapper
15{ 19{
16 public: 20 public:
17 DebugMapper(); 21 DebugMapper();
18 ~DebugMapper(); 22 ~DebugMapper();
19 23
20 const QString& map( int value ) const; 24 const QString& map( int value ) const;
21 private: 25 private:
22 IntStringMap _map; 26 IntStringMap _map;
27 class Private;
28 Private *d;
23}; 29};
24 30
31}
32}
33}
34
25#endif 35#endif
26 36
diff --git a/libopie2/opienet/omanufacturerdb.cpp b/libopie2/opienet/omanufacturerdb.cpp
index b93b752..209ec94 100644
--- a/libopie2/opienet/omanufacturerdb.cpp
+++ b/libopie2/opienet/omanufacturerdb.cpp
@@ -1,135 +1,142 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3              (C) 2003 Michael 'Mickey' Lauer <mickey@Vanille.de> 3              (C) 2003 Michael 'Mickey' Lauer <mickey@Vanille.de>
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 30
31#include "omanufacturerdb.h" 31#include "omanufacturerdb.h"
32 32
33#define OPIE_IMPROVE_GUI_LATENCY 1 33#define OPIE_IMPROVE_GUI_LATENCY 1
34 34
35/* OPIE */ 35/* OPIE */
36#include <opie2/odebug.h> 36#include <opie2/odebug.h>
37#ifdef OPIE_IMPROVE_GUI_LATENCY 37#ifdef OPIE_IMPROVE_GUI_LATENCY
38#include <qpe/global.h> 38#include <qpe/global.h>
39#endif 39#endif
40 40
41/* QT */ 41/* QT */
42#include <qapplication.h> 42#include <qapplication.h>
43#include <qfile.h> 43#include <qfile.h>
44#include <qtextstream.h> 44#include <qtextstream.h>
45 45
46using namespace Opie::Core;
47namespace Opie {
48namespace Net {
49
46OManufacturerDB* OManufacturerDB::_instance = 0; 50OManufacturerDB* OManufacturerDB::_instance = 0;
47 51
48OManufacturerDB* OManufacturerDB::instance() 52OManufacturerDB* OManufacturerDB::instance()
49{ 53{
50 if ( !OManufacturerDB::_instance ) 54 if ( !OManufacturerDB::_instance )
51 { 55 {
52 odebug << "OManufacturerDB::instance(): creating OManufacturerDB..." << oendl; 56 odebug << "OManufacturerDB::instance(): creating OManufacturerDB..." << oendl;
53 _instance = new OManufacturerDB(); 57 _instance = new OManufacturerDB();
54 } 58 }
55 return _instance; 59 return _instance;
56} 60}
57 61
58 62
59OManufacturerDB::OManufacturerDB() 63OManufacturerDB::OManufacturerDB()
60{ 64{
61 #ifdef OPIE_IMPROVE_GUI_LATENCY 65 #ifdef OPIE_IMPROVE_GUI_LATENCY
62 Global::statusMessage( "Reading Manufacturers..." ); 66 Global::statusMessage( "Reading Manufacturers..." );
63 #endif 67 #endif
64 QString filename( "/etc/manufacturers" ); 68 QString filename( "/etc/manufacturers" );
65 odebug << "OManufacturerDB: trying to read " << filename << oendl; 69 odebug << "OManufacturerDB: trying to read " << filename << oendl;
66 if ( !QFile::exists( filename ) ) 70 if ( !QFile::exists( filename ) )
67 { 71 {
68 filename = "/opt/QtPalmtop/etc/manufacturers"; 72 filename = "/opt/QtPalmtop/etc/manufacturers";
69 odebug << "OManufacturerDB: trying to read " << filename << oendl; 73 odebug << "OManufacturerDB: trying to read " << filename << oendl;
70 if ( !QFile::exists( filename ) ) 74 if ( !QFile::exists( filename ) )
71 { 75 {
72 filename = "/usr/share/wellenreiter/manufacturers"; 76 filename = "/usr/share/wellenreiter/manufacturers";
73 odebug << "OManufacturerDB: trying to read " << filename << oendl; 77 odebug << "OManufacturerDB: trying to read " << filename << oendl;
74 } 78 }
75 } 79 }
76 80
77 QFile file( filename ); 81 QFile file( filename );
78 bool hasFile = file.open( IO_ReadOnly ); 82 bool hasFile = file.open( IO_ReadOnly );
79 if (!hasFile) 83 if (!hasFile)
80 { 84 {
81 owarn << "OManufacturerDB: no valid manufacturer list found." << oendl; 85 owarn << "OManufacturerDB: no valid manufacturer list found." << oendl;
82 } 86 }
83 else 87 else
84 { 88 {
85 odebug << "OManufacturerDB: found manufacturer list in " << filename << oendl; 89 odebug << "OManufacturerDB: found manufacturer list in " << filename << oendl;
86 QTextStream s( &file ); 90 QTextStream s( &file );
87 QString addr; 91 QString addr;
88 QString manu; 92 QString manu;
89 QString extManu; 93 QString extManu;
90 #ifdef OPIE_IMPROVE_GUI_LATENCY 94 #ifdef OPIE_IMPROVE_GUI_LATENCY
91 int counter = 0; 95 int counter = 0;
92 #endif 96 #endif
93 while (!s.atEnd()) 97 while (!s.atEnd())
94 { 98 {
95 s >> addr; 99 s >> addr;
96 s >> manu; 100 s >> manu;
97 s >> extManu; 101 s >> extManu;
98 102
99 manufacturers.insert( addr, manu ); 103 manufacturers.insert( addr, manu );
100 manufacturersExt.insert( addr, extManu ); 104 manufacturersExt.insert( addr, extManu );
101 // odebug << "OmanufacturerDB: parse '" << addr << "' as '" << manu << "' (" << extManu << ")" << oendl; 105 // odebug << "OmanufacturerDB: parse '" << addr << "' as '" << manu << "' (" << extManu << ")" << oendl;
102 #ifdef OPIE_IMPROVE_GUI_LATENCY 106 #ifdef OPIE_IMPROVE_GUI_LATENCY
103 counter++; 107 counter++;
104 if ( counter == 50 ) 108 if ( counter == 50 )
105 { 109 {
106 qApp->processEvents(); 110 qApp->processEvents();
107 counter = 0; 111 counter = 0;
108 } 112 }
109 #endif 113 #endif
110 } 114 }
111 odebug << "OManufacturerDB: manufacturer list completed." << oendl; 115 odebug << "OManufacturerDB: manufacturer list completed." << oendl;
112 #ifdef OPIE_IMPROVE_GUI_LATENCY 116 #ifdef OPIE_IMPROVE_GUI_LATENCY
113 Global::statusMessage( "Manufacturers Complete..." ); 117 Global::statusMessage( "Manufacturers Complete..." );
114 #endif 118 #endif
115 } 119 }
116} 120}
117 121
118 122
119OManufacturerDB::~OManufacturerDB() 123OManufacturerDB::~OManufacturerDB()
120{ 124{
121} 125}
122 126
123 127
124const QString& OManufacturerDB::lookup( const QString& macaddr ) const 128const QString& OManufacturerDB::lookup( const QString& macaddr ) const
125{ 129{
126 return manufacturers[macaddr.upper().left(8)]; 130 return manufacturers[macaddr.upper().left(8)];
127} 131}
128 132
129 133
130const QString& OManufacturerDB::lookupExt( const QString& macaddr ) const 134const QString& OManufacturerDB::lookupExt( const QString& macaddr ) const
131{ 135{
132 QMap<QString,QString>::ConstIterator it = manufacturersExt.find( macaddr.upper().left(8) ); 136 QMap<QString,QString>::ConstIterator it = manufacturersExt.find( macaddr.upper().left(8) );
133 return it == manufacturersExt.end() ? lookup( macaddr ) : *it; 137 return it == manufacturersExt.end() ? lookup( macaddr ) : *it;
134} 138}
135 139
140}
141}
142
diff --git a/libopie2/opienet/omanufacturerdb.h b/libopie2/opienet/omanufacturerdb.h
index c2712e5..5c1940e 100644
--- a/libopie2/opienet/omanufacturerdb.h
+++ b/libopie2/opienet/omanufacturerdb.h
@@ -1,69 +1,77 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3              (C) 2003 Michael 'Mickey' Lauer <mickey@Vanille.de> 3              (C) 2003 Michael 'Mickey' Lauer <mickey@Vanille.de>
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 30
31#ifndef OMANUFACTURERDB_H 31#ifndef OMANUFACTURERDB_H
32#define OMANUFACTURERDB_H 32#define OMANUFACTURERDB_H
33 33
34#include <qmap.h> 34#include <qmap.h>
35 35
36namespace Opie {
37namespace Net {
38
36/** 39/**
37 * @brief A Ethernet card vendor database. 40 * @brief A Ethernet card vendor database.
38 * 41 *
39 * This class encapsulates the lookup of Ethernet vendor given a 42 * This class encapsulates the lookup of Ethernet vendor given a
40 * certain Mac Address. Only the first three bytes define the vendor. 43 * certain Mac Address. Only the first three bytes define the vendor.
41 */ 44 */
42class OManufacturerDB 45class OManufacturerDB
43{ 46{
44 public: 47 public:
45 /** 48 /**
46 * @returns the one-and-only @ref OManufacturerDB instance. 49 * @returns the one-and-only @ref OManufacturerDB instance.
47 */ 50 */
48 static OManufacturerDB* instance(); 51 static OManufacturerDB* instance();
49 /** 52 /**
50 * @returns the short manufacturer string given a @a macaddr. 53 * @returns the short manufacturer string given a @a macaddr.
51 */ 54 */
52 const QString& lookup( const QString& macaddr ) const; 55 const QString& lookup( const QString& macaddr ) const;
53 /** 56 /**
54 * @returns the enhanced manufacturer string given a @a macaddr. 57 * @returns the enhanced manufacturer string given a @a macaddr.
55 */ 58 */
56 const QString& lookupExt( const QString& macaddr ) const; 59 const QString& lookupExt( const QString& macaddr ) const;
57 60
58 protected: 61 protected:
59 OManufacturerDB(); 62 OManufacturerDB();
60 virtual ~OManufacturerDB(); 63 virtual ~OManufacturerDB();
61 64
62 private: 65 private:
63 QMap<QString, QString> manufacturers; 66 QMap<QString, QString> manufacturers;
64 QMap<QString, QString> manufacturersExt; 67 QMap<QString, QString> manufacturersExt;
65 static OManufacturerDB* _instance; 68 static OManufacturerDB* _instance;
69 class Private;
70 Private *d;
66}; 71};
67 72
73}
74}
75
68#endif 76#endif
69 77
diff --git a/libopie2/opienet/onetutils.cpp b/libopie2/opienet/onetutils.cpp
index 48cfa43..7794334 100644
--- a/libopie2/opienet/onetutils.cpp
+++ b/libopie2/opienet/onetutils.cpp
@@ -1,87 +1,90 @@
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@Vanille.de> 4              (C) 2003 Michael 'Mickey' Lauer <mickey@Vanille.de>
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/onetutils.h> 32#include <opie2/onetutils.h>
33#include <opie2/onetwork.h> 33#include <opie2/onetwork.h>
34#include <opie2/omanufacturerdb.h> 34#include <opie2/omanufacturerdb.h>
35 35
36#include <net/if.h> 36#include <net/if.h>
37#include <assert.h> 37#include <assert.h>
38#include <stdio.h> 38#include <stdio.h>
39 39
40namespace Opie {
41namespace Net {
42
40/*====================================================================================== 43/*======================================================================================
41 * OMacAddress 44 * OMacAddress
42 *======================================================================================*/ 45 *======================================================================================*/
43 46
44// static initializer for broadcast and unknown MAC Adresses 47// static initializer for broadcast and unknown MAC Adresses
45const unsigned char __broadcast[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; 48const unsigned char __broadcast[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
46const OMacAddress& OMacAddress::broadcast = OMacAddress( __broadcast ); 49const OMacAddress& OMacAddress::broadcast = OMacAddress( __broadcast );
47const unsigned char __unknown[6] = { 0x44, 0x44, 0x44, 0x44, 0x44, 0x44 }; 50const unsigned char __unknown[6] = { 0x44, 0x44, 0x44, 0x44, 0x44, 0x44 };
48const OMacAddress& OMacAddress::unknown = OMacAddress( __unknown ); 51const OMacAddress& OMacAddress::unknown = OMacAddress( __unknown );
49 52
50//TODO: Incorporate Ethernet Manufacturer database here! (inline or so) 53//TODO: Incorporate Ethernet Manufacturer database here! (inline or so)
51 54
52OMacAddress::OMacAddress() 55OMacAddress::OMacAddress()
53{ 56{
54 memcpy( _bytes, __unknown, 6 ); 57 memcpy( _bytes, __unknown, 6 );
55} 58}
56 59
57 60
58OMacAddress::OMacAddress( unsigned char* p ) 61OMacAddress::OMacAddress( unsigned char* p )
59{ 62{
60 memcpy( _bytes, p, 6 ); 63 memcpy( _bytes, p, 6 );
61} 64}
62 65
63 66
64OMacAddress::OMacAddress( const unsigned char* p ) 67OMacAddress::OMacAddress( const unsigned char* p )
65{ 68{
66 memcpy( _bytes, p, 6 ); 69 memcpy( _bytes, p, 6 );
67} 70}
68 71
69 72
70OMacAddress::OMacAddress( struct ifreq& ifr ) 73OMacAddress::OMacAddress( struct ifreq& ifr )
71{ 74{
72 memcpy( _bytes, ifr.ifr_hwaddr.sa_data, 6 ); 75 memcpy( _bytes, ifr.ifr_hwaddr.sa_data, 6 );
73} 76}
74 77
75 78
76OMacAddress::~OMacAddress() 79OMacAddress::~OMacAddress()
77{ 80{
78} 81}
79 82
80 83
81//#ifdef QT_NO_DEBUG 84//#ifdef QT_NO_DEBUG
82//inline 85//inline
83//#endif 86//#endif
84const unsigned char* OMacAddress::native() const 87const unsigned char* OMacAddress::native() const
85{ 88{
86 return (const unsigned char*) &_bytes; 89 return (const unsigned char*) &_bytes;
87} 90}
@@ -140,93 +143,99 @@ bool operator==( const OMacAddress &m1, const OMacAddress &m2 )
140 143
141OPrivateIOCTL::OPrivateIOCTL( QObject* parent, const char* name, int cmd, int getargs, int setargs ) 144OPrivateIOCTL::OPrivateIOCTL( QObject* parent, const char* name, int cmd, int getargs, int setargs )
142 :QObject( parent, name ), _ioctl( cmd ), _getargs( getargs ), _setargs( setargs ) 145 :QObject( parent, name ), _ioctl( cmd ), _getargs( getargs ), _setargs( setargs )
143{ 146{
144} 147}
145 148
146 149
147OPrivateIOCTL::~OPrivateIOCTL() 150OPrivateIOCTL::~OPrivateIOCTL()
148{ 151{
149} 152}
150 153
151 154
152int OPrivateIOCTL::numberGetArgs() const 155int OPrivateIOCTL::numberGetArgs() const
153{ 156{
154 return _getargs & IW_PRIV_SIZE_MASK; 157 return _getargs & IW_PRIV_SIZE_MASK;
155} 158}
156 159
157 160
158int OPrivateIOCTL::typeGetArgs() const 161int OPrivateIOCTL::typeGetArgs() const
159{ 162{
160 return _getargs & IW_PRIV_TYPE_MASK >> 12; 163 return _getargs & IW_PRIV_TYPE_MASK >> 12;
161} 164}
162 165
163 166
164int OPrivateIOCTL::numberSetArgs() const 167int OPrivateIOCTL::numberSetArgs() const
165{ 168{
166 return _setargs & IW_PRIV_SIZE_MASK; 169 return _setargs & IW_PRIV_SIZE_MASK;
167} 170}
168 171
169 172
170int OPrivateIOCTL::typeSetArgs() const 173int OPrivateIOCTL::typeSetArgs() const
171{ 174{
172 return _setargs & IW_PRIV_TYPE_MASK >> 12; 175 return _setargs & IW_PRIV_TYPE_MASK >> 12;
173} 176}
174 177
175 178
176void OPrivateIOCTL::invoke() const 179void OPrivateIOCTL::invoke() const
177{ 180{
178 ( (OWirelessNetworkInterface*) parent() )->wioctl( _ioctl ); 181 ( (OWirelessNetworkInterface*) parent() )->wioctl( _ioctl );
179} 182}
180 183
181 184
182void OPrivateIOCTL::setParameter( int num, u_int32_t value ) 185void OPrivateIOCTL::setParameter( int num, u_int32_t value )
183{ 186{
184 u_int32_t* arglist = (u_int32_t*) &( (OWirelessNetworkInterface*) parent() )->_iwr.u.name; 187 u_int32_t* arglist = (u_int32_t*) &( (OWirelessNetworkInterface*) parent() )->_iwr.u.name;
185 arglist[num] = value; 188 arglist[num] = value;
186} 189}
187 190
191
192
193namespace Private {
188/*====================================================================================== 194/*======================================================================================
189 * assorted functions 195 * assorted functions
190 *======================================================================================*/ 196 *======================================================================================*/
191 197
192void dumpBytes( const unsigned char* data, int num ) 198void dumpBytes( const unsigned char* data, int num )
193{ 199{
194 printf( "Dumping %d bytes @ %0x", num, data ); 200 printf( "Dumping %d bytes @ %0x", num, data );
195 printf( "-------------------------------------------\n" ); 201 printf( "-------------------------------------------\n" );
196 202
197 for ( int i = 0; i < num; ++i ) 203 for ( int i = 0; i < num; ++i )
198 { 204 {
199 printf( "%02x ", data[i] ); 205 printf( "%02x ", data[i] );
200 if ( !((i+1) % 32) ) printf( "\n" ); 206 if ( !((i+1) % 32) ) printf( "\n" );
201 } 207 }
202 printf( "\n\n" ); 208 printf( "\n\n" );
203} 209}
204 210
205 211
206int stringToMode( const QString& mode ) 212int stringToMode( const QString& mode )
207{ 213{
208 if ( mode == "auto" ) return IW_MODE_AUTO; 214 if ( mode == "auto" ) return IW_MODE_AUTO;
209 else if ( mode == "adhoc" ) return IW_MODE_ADHOC; 215 else if ( mode == "adhoc" ) return IW_MODE_ADHOC;
210 else if ( mode == "managed" ) return IW_MODE_INFRA; 216 else if ( mode == "managed" ) return IW_MODE_INFRA;
211 else if ( mode == "master" ) return IW_MODE_MASTER; 217 else if ( mode == "master" ) return IW_MODE_MASTER;
212 else if ( mode == "repeater" ) return IW_MODE_REPEAT; 218 else if ( mode == "repeater" ) return IW_MODE_REPEAT;
213 else if ( mode == "secondary" ) return IW_MODE_SECOND; 219 else if ( mode == "secondary" ) return IW_MODE_SECOND;
214 else if ( mode == "monitor" ) return IW_MODE_MONITOR; 220 else if ( mode == "monitor" ) return IW_MODE_MONITOR;
215 else assert( 0 ); 221 else assert( 0 );
216} 222}
217 223
218 224
219QString modeToString( int mode ) 225QString modeToString( int mode )
220{ 226{
221 switch ( mode ) 227 switch ( mode )
222 { 228 {
223 case IW_MODE_AUTO: return "auto"; 229 case IW_MODE_AUTO: return "auto";
224 case IW_MODE_ADHOC: return "adhoc"; 230 case IW_MODE_ADHOC: return "adhoc";
225 case IW_MODE_INFRA: return "managed"; 231 case IW_MODE_INFRA: return "managed";
226 case IW_MODE_MASTER: return "master"; 232 case IW_MODE_MASTER: return "master";
227 case IW_MODE_REPEAT: return "repeater"; 233 case IW_MODE_REPEAT: return "repeater";
228 case IW_MODE_SECOND: return "second"; 234 case IW_MODE_SECOND: return "second";
229 case IW_MODE_MONITOR: return "monitor"; 235 case IW_MODE_MONITOR: return "monitor";
230 default: assert( 0 ); 236 default: assert( 0 );
231 } 237 }
232} 238}
239}
240}
241}
diff --git a/libopie2/opienet/onetutils.h b/libopie2/opienet/onetutils.h
index bddfab9..ca6815d 100644
--- a/libopie2/opienet/onetutils.h
+++ b/libopie2/opienet/onetutils.h
@@ -1,174 +1,189 @@
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 =. 5 =.
6 .=l. 6 .=l.
7           .>+-= 7           .>+-=
8 _;:,     .>    :=|. This program is free software; you can 8 _;:,     .>    :=|. This program is free software; you can
9.> <`_,   >  .   <= redistribute it and/or modify it under 9.> <`_,   >  .   <= redistribute it and/or modify it under
10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
11.="- .-=="i,     .._ License as published by the Free Software 11.="- .-=="i,     .._ License as published by the Free Software
12 - .   .-<_>     .<> Foundation; either version 2 of the License, 12 - .   .-<_>     .<> Foundation; either version 2 of the License,
13     ._= =}       : or (at your option) any later version. 13     ._= =}       : or (at your option) any later version.
14    .%`+i>       _;_. 14    .%`+i>       _;_.
15    .i_,=:_.      -<s. This program is distributed in the hope that 15    .i_,=:_.      -<s. This program is distributed in the hope that
16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
17    : ..    .:,     . . . without even the implied warranty of 17    : ..    .:,     . . . without even the implied warranty of
18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.=       =       ; Library General Public License for more 20..}^=.=       =       ; Library General Public License for more
21++=   -.     .`     .: details. 21++=   -.     .`     .: details.
22 :     =  ...= . :.=- 22 :     =  ...= . :.=-
23 -.   .:....=;==+<; You should have received a copy of the GNU 23 -.   .:....=;==+<; You should have received a copy of the GNU
24  -_. . .   )=.  = Library General Public License along with 24  -_. . .   )=.  = Library General Public License along with
25    --        :-=` this library; see the file COPYING.LIB. 25    --        :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation, 26 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330, 27 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA. 28 Boston, MA 02111-1307, USA.
29 29
30*/ 30*/
31 31
32#ifndef ONETUTILS_H 32#ifndef ONETUTILS_H
33#define ONETUTILS_H 33#define ONETUTILS_H
34 34
35#include <qdict.h> 35#include <qdict.h>
36#include <qmap.h> 36#include <qmap.h>
37#include <qstring.h> 37#include <qstring.h>
38#include <qhostaddress.h> 38#include <qhostaddress.h>
39#include <qobject.h> 39#include <qobject.h>
40 40
41#include <sys/types.h> 41#include <sys/types.h>
42 42
43struct ifreq; 43struct ifreq;
44
45namespace Opie {
46namespace Net {
47
44class OWirelessNetworkInterface; 48class OWirelessNetworkInterface;
45 49
46/*====================================================================================== 50/*======================================================================================
47 * OMacAddress 51 * OMacAddress
48 *======================================================================================*/ 52 *======================================================================================*/
49 53
50class OMacAddress 54class OMacAddress
51{ 55{
52 public: 56 public:
53 // QString c'tor? -zecke 57 // QString c'tor? -zecke
54 OMacAddress(); 58 OMacAddress();
55 OMacAddress( unsigned char* ); 59 OMacAddress( unsigned char* );
56 OMacAddress( const unsigned char* ); 60 OMacAddress( const unsigned char* );
57 OMacAddress( struct ifreq& ); 61 OMacAddress( struct ifreq& );
58 ~OMacAddress(); 62 ~OMacAddress();
59 63
60 QString manufacturer() const; 64 QString manufacturer() const;
61 QString toString( bool substitute = false ) const; 65 QString toString( bool substitute = false ) const;
62 const unsigned char* native() const; 66 const unsigned char* native() const;
63 67
64 // no c'tor but this one why not make it a c'tor. it could also replace the others or is this the problem? 68 // no c'tor but this one why not make it a c'tor. it could also replace the others or is this the problem?
65 static OMacAddress fromString( const QString& ); 69 static OMacAddress fromString( const QString& );
66 70
67 public: 71 public:
68 static const OMacAddress& broadcast; // ff:ff:ff:ff:ff:ff 72 static const OMacAddress& broadcast; // ff:ff:ff:ff:ff:ff
69 static const OMacAddress& unknown; // 44:44:44:44:44:44 73 static const OMacAddress& unknown; // 44:44:44:44:44:44
70 74
71 private: 75 private:
72 unsigned char _bytes[6]; 76 unsigned char _bytes[6];
73 77
74 friend bool operator==( const OMacAddress &m1, const OMacAddress &m2 ); 78 friend bool operator==( const OMacAddress &m1, const OMacAddress &m2 );
79 class Private;
80 Private *d;
75 81
76}; 82};
77 83
78bool operator==( const OMacAddress &m1, const OMacAddress &m2 ); 84bool operator==( const OMacAddress &m1, const OMacAddress &m2 );
79 85
80 86
81/*====================================================================================== 87/*======================================================================================
82 * OHostAddress 88 * OHostAddress
83 *======================================================================================*/ 89 *======================================================================================*/
84 90
85class OHostAddress : public QHostAddress 91class OHostAddress : public QHostAddress
86{ 92{
87 /*public: 93 /*public:
88 OHostAddress(); 94 OHostAddress();
89 ~OHostAddress(); 95 ~OHostAddress();
90 */ 96 */
97 private:
98 class Private;
99 Private *d;
91}; 100};
92 101
93 102
94/*====================================================================================== 103/*======================================================================================
95 * OPrivateIOCTL 104 * OPrivateIOCTL
96 *======================================================================================*/ 105 *======================================================================================*/
97 106
98class OPrivateIOCTL : public QObject 107class OPrivateIOCTL : public QObject
99{ 108{
100 public: 109 public:
101 OPrivateIOCTL( QObject* parent, const char* name, int cmd, int getargs, int setargs ); 110 OPrivateIOCTL( QObject* parent, const char* name, int cmd, int getargs, int setargs );
102 ~OPrivateIOCTL(); 111 ~OPrivateIOCTL();
103 112
104 int numberGetArgs() const; 113 int numberGetArgs() const;
105 int typeGetArgs() const; 114 int typeGetArgs() const;
106 int numberSetArgs() const; 115 int numberSetArgs() const;
107 int typeSetArgs() const; 116 int typeSetArgs() const;
108 117
109 // FIXME return int? as ::ioctl does? -zecke 118 // FIXME return int? as ::ioctl does? -zecke
110 void invoke() const; 119 void invoke() const;
111 void setParameter( int, u_int32_t ); 120 void setParameter( int, u_int32_t );
112 121
113 private: 122 private:
114 u_int32_t _ioctl; 123 u_int32_t _ioctl;
115 u_int16_t _getargs; 124 u_int16_t _getargs;
116 u_int16_t _setargs; 125 u_int16_t _setargs;
117 126
127 class Private;
128 Private *d;
118}; 129};
119 130
120 /*====================================================================================== 131 /*======================================================================================
121 * Miscellaneous 132 * Miscellaneous
122 *======================================================================================*/ 133 *======================================================================================*/
123 134
135namespace Private {
124void dumpBytes( const unsigned char* data, int num ); 136void dumpBytes( const unsigned char* data, int num );
125QString modeToString( int ); 137QString modeToString( int );
126int stringToMode( const QString& ); 138int stringToMode( const QString& );
139}
140}
141}
127 142
128#define IW_PRIV_TYPE_MASK 0x7000 143#define IW_PRIV_TYPE_MASK 0x7000
129#define IW_PRIV_TYPE_NONE 0x0000 144#define IW_PRIV_TYPE_NONE 0x0000
130#define IW_PRIV_TYPE_BYTE 0x1000 145#define IW_PRIV_TYPE_BYTE 0x1000
131#define IW_PRIV_TYPE_CHAR 0x2000 146#define IW_PRIV_TYPE_CHAR 0x2000
132#define IW_PRIV_TYPE_INT 0x4000 147#define IW_PRIV_TYPE_INT 0x4000
133#define IW_PRIV_TYPE_FLOAT 0x5000 148#define IW_PRIV_TYPE_FLOAT 0x5000
134#define IW_PRIV_TYPE_ADDR 0x6000 149#define IW_PRIV_TYPE_ADDR 0x6000
135#define IW_PRIV_SIZE_FIXED 0x0800 150#define IW_PRIV_SIZE_FIXED 0x0800
136#define IW_PRIV_SIZE_MASK 0x07FF 151#define IW_PRIV_SIZE_MASK 0x07FF
137 152
138#ifndef ARPHRD_IEEE80211 153#ifndef ARPHRD_IEEE80211
139#define ARPHRD_IEEE80211 801 154#define ARPHRD_IEEE80211 801
140#endif 155#endif
141#ifndef ARPHRD_IEEE80211_PRISM 156#ifndef ARPHRD_IEEE80211_PRISM
142#define ARPHRD_IEEE80211_PRISM 802 157#define ARPHRD_IEEE80211_PRISM 802
143#endif 158#endif
144 159
145 160
146/* Network to host order macros */ 161/* Network to host order macros */
147 162
148#ifdef LBL_ALIGN 163#ifdef LBL_ALIGN
149#define EXTRACT_16BITS(p) \ 164#define EXTRACT_16BITS(p) \
150 ((u_int16_t)((u_int16_t)*((const u_int8_t *)(p) + 0) << 8 | \ 165 ((u_int16_t)((u_int16_t)*((const u_int8_t *)(p) + 0) << 8 | \
151 (u_int16_t)*((const u_int8_t *)(p) + 1))) 166 (u_int16_t)*((const u_int8_t *)(p) + 1)))
152#define EXTRACT_32BITS(p) \ 167#define EXTRACT_32BITS(p) \
153 ((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 0) << 24 | \ 168 ((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 0) << 24 | \
154 (u_int32_t)*((const u_int8_t *)(p) + 1) << 16 | \ 169 (u_int32_t)*((const u_int8_t *)(p) + 1) << 16 | \
155 (u_int32_t)*((const u_int8_t *)(p) + 2) << 8 | \ 170 (u_int32_t)*((const u_int8_t *)(p) + 2) << 8 | \
156 (u_int32_t)*((const u_int8_t *)(p) + 3))) 171 (u_int32_t)*((const u_int8_t *)(p) + 3)))
157#else 172#else
158#define EXTRACT_16BITS(p) \ 173#define EXTRACT_16BITS(p) \
159 ((u_int16_t)ntohs(*(const u_int16_t *)(p))) 174 ((u_int16_t)ntohs(*(const u_int16_t *)(p)))
160#define EXTRACT_32BITS(p) \ 175#define EXTRACT_32BITS(p) \
161 ((u_int32_t)ntohl(*(const u_int32_t *)(p))) 176 ((u_int32_t)ntohl(*(const u_int32_t *)(p)))
162#endif 177#endif
163 178
164#define EXTRACT_24BITS(p) \ 179#define EXTRACT_24BITS(p) \
165 ((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 0) << 16 | \ 180 ((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 0) << 16 | \
166 (u_int32_t)*((const u_int8_t *)(p) + 1) << 8 | \ 181 (u_int32_t)*((const u_int8_t *)(p) + 1) << 8 | \
167 (u_int32_t)*((const u_int8_t *)(p) + 2))) 182 (u_int32_t)*((const u_int8_t *)(p) + 2)))
168 183
169/* Little endian protocol host order macros */ 184/* Little endian protocol host order macros */
170#define EXTRACT_LE_8BITS(p) (*(p)) 185#define EXTRACT_LE_8BITS(p) (*(p))
171#define EXTRACT_LE_16BITS(p) \ 186#define EXTRACT_LE_16BITS(p) \
172 ((u_int16_t)((u_int16_t)*((const u_int8_t *)(p) + 1) << 8 | \ 187 ((u_int16_t)((u_int16_t)*((const u_int8_t *)(p) + 1) << 8 | \
173 (u_int16_t)*((const u_int8_t *)(p) + 0))) 188 (u_int16_t)*((const u_int8_t *)(p) + 0)))
174#define EXTRACT_LE_32BITS(p) \ 189#define EXTRACT_LE_32BITS(p) \
diff --git a/libopie2/opienet/onetwork.cpp b/libopie2/opienet/onetwork.cpp
index e5b091f..ab3e77f 100644
--- a/libopie2/opienet/onetwork.cpp
+++ b/libopie2/opienet/onetwork.cpp
@@ -12,103 +12,109 @@
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/onetwork.h> 33#include <opie2/onetwork.h>
34#include <opie2/ostation.h> 34#include <opie2/ostation.h>
35#include <opie2/odebug.h> 35#include <opie2/odebug.h>
36 36
37/* QT */ 37/* QT */
38 38
39#include <qfile.h> 39#include <qfile.h>
40#include <qtextstream.h> 40#include <qtextstream.h>
41 41
42/* UNIX */ 42/* UNIX */
43 43
44#include <assert.h> 44#include <assert.h>
45#include <arpa/inet.h> 45#include <arpa/inet.h>
46#include <errno.h> 46#include <errno.h>
47#include <string.h> 47#include <string.h>
48#include <stdlib.h> 48#include <stdlib.h>
49#include <math.h> 49#include <math.h>
50#include <sys/ioctl.h> 50#include <sys/ioctl.h>
51#include <sys/socket.h> 51#include <sys/socket.h>
52#include <sys/types.h> 52#include <sys/types.h>
53#include <unistd.h> 53#include <unistd.h>
54#include <linux/sockios.h> 54#include <linux/sockios.h>
55#include <net/if_arp.h> 55#include <net/if_arp.h>
56#include <stdarg.h> 56#include <stdarg.h>
57 57
58#ifndef NODEBUG 58#ifndef NODEBUG
59#include <opie2/odebugmapper.h> 59#include <opie2/odebugmapper.h>
60
61
62using namespace Opie::Core;
63using namespace Opie::Net::Private;
60DebugMapper* debugmapper = new DebugMapper(); 64DebugMapper* debugmapper = new DebugMapper();
61#endif 65#endif
62 66
63/*====================================================================================== 67/*======================================================================================
64 * ONetwork 68 * ONetwork
65 *======================================================================================*/ 69 *======================================================================================*/
66 70
71namespace Opie {
72namespace Net {
67ONetwork* ONetwork::_instance = 0; 73ONetwork* ONetwork::_instance = 0;
68 74
69ONetwork::ONetwork() 75ONetwork::ONetwork()
70{ 76{
71 odebug << "ONetwork::ONetwork()" << oendl; 77 odebug << "ONetwork::ONetwork()" << oendl;
72 odebug << "ONetwork: This code has been compiled against Wireless Extensions V" << WIRELESS_EXT << oendl; 78 odebug << "ONetwork: This code has been compiled against Wireless Extensions V" << WIRELESS_EXT << oendl;
73 synchronize(); 79 synchronize();
74} 80}
75 81
76void ONetwork::synchronize() 82void ONetwork::synchronize()
77{ 83{
78 // gather available interfaces by inspecting /proc/net/dev 84 // gather available interfaces by inspecting /proc/net/dev
79 //FIXME: we could use SIOCGIFCONF here, but we aren't interested in virtual (e.g. eth0:0) devices 85 //FIXME: we could use SIOCGIFCONF here, but we aren't interested in virtual (e.g. eth0:0) devices
80 //FIXME: Use SIOCGIFCONF anway, because we can disable listing of aliased devices 86 //FIXME: Use SIOCGIFCONF anway, because we can disable listing of aliased devices
81 //FIXME: Best is use SIOCGIFCONF and if this doesn't work (result=-1), then fallback to parsing /proc/net/dev 87 //FIXME: Best is use SIOCGIFCONF and if this doesn't work (result=-1), then fallback to parsing /proc/net/dev
82 88
83 _interfaces.clear(); 89 _interfaces.clear();
84 QString str; 90 QString str;
85 QFile f( "/proc/net/dev" ); 91 QFile f( "/proc/net/dev" );
86 bool hasFile = f.open( IO_ReadOnly ); 92 bool hasFile = f.open( IO_ReadOnly );
87 if ( !hasFile ) 93 if ( !hasFile )
88 { 94 {
89 odebug << "ONetwork: /proc/net/dev not existing. No network devices available" << oendl; 95 odebug << "ONetwork: /proc/net/dev not existing. No network devices available" << oendl;
90 return; 96 return;
91 } 97 }
92 QTextStream s( &f ); 98 QTextStream s( &f );
93 s.readLine(); 99 s.readLine();
94 s.readLine(); 100 s.readLine();
95 while ( !s.atEnd() ) 101 while ( !s.atEnd() )
96 { 102 {
97 s >> str; 103 s >> str;
98 str.truncate( str.find( ':' ) ); 104 str.truncate( str.find( ':' ) );
99 odebug << "ONetwork: found interface '" << str << "'" << oendl; 105 odebug << "ONetwork: found interface '" << str << "'" << oendl;
100 ONetworkInterface* iface; 106 ONetworkInterface* iface;
101 if ( isWirelessInterface( str ) ) 107 if ( isWirelessInterface( str ) )
102 { 108 {
103 iface = new OWirelessNetworkInterface( this, (const char*) str ); 109 iface = new OWirelessNetworkInterface( this, (const char*) str );
104 odebug << "ONetwork: interface '" << str << "' has Wireless Extensions" << oendl; 110 odebug << "ONetwork: interface '" << str << "' has Wireless Extensions" << oendl;
105 } 111 }
106 else 112 else
107 { 113 {
108 iface = new ONetworkInterface( this, (const char*) str ); 114 iface = new ONetworkInterface( this, (const char*) str );
109 } 115 }
110 _interfaces.insert( str, iface ); 116 _interfaces.insert( str, iface );
111 s.readLine(); 117 s.readLine();
112 } 118 }
113} 119}
114 120
@@ -1192,48 +1198,51 @@ QString OHostAPMonitoringInterface::name() const
1192 1198
1193/*====================================================================================== 1199/*======================================================================================
1194 * OOrinocoNetworkInterface 1200 * OOrinocoNetworkInterface
1195 *======================================================================================*/ 1201 *======================================================================================*/
1196 1202
1197OOrinocoMonitoringInterface::OOrinocoMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) 1203OOrinocoMonitoringInterface::OOrinocoMonitoringInterface( ONetworkInterface* iface, bool prismHeader )
1198 :OMonitoringInterface( iface, prismHeader ) 1204 :OMonitoringInterface( iface, prismHeader )
1199{ 1205{
1200 iface->setMonitoring( this ); 1206 iface->setMonitoring( this );
1201} 1207}
1202 1208
1203 1209
1204OOrinocoMonitoringInterface::~OOrinocoMonitoringInterface() 1210OOrinocoMonitoringInterface::~OOrinocoMonitoringInterface()
1205{ 1211{
1206} 1212}
1207 1213
1208 1214
1209void OOrinocoMonitoringInterface::setChannel( int c ) 1215void OOrinocoMonitoringInterface::setChannel( int c )
1210{ 1216{
1211 if ( !_if->hasPrivate( "monitor" ) ) 1217 if ( !_if->hasPrivate( "monitor" ) )
1212 { 1218 {
1213 this->OMonitoringInterface::setChannel( c ); 1219 this->OMonitoringInterface::setChannel( c );
1214 } 1220 }
1215 else 1221 else
1216 { 1222 {
1217 int monitorCode = _prismHeader ? 1 : 2; 1223 int monitorCode = _prismHeader ? 1 : 2;
1218 _if->setPrivate( "monitor", 2, monitorCode, c ); 1224 _if->setPrivate( "monitor", 2, monitorCode, c );
1219 } 1225 }
1220} 1226}
1221 1227
1222 1228
1223void OOrinocoMonitoringInterface::setEnabled( bool b ) 1229void OOrinocoMonitoringInterface::setEnabled( bool b )
1224{ 1230{
1225 if ( b ) 1231 if ( b )
1226 { 1232 {
1227 setChannel( 1 ); 1233 setChannel( 1 );
1228 } 1234 }
1229 else 1235 else
1230 { 1236 {
1231 _if->setPrivate( "monitor", 2, 0, 0 ); 1237 _if->setPrivate( "monitor", 2, 0, 0 );
1232 } 1238 }
1233} 1239}
1234 1240
1235 1241
1236QString OOrinocoMonitoringInterface::name() const 1242QString OOrinocoMonitoringInterface::name() const
1237{ 1243{
1238 return "orinoco"; 1244 return "orinoco";
1239} 1245}
1246
1247}
1248}
diff --git a/libopie2/opienet/onetwork.h b/libopie2/opienet/onetwork.h
index 93b129f..a953296 100644
--- a/libopie2/opienet/onetwork.h
+++ b/libopie2/opienet/onetwork.h
@@ -11,163 +11,168 @@
11 - .   .-<_>     .<> Foundation; either version 2 of the License, 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version. 12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_. 13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This program is distributed in the hope that 14    .i_,=:_.      -<s. This program is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of 16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more 19..}^=.=       =       ; Library General Public License for more
20++=   -.     .`     .: details. 20++=   -.     .`     .: details.
21 :     =  ...= . :.=- 21 :     =  ...= . :.=-
22 -.   .:....=;==+<; You should have received a copy of the GNU 22 -.   .:....=;==+<; You should have received a copy of the GNU
23  -_. . .   )=.  = Library General Public License along with 23  -_. . .   )=.  = Library General Public License along with
24    --        :-=` this library; see the file COPYING.LIB. 24    --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28 28
29*/ 29*/
30 30
31#ifndef ONETWORK_H 31#ifndef ONETWORK_H
32#define ONETWORK_H 32#define ONETWORK_H
33 33
34#if !defined( OPIE_WE_VERSION ) 34#if !defined( OPIE_WE_VERSION )
35#error Need to define a wireless extension version to build against! 35#error Need to define a wireless extension version to build against!
36#endif 36#endif
37 37
38#if OPIE_WE_VERSION == 15 38#if OPIE_WE_VERSION == 15
39#include "wireless.15.h" 39#include "wireless.15.h"
40#endif 40#endif
41 41
42#if OPIE_WE_VERSION == 16 42#if OPIE_WE_VERSION == 16
43#include "wireless.16.h" 43#include "wireless.16.h"
44#endif 44#endif
45 45
46/* OPIE */ 46/* OPIE */
47 47
48#include <opie2/onetutils.h> 48#include <opie2/onetutils.h>
49#include <opie2/ostation.h> 49#include <opie2/ostation.h>
50 50
51/* QT */ 51/* QT */
52 52
53#include <qvaluelist.h> 53#include <qvaluelist.h>
54#include <qdict.h> 54#include <qdict.h>
55#include <qmap.h> 55#include <qmap.h>
56#include <qobject.h> 56#include <qobject.h>
57#include <qhostaddress.h> 57#include <qhostaddress.h>
58 58
59namespace Opie {
60namespace Net {
61
59class ONetworkInterface; 62class ONetworkInterface;
60class OWirelessNetworkInterface; 63class OWirelessNetworkInterface;
61class OChannelHopper; 64class OChannelHopper;
62class OMonitoringInterface; 65class OMonitoringInterface;
63 66
64/*====================================================================================== 67/*======================================================================================
65 * ONetwork 68 * ONetwork
66 *======================================================================================*/ 69 *======================================================================================*/
67 70
68/** 71/**
69 * @brief A container class for all network interfaces 72 * @brief A container class for all network interfaces
70 * 73 *
71 * This class provides access to all available network interfaces of your computer. 74 * This class provides access to all available network interfaces of your computer.
72 * 75 *
73 * @author Michael 'Mickey' Lauer <mickey@vanille.de> 76 * @author Michael 'Mickey' Lauer <mickey@vanille.de>
74 */ 77 */
75class ONetwork : public QObject 78class ONetwork : public QObject
76{ 79{
77 Q_OBJECT 80 Q_OBJECT
78 81
79 public: 82 public:
80 typedef QDict<ONetworkInterface> InterfaceMap; 83 typedef QDict<ONetworkInterface> InterfaceMap;
81 typedef QDictIterator<ONetworkInterface> InterfaceIterator; 84 typedef QDictIterator<ONetworkInterface> InterfaceIterator;
82 85
83 public: 86 public:
84 /** 87 /**
85 * @returns the number of available interfaces 88 * @returns the number of available interfaces
86 */ 89 */
87 int count() const; 90 int count() const;
88 /** 91 /**
89 * @returns a pointer to the (one and only) @ref ONetwork instance. 92 * @returns a pointer to the (one and only) @ref ONetwork instance.
90 */ 93 */
91 static ONetwork* instance(); 94 static ONetwork* instance();
92 /** 95 /**
93 * @returns an iterator usable for iterating through all network interfaces. 96 * @returns an iterator usable for iterating through all network interfaces.
94 */ 97 */
95 InterfaceIterator iterator() const; 98 InterfaceIterator iterator() const;
96 /** 99 /**
97 * @returns true, if the @a interface is present. 100 * @returns true, if the @a interface is present.
98 */ 101 */
99 bool isPresent( const char* interface ) const; 102 bool isPresent( const char* interface ) const;
100 /** 103 /**
101 * @returns true, if the @a interface supports the wireless extension protocol. 104 * @returns true, if the @a interface supports the wireless extension protocol.
102 */ 105 */
103 bool isWirelessInterface( const char* interface ) const; 106 bool isWirelessInterface( const char* interface ) const;
104 /** 107 /**
105 * @returns a pointer to the @ref ONetworkInterface object for the specified @a interface or 0, if not found. 108 * @returns a pointer to the @ref ONetworkInterface object for the specified @a interface or 0, if not found.
106 * @see ONetworkInterface 109 * @see ONetworkInterface
107 */ 110 */
108 ONetworkInterface* interface( const QString& interface ) const; 111 ONetworkInterface* interface( const QString& interface ) const;
109 /** 112 /**
110 * @internal Rebuild the internal interface database 113 * @internal Rebuild the internal interface database
111 * @note Sometimes it might be useful to call this from client code, 114 * @note Sometimes it might be useful to call this from client code,
112 * e.g. after issuing a cardctl insert 115 * e.g. after issuing a cardctl insert
113 */ 116 */
114 void synchronize(); 117 void synchronize();
115 /** 118 /**
116 * @returns the wireless extension version used at compile time. 119 * @returns the wireless extension version used at compile time.
117 **/ 120 **/
118 static short wirelessExtensionVersion(); 121 static short wirelessExtensionVersion();
119 122
120 protected: 123 protected:
121 ONetwork(); 124 ONetwork();
122 125
123 private: 126 private:
124 static ONetwork* _instance; 127 static ONetwork* _instance;
125 InterfaceMap _interfaces; 128 InterfaceMap _interfaces;
129 class Private;
130 Private *d;
126}; 131};
127 132
128 133
129/*====================================================================================== 134/*======================================================================================
130 * ONetworkInterface 135 * ONetworkInterface
131 *======================================================================================*/ 136 *======================================================================================*/
132 137
133/** 138/**
134 * @brief A network interface wrapper. 139 * @brief A network interface wrapper.
135 * 140 *
136 * This class provides a wrapper for a network interface. All the cumbersume details of 141 * This class provides a wrapper for a network interface. All the cumbersume details of
137 * Linux ioctls are hidden under a convenient high-level interface. 142 * Linux ioctls are hidden under a convenient high-level interface.
138 * @warning Most of the setting methods contained in this class require the appropriate 143 * @warning Most of the setting methods contained in this class require the appropriate
139 * process permissions to work. 144 * process permissions to work.
140 * 145 *
141 * @author Michael 'Mickey' Lauer <mickey@vanille.de> 146 * @author Michael 'Mickey' Lauer <mickey@vanille.de>
142 */ 147 */
143class ONetworkInterface : public QObject 148class ONetworkInterface : public QObject
144{ 149{
145 friend class OMonitoringInterface; 150 friend class OMonitoringInterface;
146 friend class OCiscoMonitoringInterface; 151 friend class OCiscoMonitoringInterface;
147 friend class OWlanNGMonitoringInterface; 152 friend class OWlanNGMonitoringInterface;
148 friend class OHostAPMonitoringInterface; 153 friend class OHostAPMonitoringInterface;
149 friend class OOrinocoMonitoringInterface; 154 friend class OOrinocoMonitoringInterface;
150 155
151 public: 156 public:
152 /** 157 /**
153 * Constructor. Normally you don't create @ref ONetworkInterface objects yourself, 158 * Constructor. Normally you don't create @ref ONetworkInterface objects yourself,
154 * but access them via @ref ONetwork::interface(). 159 * but access them via @ref ONetwork::interface().
155 */ 160 */
156 ONetworkInterface( QObject* parent, const char* name ); 161 ONetworkInterface( QObject* parent, const char* name );
157 /** 162 /**
158 * Destructor. 163 * Destructor.
159 */ 164 */
160 virtual ~ONetworkInterface(); 165 virtual ~ONetworkInterface();
161 /** 166 /**
162 * Associates a @a monitoring interface with this network interface. 167 * Associates a @a monitoring interface with this network interface.
163 * @note This is currently only useful with @ref OWirelessNetworkInterface objects. 168 * @note This is currently only useful with @ref OWirelessNetworkInterface objects.
164 */ 169 */
165 void setMonitoring( OMonitoringInterface* monitoring ); 170 void setMonitoring( OMonitoringInterface* monitoring );
166 /** 171 /**
167 * @returns the currently associated monitoring interface or 0, if no monitoring is associated. 172 * @returns the currently associated monitoring interface or 0, if no monitoring is associated.
168 */ 173 */
169 OMonitoringInterface* monitoring() const; 174 OMonitoringInterface* monitoring() const;
170 /** 175 /**
171 * Setting an interface to promiscuous mode enables the device to receive 176 * Setting an interface to promiscuous mode enables the device to receive
172 * all packets on the shared medium - as opposed to packets which are addressed to this interface. 177 * all packets on the shared medium - as opposed to packets which are addressed to this interface.
173 */ 178 */
@@ -189,158 +194,163 @@ class ONetworkInterface : public QObject
189 */ 194 */
190 bool isLoopback() const; 195 bool isLoopback() const;
191 /** 196 /**
192 * @returns true if the interface is featuring supports the wireless extension protocol. 197 * @returns true if the interface is featuring supports the wireless extension protocol.
193 */ 198 */
194 bool isWireless() const; 199 bool isWireless() const;
195 /** 200 /**
196 * Associate the IP address @ addr with the interface. 201 * Associate the IP address @ addr with the interface.
197 */ 202 */
198 void setIPV4Address( const QHostAddress& addr ); 203 void setIPV4Address( const QHostAddress& addr );
199 /** 204 /**
200 * @returns the IPv4 address associated with the interface. 205 * @returns the IPv4 address associated with the interface.
201 */ 206 */
202 QString ipV4Address() const; //TODO: make this return an OHostAddress 207 QString ipV4Address() const; //TODO: make this return an OHostAddress
203 /** 208 /**
204 * Associate the MAC address @a addr with the interface. 209 * Associate the MAC address @a addr with the interface.
205 * @note It can be necessary to shut down the interface prior to calling this method. 210 * @note It can be necessary to shut down the interface prior to calling this method.
206 * @warning This is not supported by all drivers. 211 * @warning This is not supported by all drivers.
207 */ 212 */
208 void setMacAddress( const OMacAddress& addr ); 213 void setMacAddress( const OMacAddress& addr );
209 /** 214 /**
210 * @returns the MAC address associated with the interface. 215 * @returns the MAC address associated with the interface.
211 */ 216 */
212 OMacAddress macAddress() const; 217 OMacAddress macAddress() const;
213 /** 218 /**
214 * Associate the IPv4 @a netmask with the interface. 219 * Associate the IPv4 @a netmask with the interface.
215 */ 220 */
216 void setIPV4Netmask( const QHostAddress& netmask ); 221 void setIPV4Netmask( const QHostAddress& netmask );
217 /** 222 /**
218 * @returns the IPv4 netmask associated with the interface. 223 * @returns the IPv4 netmask associated with the interface.
219 */ 224 */
220 QString ipV4Netmask() const; //TODO: make this return an OHostAddress 225 QString ipV4Netmask() const; //TODO: make this return an OHostAddress
221 /** 226 /**
222 * @returns the data link type currently associated with the interface. 227 * @returns the data link type currently associated with the interface.
223 * @see #include <net/if_arp.h> for possible values. 228 * @see #include <net/if_arp.h> for possible values.
224 */ 229 */
225 int dataLinkType() const; 230 int dataLinkType() const;
226 231
227 protected: 232 protected:
228 const int _sfd; 233 const int _sfd;
229 mutable ifreq _ifr; 234 mutable ifreq _ifr;
230 OMonitoringInterface* _mon; 235 OMonitoringInterface* _mon;
231 236
232 protected: 237 protected:
233 struct ifreq& ifr() const; 238 struct ifreq& ifr() const;
234 virtual void init(); 239 virtual void init();
235 bool ioctl( int call ) const; 240 bool ioctl( int call ) const;
236 bool ioctl( int call, struct ifreq& ) const; 241 bool ioctl( int call, struct ifreq& ) const;
242 private:
243 class Private;
244 Private *d;
237}; 245};
238 246
239/*====================================================================================== 247/*======================================================================================
240 * OChannelHopper 248 * OChannelHopper
241 *======================================================================================*/ 249 *======================================================================================*/
242 250
243/** 251/**
244 * @brief A radio frequency channel hopper. 252 * @brief A radio frequency channel hopper.
245 * 253 *
246 * This class provides a channel hopper for radio frequencies. A channel hopper frequently 254 * This class provides a channel hopper for radio frequencies. A channel hopper frequently
247 * changes the radio frequency channel of its associated @ref OWirelessNetworkInterface. 255 * changes the radio frequency channel of its associated @ref OWirelessNetworkInterface.
248 * This is necessary when in monitoring mode and scanning for other devices, because 256 * This is necessary when in monitoring mode and scanning for other devices, because
249 * the radio frequency hardware can only detect packets sent on the same frequency. 257 * the radio frequency hardware can only detect packets sent on the same frequency.
250 * 258 *
251 * @author Michael 'Mickey' Lauer <mickey@vanille.de> 259 * @author Michael 'Mickey' Lauer <mickey@vanille.de>
252 */ 260 */
253class OChannelHopper : public QObject 261class OChannelHopper : public QObject
254{ 262{
255 Q_OBJECT 263 Q_OBJECT
256 264
257 public: 265 public:
258 /** 266 /**
259 * Constructor. 267 * Constructor.
260 */ 268 */
261 OChannelHopper( OWirelessNetworkInterface* ); 269 OChannelHopper( OWirelessNetworkInterface* );
262 /** 270 /**
263 * Destructor. 271 * Destructor.
264 */ 272 */
265 virtual ~OChannelHopper(); 273 virtual ~OChannelHopper();
266 /** 274 /**
267 * @returns true, if the channel hopper is hopping channels 275 * @returns true, if the channel hopper is hopping channels
268 */ 276 */
269 bool isActive() const; 277 bool isActive() const;
270 /** 278 /**
271 * @returns the last hopped channel 279 * @returns the last hopped channel
272 */ 280 */
273 int channel() const; 281 int channel() const;
274 /** 282 /**
275 * Set the channel hopping @a interval. 283 * Set the channel hopping @a interval.
276 * An interval of 0 deactivates the channel hopper. 284 * An interval of 0 deactivates the channel hopper.
277 */ 285 */
278 void setInterval( int interval ); 286 void setInterval( int interval );
279 /** 287 /**
280 * @returns the channel hopping interval 288 * @returns the channel hopping interval
281 */ 289 */
282 int interval() const; 290 int interval() const;
283 291
284 signals: 292 signals:
285 /** 293 /**
286 * This signal is emitted right after the channel hopper performed a hop 294 * This signal is emitted right after the channel hopper performed a hop
287 */ 295 */
288 void hopped( int ); 296 void hopped( int );
289 297
290 protected: 298 protected:
291 virtual void timerEvent( QTimerEvent* ); 299 virtual void timerEvent( QTimerEvent* );
292 300
293 private: 301 private:
294 OWirelessNetworkInterface* _iface; 302 OWirelessNetworkInterface* _iface;
295 int _interval; 303 int _interval;
296 int _tid; 304 int _tid;
297 QValueList<int> _channels; 305 QValueList<int> _channels;
298 QValueList<int>::Iterator _channel; 306 QValueList<int>::Iterator _channel;
307 class Private;
308 Private *d;
299}; 309};
300 310
301 311
302/*====================================================================================== 312/*======================================================================================
303 * OWirelessNetworkInterface 313 * OWirelessNetworkInterface
304 *======================================================================================*/ 314 *======================================================================================*/
305 315
306/** 316/**
307 * @brief A network interface wrapper for interfaces supporting the wireless extensions protocol. 317 * @brief A network interface wrapper for interfaces supporting the wireless extensions protocol.
308 * 318 *
309 * This class provides a high-level encapsulation of the Linux wireless extension API. 319 * This class provides a high-level encapsulation of the Linux wireless extension API.
310 * 320 *
311 * @author Michael 'Mickey' Lauer <mickey@vanille.de> 321 * @author Michael 'Mickey' Lauer <mickey@vanille.de>
312 */ 322 */
313class OWirelessNetworkInterface : public ONetworkInterface 323class OWirelessNetworkInterface : public ONetworkInterface
314{ 324{
315 friend class OMonitoringInterface; 325 friend class OMonitoringInterface;
316 friend class OCiscoMonitoringInterface; 326 friend class OCiscoMonitoringInterface;
317 friend class OWlanNGMonitoringInterface; 327 friend class OWlanNGMonitoringInterface;
318 friend class OHostAPMonitoringInterface; 328 friend class OHostAPMonitoringInterface;
319 friend class OOrinocoMonitoringInterface; 329 friend class OOrinocoMonitoringInterface;
320 330
321 friend class OPrivateIOCTL; 331 friend class OPrivateIOCTL;
322 332
323 public: 333 public:
324 /** 334 /**
325 * Constructor. 335 * Constructor.
326 */ 336 */
327 OWirelessNetworkInterface( QObject* parent, const char* name ); 337 OWirelessNetworkInterface( QObject* parent, const char* name );
328 /** 338 /**
329 * Destructor. 339 * Destructor.
330 */ 340 */
331 virtual ~OWirelessNetworkInterface(); 341 virtual ~OWirelessNetworkInterface();
332 /** 342 /**
333 * Setting the @a channel of the interface changes the radio frequency (RF) 343 * Setting the @a channel of the interface changes the radio frequency (RF)
334 * of the corresponding wireless network device. 344 * of the corresponding wireless network device.
335 * @note Common channel range is within [1-14]. A value of 0 is not allowed. 345 * @note Common channel range is within [1-14]. A value of 0 is not allowed.
336 * @see channels() 346 * @see channels()
337 */ 347 */
338 virtual void setChannel( int channel ) const; 348 virtual void setChannel( int channel ) const;
339 /** 349 /**
340 * @returns the channel index of the current radio frequency. 350 * @returns the channel index of the current radio frequency.
341 */ 351 */
342 virtual int channel() const; 352 virtual int channel() const;
343 /** 353 /**
344 * @returns the current radio frequency (in MHz). 354 * @returns the current radio frequency (in MHz).
345 */ 355 */
346 virtual double frequency() const; 356 virtual double frequency() const;
@@ -410,150 +420,171 @@ class OWirelessNetworkInterface : public ONetworkInterface
410 */ 420 */
411 virtual bool isAssociated() const; 421 virtual bool isAssociated() const;
412 /** 422 /**
413 * @returns the MAC address of the Access Point if the device is in infrastructure mode. 423 * @returns the MAC address of the Access Point if the device is in infrastructure mode.
414 * @returns a (more or less random) cell ID address if the device is in adhoc mode. 424 * @returns a (more or less random) cell ID address if the device is in adhoc mode.
415 */ 425 */
416 virtual OMacAddress associatedAP() const; 426 virtual OMacAddress associatedAP() const;
417 /** 427 /**
418 * Set the @a ssid (Service Set ID) string. This is used to decide 428 * Set the @a ssid (Service Set ID) string. This is used to decide
419 * which network to associate with (use "any" to let the driver decide). 429 * which network to associate with (use "any" to let the driver decide).
420 */ 430 */
421 virtual void setSSID( const QString& ssid ); 431 virtual void setSSID( const QString& ssid );
422 /** 432 /**
423 * @returns the current SSID (Service Set ID). 433 * @returns the current SSID (Service Set ID).
424 */ 434 */
425 virtual QString SSID() const; 435 virtual QString SSID() const;
426 /** 436 /**
427 * Perform scanning the wireless network neighbourhood. 437 * Perform scanning the wireless network neighbourhood.
428 * @note: UNSTABLE API - UNDER CONSTRUCTION - DON'T USE! 438 * @note: UNSTABLE API - UNDER CONSTRUCTION - DON'T USE!
429 */ 439 */
430 virtual OStationList* scanNetwork(); 440 virtual OStationList* scanNetwork();
431 /** 441 /**
432 * @return signal strength to associated neighbour (in percent). 442 * @return signal strength to associated neighbour (in percent).
433 * In infrastructure mode, this is the signal strength of the Access Point. 443 * In infrastructure mode, this is the signal strength of the Access Point.
434 * In other modes the result is driver dependent. 444 * In other modes the result is driver dependent.
435 */ 445 */
436 virtual int signalStrength() const; 446 virtual int signalStrength() const;
437 /** @internal commit pending changes to the driver 447 /** @internal commit pending changes to the driver
438 * 448 *
439 */ 449 */
440 void commit() const; 450 void commit() const;
441 451
442 protected: 452 protected:
443 void buildInformation(); 453 void buildInformation();
444 void buildPrivateList(); 454 void buildPrivateList();
445 void dumpInformation() const; 455 void dumpInformation() const;
446 virtual void init(); 456 virtual void init();
447 struct iwreq& iwr() const; 457 struct iwreq& iwr() const;
448 bool wioctl( int call ) const; 458 bool wioctl( int call ) const;
449 bool wioctl( int call, struct iwreq& ) const; 459 bool wioctl( int call, struct iwreq& ) const;
450 460
451 protected: 461 protected:
452 mutable struct iwreq _iwr; 462 mutable struct iwreq _iwr;
453 QMap<int,int> _channels; 463 QMap<int,int> _channels;
454 struct iw_range _range; 464 struct iw_range _range;
455 465
456 private: 466 private:
457 OChannelHopper* _hopper; 467 OChannelHopper* _hopper;
468 class Private;
469 Private *d;
458}; 470};
459 471
460 472
461/*====================================================================================== 473/*======================================================================================
462 * OMonitoringInterface 474 * OMonitoringInterface
463 *======================================================================================*/ 475 *======================================================================================*/
464 476
465 477
466class OMonitoringInterface 478class OMonitoringInterface
467{ 479{
468 public: 480 public:
469 OMonitoringInterface(); 481 OMonitoringInterface();
470 OMonitoringInterface( ONetworkInterface*, bool _prismHeader ); 482 OMonitoringInterface( ONetworkInterface*, bool _prismHeader );
471 virtual ~OMonitoringInterface(); 483 virtual ~OMonitoringInterface();
472 484
473 public: 485 public:
474 virtual void setEnabled( bool ); 486 virtual void setEnabled( bool );
475 virtual void setChannel( int ); 487 virtual void setChannel( int );
476 488
477 virtual QString name() const = 0; 489 virtual QString name() const = 0;
478 490
479 protected: 491 protected:
480 OWirelessNetworkInterface* _if; 492 OWirelessNetworkInterface* _if;
481 bool _prismHeader; 493 bool _prismHeader;
494 private:
495 class Private;
496 Private *d;
482 497
483}; 498};
484 499
485 500
486/*====================================================================================== 501/*======================================================================================
487 * OCiscoMonitoring 502 * OCiscoMonitoring
488 *======================================================================================*/ 503 *======================================================================================*/
489 504
490 505
491class OCiscoMonitoringInterface : public OMonitoringInterface 506class OCiscoMonitoringInterface : public OMonitoringInterface
492{ 507{
493 public: 508 public:
494 OCiscoMonitoringInterface( ONetworkInterface*, bool _prismHeader ); 509 OCiscoMonitoringInterface( ONetworkInterface*, bool _prismHeader );
495 virtual ~OCiscoMonitoringInterface(); 510 virtual ~OCiscoMonitoringInterface();
496 511
497 virtual void setEnabled( bool ); 512 virtual void setEnabled( bool );
498 virtual QString name() const; 513 virtual QString name() const;
499 virtual void setChannel( int ); 514 virtual void setChannel( int );
515 private:
516 class Private;
517 Private *d;
500 518
501}; 519};
502 520
503 521
504/*====================================================================================== 522/*======================================================================================
505 * OWlanNGMonitoringInterface 523 * OWlanNGMonitoringInterface
506 *======================================================================================*/ 524 *======================================================================================*/
507 525
508 526
509class OWlanNGMonitoringInterface : public OMonitoringInterface 527class OWlanNGMonitoringInterface : public OMonitoringInterface
510{ 528{
511 public: 529 public:
512 OWlanNGMonitoringInterface( ONetworkInterface*, bool _prismHeader ); 530 OWlanNGMonitoringInterface( ONetworkInterface*, bool _prismHeader );
513 virtual ~OWlanNGMonitoringInterface(); 531 virtual ~OWlanNGMonitoringInterface();
514 532
515 public: 533 public:
516 virtual void setEnabled( bool ); 534 virtual void setEnabled( bool );
517 virtual QString name() const; 535 virtual QString name() const;
518 virtual void setChannel( int ); 536 virtual void setChannel( int );
537 private:
538 class Private;
539 Private *d;
519 540
520}; 541};
521 542
522 543
523/*====================================================================================== 544/*======================================================================================
524 * OHostAPMonitoringInterface 545 * OHostAPMonitoringInterface
525 *======================================================================================*/ 546 *======================================================================================*/
526 547
527 548
528class OHostAPMonitoringInterface : public OMonitoringInterface 549class OHostAPMonitoringInterface : public OMonitoringInterface
529{ 550{
530 public: 551 public:
531 OHostAPMonitoringInterface( ONetworkInterface*, bool _prismHeader ); 552 OHostAPMonitoringInterface( ONetworkInterface*, bool _prismHeader );
532 virtual ~OHostAPMonitoringInterface(); 553 virtual ~OHostAPMonitoringInterface();
533 554
534 public: 555 public:
535 virtual void setEnabled( bool ); 556 virtual void setEnabled( bool );
536 virtual QString name() const; 557 virtual QString name() const;
558
559 private:
560 class Private;
561 Private *d;
537 }; 562 };
538 563
539 564
540/*====================================================================================== 565/*======================================================================================
541 * OOrinocoMonitoringInterface 566 * OOrinocoMonitoringInterface
542 *======================================================================================*/ 567 *======================================================================================*/
543 568
544 569
545class OOrinocoMonitoringInterface : public OMonitoringInterface 570class OOrinocoMonitoringInterface : public OMonitoringInterface
546{ 571{
547 public: 572 public:
548 OOrinocoMonitoringInterface( ONetworkInterface*, bool _prismHeader ); 573 OOrinocoMonitoringInterface( ONetworkInterface*, bool _prismHeader );
549 virtual ~OOrinocoMonitoringInterface(); 574 virtual ~OOrinocoMonitoringInterface();
550 575
551 public: 576 public:
552 virtual void setChannel( int ); 577 virtual void setChannel( int );
553 virtual void setEnabled( bool ); 578 virtual void setEnabled( bool );
554 virtual QString name() const; 579 virtual QString name() const;
555 580
581 private:
582 class Private;
583 Private *d;
556}; 584};
557 585
586}
587}
588
558#endif // ONETWORK_H 589#endif // ONETWORK_H
559 590
diff --git a/libopie2/opienet/opcap.cpp b/libopie2/opienet/opcap.cpp
index fdd519c..4081d4f 100644
--- a/libopie2/opienet/opcap.cpp
+++ b/libopie2/opienet/opcap.cpp
@@ -1,95 +1,100 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3              Copyright (C) 2003 by Michael 'Mickey' Lauer <mickey@Vanille.de> 3              Copyright (C) 2003 by Michael 'Mickey' Lauer <mickey@Vanille.de>
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 30
31/* OPIE */ 31/* OPIE */
32#include <opie2/opcap.h> 32#include <opie2/opcap.h>
33#include <opie2/odebug.h> 33#include <opie2/odebug.h>
34 34
35/* QT */ 35/* QT */
36#include <qapplication.h> // don't use oapplication here (will decrease reusability in other projects) 36#include <qapplication.h> // don't use oapplication here (will decrease reusability in other projects)
37#include <qsocketnotifier.h> 37#include <qsocketnotifier.h>
38#include <qobjectlist.h> 38#include <qobjectlist.h>
39 39
40/* SYSTEM */ 40/* SYSTEM */
41#include <sys/time.h> 41#include <sys/time.h>
42#include <sys/types.h> 42#include <sys/types.h>
43#include <unistd.h> 43#include <unistd.h>
44 44
45/* LOCAL */ 45/* LOCAL */
46#include "udp_ports.h" 46#include "udp_ports.h"
47 47
48using namespace Opie::Core;
49
50namespace Opie {
51namespace Net {
52
48/*====================================================================================== 53/*======================================================================================
49 * OPacket 54 * OPacket
50 *======================================================================================*/ 55 *======================================================================================*/
51 56
52OPacket::OPacket( int datalink, packetheaderstruct header, const unsigned char* data, QObject* parent ) 57OPacket::OPacket( int datalink, packetheaderstruct header, const unsigned char* data, QObject* parent )
53 :QObject( parent, "Generic" ), _hdr( header ), _data( data ) 58 :QObject( parent, "Generic" ), _hdr( header ), _data( data )
54{ 59{
55 //qDebug( "OPacket::OPacket(): (Len %d, CapLen %d)" /*, ctime((const time_t*) header.ts.tv_sec)*/, header.len, header.caplen ); 60 //qDebug( "OPacket::OPacket(): (Len %d, CapLen %d)" /*, ctime((const time_t*) header.ts.tv_sec)*/, header.len, header.caplen );
56 61
57 _end = (unsigned char*) data + header.len; 62 _end = (unsigned char*) data + header.len;
58 //qDebug( "OPacket::data @ %0x, end @ %0x", data, _end ); 63 //qDebug( "OPacket::data @ %0x, end @ %0x", data, _end );
59 64
60 switch ( datalink ) 65 switch ( datalink )
61 { 66 {
62 case DLT_EN10MB: 67 case DLT_EN10MB:
63 odebug << "OPacket::OPacket(): Received Packet. Datalink = ETHERNET" << oendl; 68 odebug << "OPacket::OPacket(): Received Packet. Datalink = ETHERNET" << oendl;
64 new OEthernetPacket( _end, (const struct ether_header*) data, this ); 69 new OEthernetPacket( _end, (const struct ether_header*) data, this );
65 break; 70 break;
66 71
67 case DLT_IEEE802_11: 72 case DLT_IEEE802_11:
68 odebug << "OPacket::OPacket(): Received Packet. Datalink = IEEE802.11" << oendl; 73 odebug << "OPacket::OPacket(): Received Packet. Datalink = IEEE802.11" << oendl;
69 new OWaveLanPacket( _end, (const struct ieee_802_11_header*) data, this ); 74 new OWaveLanPacket( _end, (const struct ieee_802_11_header*) data, this );
70 break; 75 break;
71 76
72 case DLT_PRISM_HEADER: 77 case DLT_PRISM_HEADER:
73 odebug << "OPacket::OPacket(): Received Packet. Datalink = PRISM_HEADER" << oendl; 78 odebug << "OPacket::OPacket(): Received Packet. Datalink = PRISM_HEADER" << oendl;
74 new OPrismHeaderPacket( _end, (const struct prism_hdr*) (unsigned char*) data, this ); 79 new OPrismHeaderPacket( _end, (const struct prism_hdr*) (unsigned char*) data, this );
75 break; 80 break;
76 81
77 default: 82 default:
78 owarn << "OPacket::OPacket(): Received Packet over unsupported datalink, type " << datalink << "!" << oendl; 83 owarn << "OPacket::OPacket(): Received Packet over unsupported datalink, type " << datalink << "!" << oendl;
79 } 84 }
80} 85}
81 86
82 87
83OPacket::~OPacket() 88OPacket::~OPacket()
84{ 89{
85} 90}
86 91
87 92
88timevalstruct OPacket::timeval() const 93timevalstruct OPacket::timeval() const
89{ 94{
90 return _hdr.ts; 95 return _hdr.ts;
91} 96}
92 97
93 98
94int OPacket::caplen() const 99int OPacket::caplen() const
95{ 100{
@@ -1299,49 +1304,50 @@ bool OPacketCapturer::open( const QFile& file )
1299 else 1304 else
1300 { 1305 {
1301 odebug << "OPacketCapturer::open(): can't open libpcap with '" << name << "': " << _errbuf << oendl; 1306 odebug << "OPacketCapturer::open(): can't open libpcap with '" << name << "': " << _errbuf << oendl;
1302 return false; 1307 return false;
1303 } 1308 }
1304 1309
1305} 1310}
1306 1311
1307 1312
1308bool OPacketCapturer::isOpen() const 1313bool OPacketCapturer::isOpen() const
1309{ 1314{
1310 return _open; 1315 return _open;
1311} 1316}
1312 1317
1313 1318
1314void OPacketCapturer::readyToReceive() 1319void OPacketCapturer::readyToReceive()
1315{ 1320{
1316 odebug << "OPacketCapturer::readyToReceive(): about to emit 'receivePacket(p)'" << oendl; 1321 odebug << "OPacketCapturer::readyToReceive(): about to emit 'receivePacket(p)'" << oendl;
1317 OPacket* p = next(); 1322 OPacket* p = next();
1318 emit receivedPacket( p ); 1323 emit receivedPacket( p );
1319 // emit is synchronous - packet has been dealt with, now it's safe to delete 1324 // emit is synchronous - packet has been dealt with, now it's safe to delete
1320 delete p; 1325 delete p;
1321} 1326}
1322 1327
1323 1328
1324const QMap<QString,int>& OPacketCapturer::statistics() const 1329const QMap<QString,int>& OPacketCapturer::statistics() const
1325{ 1330{
1326 return _stats; 1331 return _stats;
1327} 1332}
1328 1333
1329 1334
1330int OPacketCapturer::snapShot() const 1335int OPacketCapturer::snapShot() const
1331{ 1336{
1332 return pcap_snapshot( _pch ); 1337 return pcap_snapshot( _pch );
1333} 1338}
1334 1339
1335 1340
1336bool OPacketCapturer::swapped() const 1341bool OPacketCapturer::swapped() const
1337{ 1342{
1338 return pcap_is_swapped( _pch ); 1343 return pcap_is_swapped( _pch );
1339} 1344}
1340 1345
1341 1346
1342QString OPacketCapturer::version() const 1347QString OPacketCapturer::version() const
1343{ 1348{
1344 return QString().sprintf( "%d.%d", pcap_major_version( _pch ), pcap_minor_version( _pch ) ); 1349 return QString().sprintf( "%d.%d", pcap_major_version( _pch ), pcap_minor_version( _pch ) );
1345} 1350}
1346 1351
1347 1352}
1353}
diff --git a/libopie2/opienet/opcap.h b/libopie2/opienet/opcap.h
index b873b49..dc609a3 100644
--- a/libopie2/opienet/opcap.h
+++ b/libopie2/opienet/opcap.h
@@ -19,577 +19,623 @@
19..}^=.=       =       ; Library General Public License for more 19..}^=.=       =       ; Library General Public License for more
20++=   -.     .`     .: details. 20++=   -.     .`     .: details.
21 :     =  ...= . :.=- 21 :     =  ...= . :.=-
22 -.   .:....=;==+<; You should have received a copy of the GNU 22 -.   .:....=;==+<; You should have received a copy of the GNU
23  -_. . .   )=.  = Library General Public License along with 23  -_. . .   )=.  = Library General Public License along with
24    --        :-=` this library; see the file COPYING.LIB. 24    --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28 28
29*/ 29*/
30 30
31#ifndef OPCAP_H 31#ifndef OPCAP_H
32#define OPCAP_H 32#define OPCAP_H
33 33
34/* OPIE */ 34/* OPIE */
35#include <opie2/onetutils.h> 35#include <opie2/onetutils.h>
36 36
37/* QT */ 37/* QT */
38#include <qevent.h> 38#include <qevent.h>
39#include <qfile.h> 39#include <qfile.h>
40#include <qhostaddress.h> 40#include <qhostaddress.h>
41#include <qobject.h> 41#include <qobject.h>
42#include <qstring.h> 42#include <qstring.h>
43#include <qtextstream.h> 43#include <qtextstream.h>
44#include <qmap.h> 44#include <qmap.h>
45 45
46/* STD */ 46/* STD */
47extern "C" // work around a bpf/pcap conflict in recent headers 47extern "C" // work around a bpf/pcap conflict in recent headers
48{ 48{
49 #include <pcap.h> 49 #include <pcap.h>
50} 50}
51#include <netinet/ether.h> 51#include <netinet/ether.h>
52#include <netinet/ip.h> 52#include <netinet/ip.h>
53#include <netinet/udp.h> 53#include <netinet/udp.h>
54#include <netinet/tcp.h> 54#include <netinet/tcp.h>
55#include <time.h> 55#include <time.h>
56 56
57/* Custom Network Includes (must go here, don't reorder!) */ 57/* Custom Network Includes (must go here, don't reorder!) */
58#include "802_11_user.h" 58#include "802_11_user.h"
59#include "dhcp.h" 59#include "dhcp.h"
60 60
61 61
62/* TYPEDEFS */ 62/* TYPEDEFS */
63typedef struct timeval timevalstruct; 63typedef struct timeval timevalstruct;
64typedef struct pcap_pkthdr packetheaderstruct; 64typedef struct pcap_pkthdr packetheaderstruct;
65 65
66/* FORWARDS */ 66/* FORWARDS */
67class OPacketCapturer;
68class QSocketNotifier; 67class QSocketNotifier;
68namespace Opie {
69namespace Net {
70class OPacketCapturer;
69 71
70/*====================================================================================== 72/*======================================================================================
71 * OPacket - A frame on the wire 73 * OPacket - A frame on the wire
72 *======================================================================================*/ 74 *======================================================================================*/
73 75
74/** @brief A class representing a data frame on the wire. 76/** @brief A class representing a data frame on the wire.
75 * 77 *
76 * The whole family of the packet classes are used when capturing frames from a network. 78 * The whole family of the packet classes are used when capturing frames from a network.
77 * Most standard network protocols in use share a common architecture, which mostly is 79 * Most standard network protocols in use share a common architecture, which mostly is
78 * a packet header and then the packet payload. In layered architectures, each lower layer 80 * a packet header and then the packet payload. In layered architectures, each lower layer
79 * encapsulates data from its upper layer - that is it 81 * encapsulates data from its upper layer - that is it
80 * treats the data from its upper layer as payload and prepends an own header to the packet, 82 * treats the data from its upper layer as payload and prepends an own header to the packet,
81 * which - again - is treated as the payload for the layer below. The figure below is an 83 * which - again - is treated as the payload for the layer below. The figure below is an
82 * example for how such a data frame is composed out of packets, e.g. when sending a mail. 84 * example for how such a data frame is composed out of packets, e.g. when sending a mail.
83 * 85 *
84 * <pre> 86 * <pre>
85 * | User Data | == Mail Data 87 * | User Data | == Mail Data
86 * | SMTP Header | User Data | == SMTP 88 * | SMTP Header | User Data | == SMTP
87 * | TCP Header | SMTP Header | User Data | == TCP 89 * | TCP Header | SMTP Header | User Data | == TCP
88 * | IP Header | TCP Header | SMTP Header | User Data | == IP 90 * | IP Header | TCP Header | SMTP Header | User Data | == IP
89 * | MAC Header | IP Header | TCP Header | SMTP Header | User Data | == MAC 91 * | MAC Header | IP Header | TCP Header | SMTP Header | User Data | == MAC
90 * 92 *
91 * </pre> 93 * </pre>
92 * 94 *
93 * The example is trimmed for simplicity, because the MAC (Medium Access Control) layer 95 * The example is trimmed for simplicity, because the MAC (Medium Access Control) layer
94 * also contains a few more levels of encapsulation. 96 * also contains a few more levels of encapsulation.
95 * Since the type of the payload is more or less independent from the encapsulating protocol, 97 * Since the type of the payload is more or less independent from the encapsulating protocol,
96 * the header must be inspected before attempting to decode the payload. Hence, the 98 * the header must be inspected before attempting to decode the payload. Hence, the
97 * encapsulation level varies and can't be deduced without actually looking into the packets. 99 * encapsulation level varies and can't be deduced without actually looking into the packets.
98 * 100 *
99 * For actually working with captured frames, it's useful to identify the packets via names and 101 * For actually working with captured frames, it's useful to identify the packets via names and
100 * insert them into a parent/child - relationship based on the encapsulation. This is why 102 * insert them into a parent/child - relationship based on the encapsulation. This is why
101 * all packet classes derive from QObject. The amount of overhead caused by the QObject is 103 * all packet classes derive from QObject. The amount of overhead caused by the QObject is
102 * not a problem in this case, because we're talking about a theoratical maximum of about 104 * not a problem in this case, because we're talking about a theoratical maximum of about
103 * 10 packets per captured frame. We need to stuff them into a searchable list anyway and the 105 * 10 packets per captured frame. We need to stuff them into a searchable list anyway and the
104 * QObject also cares about destroying the sub-, (child-) packets. 106 * QObject also cares about destroying the sub-, (child-) packets.
105 * 107 *
106 * This enables us to perform a simple look for packets of a certain type: 108 * This enables us to perform a simple look for packets of a certain type:
107 * @code 109 * @code
108 * OPacketCapturer* pcap = new OPacketCapturer(); 110 * OPacketCapturer* pcap = new OPacketCapturer();
109 * pcap->open( "eth0" ); 111 * pcap->open( "eth0" );
110 * OPacket* p = pcap->next(); 112 * OPacket* p = pcap->next();
111 * OIPPacket* ip = (OIPPacket*) p->child( "IP" ); // returns 0, if no such child exists 113 * OIPPacket* ip = (OIPPacket*) p->child( "IP" ); // returns 0, if no such child exists
112 * odebug << "got ip packet from " << ip->fromIPAddress().toString() << " to " << ip->toIPAddress().toString() << oendl; 114 * odebug << "got ip packet from " << ip->fromIPAddress().toString() << " to " << ip->toIPAddress().toString() << oendl;
113 * 115 *
114 */ 116 */
115 117
116class OPacket : public QObject 118class OPacket : public QObject
117{ 119{
118 Q_OBJECT 120 Q_OBJECT
119 121
120 friend class OPacketCapturer; 122 friend class OPacketCapturer;
121 friend QTextStream& operator<<( QTextStream& s, const OPacket& p ); 123 friend QTextStream& operator<<( QTextStream& s, const OPacket& p );
122 124
123 public: 125 public:
124 OPacket( int datalink, packetheaderstruct, const unsigned char*, QObject* parent ); 126 OPacket( int datalink, packetheaderstruct, const unsigned char*, QObject* parent );
125 virtual ~OPacket(); 127 virtual ~OPacket();
126 128
127 timevalstruct timeval() const; 129 timevalstruct timeval() const;
128 130
129 int caplen() const; 131 int caplen() const;
130 int len() const; 132 int len() const;
131 QString dump( int = 32 ) const; 133 QString dump( int = 32 ) const;
132 134
133 void updateStats( QMap<QString,int>&, QObjectList* ); 135 void updateStats( QMap<QString,int>&, QObjectList* );
134 136
135 private: 137 private:
136 138
137 QString dumpStructure() const; 139 QString dumpStructure() const;
138 QString _dumpStructure( QObjectList* ) const; 140 QString _dumpStructure( QObjectList* ) const;
139 141
140 private: 142 private:
141 const packetheaderstruct _hdr; // pcap packet header 143 const packetheaderstruct _hdr; // pcap packet header
142 const unsigned char* _data; // pcap packet data 144 const unsigned char* _data; // pcap packet data
143 const unsigned char* _end; // end of pcap packet data 145 const unsigned char* _end; // end of pcap packet data
146 private:
147 class Private;
148 Private *d;
144}; 149};
145 150
146QTextStream& operator<<( QTextStream& s, const OPacket& p ); 151QTextStream& operator<<( QTextStream& s, const OPacket& p );
147 152
148/*====================================================================================== 153/*======================================================================================
149 * OEthernetPacket - DLT_EN10MB frame 154 * OEthernetPacket - DLT_EN10MB frame
150 *======================================================================================*/ 155 *======================================================================================*/
151 156
152class OEthernetPacket : public QObject 157class OEthernetPacket : public QObject
153{ 158{
154 Q_OBJECT 159 Q_OBJECT
155 160
156 public: 161 public:
157 OEthernetPacket( const unsigned char*, const struct ether_header*, QObject* parent = 0 ); 162 OEthernetPacket( const unsigned char*, const struct ether_header*, QObject* parent = 0 );
158 virtual ~OEthernetPacket(); 163 virtual ~OEthernetPacket();
159 164
160 OMacAddress sourceAddress() const; 165 OMacAddress sourceAddress() const;
161 OMacAddress destinationAddress() const; 166 OMacAddress destinationAddress() const;
162 int type() const; 167 int type() const;
163 168
164 private: 169 private:
165 const struct ether_header* _ether; 170 const struct ether_header* _ether;
171 private:
172 class Private;
173 Private *d;
166}; 174};
167 175
168/*====================================================================================== 176/*======================================================================================
169 * OPrismHeaderPacket - DLT_PRISM_HEADER frame 177 * OPrismHeaderPacket - DLT_PRISM_HEADER frame
170 *======================================================================================*/ 178 *======================================================================================*/
171 179
172class OPrismHeaderPacket : public QObject 180class OPrismHeaderPacket : public QObject
173{ 181{
174 Q_OBJECT 182 Q_OBJECT
175 183
176 public: 184 public:
177 OPrismHeaderPacket( const unsigned char*, const struct prism_hdr*, QObject* parent = 0 ); 185 OPrismHeaderPacket( const unsigned char*, const struct prism_hdr*, QObject* parent = 0 );
178 virtual ~OPrismHeaderPacket(); 186 virtual ~OPrismHeaderPacket();
179 187
180 unsigned int signalStrength() const; 188 unsigned int signalStrength() const;
181 189
182 private: 190 private:
183 const struct prism_hdr* _header; 191 const struct prism_hdr* _header;
192 class Private;
193 Private *d;
184}; 194};
185 195
186/*====================================================================================== 196/*======================================================================================
187 * OWaveLanPacket - DLT_IEEE802_11 frame 197 * OWaveLanPacket - DLT_IEEE802_11 frame
188 *======================================================================================*/ 198 *======================================================================================*/
189 199
190class OWaveLanPacket : public QObject 200class OWaveLanPacket : public QObject
191{ 201{
192 Q_OBJECT 202 Q_OBJECT
193 203
194 public: 204 public:
195 OWaveLanPacket( const unsigned char*, const struct ieee_802_11_header*, QObject* parent = 0 ); 205 OWaveLanPacket( const unsigned char*, const struct ieee_802_11_header*, QObject* parent = 0 );
196 virtual ~OWaveLanPacket(); 206 virtual ~OWaveLanPacket();
197 207
198 int duration() const; 208 int duration() const;
199 bool fromDS() const; 209 bool fromDS() const;
200 bool toDS() const; 210 bool toDS() const;
201 virtual OMacAddress macAddress1() const; 211 virtual OMacAddress macAddress1() const;
202 virtual OMacAddress macAddress2() const; 212 virtual OMacAddress macAddress2() const;
203 virtual OMacAddress macAddress3() const; 213 virtual OMacAddress macAddress3() const;
204 virtual OMacAddress macAddress4() const; 214 virtual OMacAddress macAddress4() const;
205 bool usesPowerManagement() const; 215 bool usesPowerManagement() const;
206 int type() const; 216 int type() const;
207 int subType() const; 217 int subType() const;
208 int version() const; 218 int version() const;
209 bool usesWep() const; 219 bool usesWep() const;
210 220
211 private: 221 private:
212 const struct ieee_802_11_header* _wlanhdr; 222 const struct ieee_802_11_header* _wlanhdr;
223 class Private;
224 Private *d;
213}; 225};
214 226
215 227
216/*====================================================================================== 228/*======================================================================================
217 * OWaveLanManagementPacket - type: management (T_MGMT) 229 * OWaveLanManagementPacket - type: management (T_MGMT)
218 *======================================================================================*/ 230 *======================================================================================*/
219 231
220class OWaveLanManagementPacket : public QObject 232class OWaveLanManagementPacket : public QObject
221{ 233{
222 Q_OBJECT 234 Q_OBJECT
223 235
224 public: 236 public:
225 OWaveLanManagementPacket( const unsigned char*, const struct ieee_802_11_mgmt_header*, OWaveLanPacket* parent = 0 ); 237 OWaveLanManagementPacket( const unsigned char*, const struct ieee_802_11_mgmt_header*, OWaveLanPacket* parent = 0 );
226 virtual ~OWaveLanManagementPacket(); 238 virtual ~OWaveLanManagementPacket();
227 239
228 QString managementType() const; 240 QString managementType() const;
229 241
230 int beaconInterval() const; 242 int beaconInterval() const;
231 int capabilities() const; // generic 243 int capabilities() const; // generic
232 244
233 bool canESS() const; 245 bool canESS() const;
234 bool canIBSS() const; 246 bool canIBSS() const;
235 bool canCFP() const; 247 bool canCFP() const;
236 bool canCFP_REQ() const; 248 bool canCFP_REQ() const;
237 bool canPrivacy() const; 249 bool canPrivacy() const;
238 250
239 private: 251 private:
240 const struct ieee_802_11_mgmt_header* _header; 252 const struct ieee_802_11_mgmt_header* _header;
241 const struct ieee_802_11_mgmt_body* _body; 253 const struct ieee_802_11_mgmt_body* _body;
254 class Private;
255 Private *d;
242}; 256};
243 257
244 258
245/*====================================================================================== 259/*======================================================================================
246 * OWaveLanManagementSSID 260 * OWaveLanManagementSSID
247 *======================================================================================*/ 261 *======================================================================================*/
248 262
249class OWaveLanManagementSSID : public QObject 263class OWaveLanManagementSSID : public QObject
250{ 264{
251 Q_OBJECT 265 Q_OBJECT
252 266
253 public: 267 public:
254 OWaveLanManagementSSID( const unsigned char*, const struct ssid_t*, QObject* parent = 0 ); 268 OWaveLanManagementSSID( const unsigned char*, const struct ssid_t*, QObject* parent = 0 );
255 virtual ~OWaveLanManagementSSID(); 269 virtual ~OWaveLanManagementSSID();
256 270
257 QString ID( bool decloak = false ) const; 271 QString ID( bool decloak = false ) const;
258 272
259 private: 273 private:
260 const struct ssid_t* _data; 274 const struct ssid_t* _data;
275 class Private;
276 Private *d;
261}; 277};
262 278
263/*====================================================================================== 279/*======================================================================================
264 * OWaveLanManagementRates 280 * OWaveLanManagementRates
265 *======================================================================================*/ 281 *======================================================================================*/
266 282
267class OWaveLanManagementRates : public QObject 283class OWaveLanManagementRates : public QObject
268{ 284{
269 Q_OBJECT 285 Q_OBJECT
270 286
271 public: 287 public:
272 OWaveLanManagementRates( const unsigned char*, const struct rates_t*, QObject* parent = 0 ); 288 OWaveLanManagementRates( const unsigned char*, const struct rates_t*, QObject* parent = 0 );
273 virtual ~OWaveLanManagementRates(); 289 virtual ~OWaveLanManagementRates();
274 290
275 private: 291 private:
276 const struct rates_t* _data; 292 const struct rates_t* _data;
293 class Private;
294 Private *d;
277}; 295};
278 296
279/*====================================================================================== 297/*======================================================================================
280 * OWaveLanManagementCF 298 * OWaveLanManagementCF
281 *======================================================================================*/ 299 *======================================================================================*/
282 300
283class OWaveLanManagementCF : public QObject 301class OWaveLanManagementCF : public QObject
284{ 302{
285 Q_OBJECT 303 Q_OBJECT
286 304
287 public: 305 public:
288 OWaveLanManagementCF( const unsigned char*, const struct cf_t*, QObject* parent = 0 ); 306 OWaveLanManagementCF( const unsigned char*, const struct cf_t*, QObject* parent = 0 );
289 virtual ~OWaveLanManagementCF(); 307 virtual ~OWaveLanManagementCF();
290 308
291 private: 309 private:
292 const struct cf_t* _data; 310 const struct cf_t* _data;
311 class Private;
312 Private *d;
293}; 313};
294 314
295/*====================================================================================== 315/*======================================================================================
296 * OWaveLanManagementFH 316 * OWaveLanManagementFH
297 *======================================================================================*/ 317 *======================================================================================*/
298 318
299class OWaveLanManagementFH : public QObject 319class OWaveLanManagementFH : public QObject
300{ 320{
301 Q_OBJECT 321 Q_OBJECT
302 322
303 public: 323 public:
304 OWaveLanManagementFH( const unsigned char*, const struct fh_t*, QObject* parent = 0 ); 324 OWaveLanManagementFH( const unsigned char*, const struct fh_t*, QObject* parent = 0 );
305 virtual ~OWaveLanManagementFH(); 325 virtual ~OWaveLanManagementFH();
306 326
307 private: 327 private:
308 const struct fh_t* _data; 328 const struct fh_t* _data;
329 class Private;
330 Private *d;
309}; 331};
310 332
311/*====================================================================================== 333/*======================================================================================
312 * OWaveLanManagementDS 334 * OWaveLanManagementDS
313 *======================================================================================*/ 335 *======================================================================================*/
314 336
315class OWaveLanManagementDS : public QObject 337class OWaveLanManagementDS : public QObject
316{ 338{
317 Q_OBJECT 339 Q_OBJECT
318 340
319 public: 341 public:
320 OWaveLanManagementDS( const unsigned char*, const struct ds_t*, QObject* parent = 0 ); 342 OWaveLanManagementDS( const unsigned char*, const struct ds_t*, QObject* parent = 0 );
321 virtual ~OWaveLanManagementDS(); 343 virtual ~OWaveLanManagementDS();
322 344
323 int channel() const; 345 int channel() const;
324 346
325 private: 347 private:
326 const struct ds_t* _data; 348 const struct ds_t* _data;
349 class Private;
350 Private *d;
327}; 351};
328 352
329/*====================================================================================== 353/*======================================================================================
330 * OWaveLanManagementTim 354 * OWaveLanManagementTim
331 *======================================================================================*/ 355 *======================================================================================*/
332 356
333class OWaveLanManagementTim : public QObject 357class OWaveLanManagementTim : public QObject
334{ 358{
335 Q_OBJECT 359 Q_OBJECT
336 360
337 public: 361 public:
338 OWaveLanManagementTim( const unsigned char*, const struct tim_t*, QObject* parent = 0 ); 362 OWaveLanManagementTim( const unsigned char*, const struct tim_t*, QObject* parent = 0 );
339 virtual ~OWaveLanManagementTim(); 363 virtual ~OWaveLanManagementTim();
340 364
341 private: 365 private:
342 const struct tim_t* _data; 366 const struct tim_t* _data;
367 class Private;
368 Private *d;
343}; 369};
344 370
345/*====================================================================================== 371/*======================================================================================
346 * OWaveLanManagementIBSS 372 * OWaveLanManagementIBSS
347 *======================================================================================*/ 373 *======================================================================================*/
348 374
349class OWaveLanManagementIBSS : public QObject 375class OWaveLanManagementIBSS : public QObject
350{ 376{
351 Q_OBJECT 377 Q_OBJECT
352 378
353 public: 379 public:
354 OWaveLanManagementIBSS( const unsigned char*, const struct ibss_t*, QObject* parent = 0 ); 380 OWaveLanManagementIBSS( const unsigned char*, const struct ibss_t*, QObject* parent = 0 );
355 virtual ~OWaveLanManagementIBSS(); 381 virtual ~OWaveLanManagementIBSS();
356 382
357 private: 383 private:
358 const struct ibss_t* _data; 384 const struct ibss_t* _data;
385 class Private;
386 Private *d;
359}; 387};
360 388
361/*====================================================================================== 389/*======================================================================================
362 * OWaveLanManagementChallenge 390 * OWaveLanManagementChallenge
363 *======================================================================================*/ 391 *======================================================================================*/
364 392
365class OWaveLanManagementChallenge : public QObject 393class OWaveLanManagementChallenge : public QObject
366{ 394{
367 Q_OBJECT 395 Q_OBJECT
368 396
369 public: 397 public:
370 OWaveLanManagementChallenge( const unsigned char*, const struct challenge_t*, QObject* parent = 0 ); 398 OWaveLanManagementChallenge( const unsigned char*, const struct challenge_t*, QObject* parent = 0 );
371 virtual ~OWaveLanManagementChallenge(); 399 virtual ~OWaveLanManagementChallenge();
372 400
373 private: 401 private:
374 const struct challenge_t* _data; 402 const struct challenge_t* _data;
403 class Private;
404 Private *d;
375}; 405};
376 406
377/*====================================================================================== 407/*======================================================================================
378 * OWaveLanDataPacket - type: data (T_DATA) 408 * OWaveLanDataPacket - type: data (T_DATA)
379 *======================================================================================*/ 409 *======================================================================================*/
380 410
381class OWaveLanDataPacket : public QObject 411class OWaveLanDataPacket : public QObject
382{ 412{
383 Q_OBJECT 413 Q_OBJECT
384 414
385 public: 415 public:
386 OWaveLanDataPacket( const unsigned char*, const struct ieee_802_11_data_header*, OWaveLanPacket* parent = 0 ); 416 OWaveLanDataPacket( const unsigned char*, const struct ieee_802_11_data_header*, OWaveLanPacket* parent = 0 );
387 virtual ~OWaveLanDataPacket(); 417 virtual ~OWaveLanDataPacket();
388 418
389 private: 419 private:
390 const struct ieee_802_11_data_header* _header; 420 const struct ieee_802_11_data_header* _header;
421 class Private;
422 Private *d;
391}; 423};
392 424
393/*====================================================================================== 425/*======================================================================================
394 * OWaveLanControlPacket - type: control (T_CTRL) 426 * OWaveLanControlPacket - type: control (T_CTRL)
395 *======================================================================================*/ 427 *======================================================================================*/
396 428
397class OWaveLanControlPacket : public QObject 429class OWaveLanControlPacket : public QObject
398{ 430{
399 Q_OBJECT 431 Q_OBJECT
400 432
401 public: 433 public:
402 OWaveLanControlPacket( const unsigned char*, const struct ieee_802_11_control_header*, OWaveLanPacket* parent = 0 ); 434 OWaveLanControlPacket( const unsigned char*, const struct ieee_802_11_control_header*, OWaveLanPacket* parent = 0 );
403 virtual ~OWaveLanControlPacket(); 435 virtual ~OWaveLanControlPacket();
404 436
405 QString controlType() const; 437 QString controlType() const;
406 438
407 private: 439 private:
408 const struct ieee_802_11_control_header* _header; 440 const struct ieee_802_11_control_header* _header;
441 class Private;
442 Private *d;
409}; 443};
410 444
411/*====================================================================================== 445/*======================================================================================
412 * OLLCPacket - IEEE 802.2 Link Level Control 446 * OLLCPacket - IEEE 802.2 Link Level Control
413 *======================================================================================*/ 447 *======================================================================================*/
414 448
415class OLLCPacket : public QObject 449class OLLCPacket : public QObject
416{ 450{
417 Q_OBJECT 451 Q_OBJECT
418 452
419 public: 453 public:
420 OLLCPacket( const unsigned char*, const struct ieee_802_11_802_2_header* data, QObject* parent = 0 ); 454 OLLCPacket( const unsigned char*, const struct ieee_802_11_802_2_header* data, QObject* parent = 0 );
421 virtual ~OLLCPacket(); 455 virtual ~OLLCPacket();
422 456
423 private: 457 private:
424 const struct ieee_802_11_802_2_header* _header; 458 const struct ieee_802_11_802_2_header* _header;
459 class Private;
460 Private *d;
425}; 461};
426 462
427/*====================================================================================== 463/*======================================================================================
428 * OIPPacket 464 * OIPPacket
429 *======================================================================================*/ 465 *======================================================================================*/
430 466
431class OIPPacket : public QObject 467class OIPPacket : public QObject
432{ 468{
433 Q_OBJECT 469 Q_OBJECT
434 470
435 public: 471 public:
436 OIPPacket( const unsigned char*, const struct iphdr*, QObject* parent = 0 ); 472 OIPPacket( const unsigned char*, const struct iphdr*, QObject* parent = 0 );
437 virtual ~OIPPacket(); 473 virtual ~OIPPacket();
438 474
439 QHostAddress fromIPAddress() const; 475 QHostAddress fromIPAddress() const;
440 QHostAddress toIPAddress() const; 476 QHostAddress toIPAddress() const;
441 477
442 int tos() const; 478 int tos() const;
443 int len() const; 479 int len() const;
444 int id() const; 480 int id() const;
445 int offset() const; 481 int offset() const;
446 int ttl() const; 482 int ttl() const;
447 int protocol() const; 483 int protocol() const;
448 int checksum() const; 484 int checksum() const;
449 485
450 private: 486 private:
451 const struct iphdr* _iphdr; 487 const struct iphdr* _iphdr;
488 class Private;
489 Private *d;
452}; 490};
453 491
454/*====================================================================================== 492/*======================================================================================
455 * OARPPacket 493 * OARPPacket
456 *======================================================================================*/ 494 *======================================================================================*/
457 495
458class OARPPacket : public QObject 496class OARPPacket : public QObject
459{ 497{
460 Q_OBJECT 498 Q_OBJECT
461 499
462 public: 500 public:
463 OARPPacket( const unsigned char*, const struct myarphdr*, QObject* parent = 0 ); 501 OARPPacket( const unsigned char*, const struct myarphdr*, QObject* parent = 0 );
464 virtual ~OARPPacket(); 502 virtual ~OARPPacket();
465 503
466 QHostAddress senderIPV4Address() const; 504 QHostAddress senderIPV4Address() const;
467 OMacAddress senderMacAddress() const; 505 OMacAddress senderMacAddress() const;
468 QHostAddress targetIPV4Address() const; 506 QHostAddress targetIPV4Address() const;
469 OMacAddress targetMacAddress() const; 507 OMacAddress targetMacAddress() const;
470 508
471 //int type() const; 509 //int type() const;
472 QString type() const; 510 QString type() const;
473 511
474 private: 512 private:
475 const struct myarphdr* _arphdr; 513 const struct myarphdr* _arphdr;
514 class Private;
515 Private *d;
476}; 516};
477 517
478/*====================================================================================== 518/*======================================================================================
479 * OUDPPacket 519 * OUDPPacket
480 *======================================================================================*/ 520 *======================================================================================*/
481 521
482class OUDPPacket : public QObject 522class OUDPPacket : public QObject
483{ 523{
484 Q_OBJECT 524 Q_OBJECT
485 525
486 public: 526 public:
487 OUDPPacket( const unsigned char*, const struct udphdr*, QObject* parent = 0 ); 527 OUDPPacket( const unsigned char*, const struct udphdr*, QObject* parent = 0 );
488 virtual ~OUDPPacket(); 528 virtual ~OUDPPacket();
489 529
490 int fromPort() const; 530 int fromPort() const;
491 int toPort() const; 531 int toPort() const;
492 int length() const; 532 int length() const;
493 int checksum() const; 533 int checksum() const;
494 534
495 private: 535 private:
496 const struct udphdr* _udphdr; 536 const struct udphdr* _udphdr;
537 class Private;
538 Private *d;
497}; 539};
498 540
499/*====================================================================================== 541/*======================================================================================
500 * ODHCPPacket 542 * ODHCPPacket
501 *======================================================================================*/ 543 *======================================================================================*/
502 544
503class ODHCPPacket : public QObject 545class ODHCPPacket : public QObject
504{ 546{
505 Q_OBJECT 547 Q_OBJECT
506 548
507 public: 549 public:
508 ODHCPPacket( const unsigned char*, const struct dhcp_packet*, QObject* parent = 0 ); 550 ODHCPPacket( const unsigned char*, const struct dhcp_packet*, QObject* parent = 0 );
509 virtual ~ODHCPPacket(); 551 virtual ~ODHCPPacket();
510 552
511 QHostAddress clientAddress() const; 553 QHostAddress clientAddress() const;
512 QHostAddress yourAddress() const; 554 QHostAddress yourAddress() const;
513 QHostAddress serverAddress() const; 555 QHostAddress serverAddress() const;
514 QHostAddress relayAddress() const; 556 QHostAddress relayAddress() const;
515 557
516 OMacAddress clientMacAddress() const; 558 OMacAddress clientMacAddress() const;
517 559
518 bool isRequest() const; 560 bool isRequest() const;
519 bool isReply() const; 561 bool isReply() const;
520 QString type() const; 562 QString type() const;
521 563
522 private: 564 private:
523 const struct dhcp_packet* _dhcphdr; 565 const struct dhcp_packet* _dhcphdr;
524 unsigned char _type; 566 unsigned char _type;
567 class Private;
568 Private *d;
525}; 569};
526 570
527/*====================================================================================== 571/*======================================================================================
528 * OTCPPacket 572 * OTCPPacket
529 *======================================================================================*/ 573 *======================================================================================*/
530 574
531class OTCPPacket : public QObject 575class OTCPPacket : public QObject
532{ 576{
533 Q_OBJECT 577 Q_OBJECT
534 578
535 public: 579 public:
536 OTCPPacket( const unsigned char*, const struct tcphdr*, QObject* parent = 0 ); 580 OTCPPacket( const unsigned char*, const struct tcphdr*, QObject* parent = 0 );
537 virtual ~OTCPPacket(); 581 virtual ~OTCPPacket();
538 582
539 int fromPort() const; 583 int fromPort() const;
540 int toPort() const; 584 int toPort() const;
541 int seq() const; 585 int seq() const;
542 int ack() const; 586 int ack() const;
543 int window() const; 587 int window() const;
544 int checksum() const; 588 int checksum() const;
545 589
546 private: 590 private:
547 const struct tcphdr* _tcphdr; 591 const struct tcphdr* _tcphdr;
592 class Private;
593 Private *d;
548}; 594};
549 595
550 596
551/*====================================================================================== 597/*======================================================================================
552 * OPacketCapturer 598 * OPacketCapturer
553 *======================================================================================*/ 599 *======================================================================================*/
554 600
555/** 601/**
556 * @brief A class based wrapper for network packet capturing. 602 * @brief A class based wrapper for network packet capturing.
557 * 603 *
558 * This class is the base of a high-level interface to the well known packet capturing 604 * This class is the base of a high-level interface to the well known packet capturing
559 * library libpcap. 605 * library libpcap.
560 * @see http://tcpdump.org 606 * @see http://tcpdump.org
561 */ 607 */
562class OPacketCapturer : public QObject 608class OPacketCapturer : public QObject
563{ 609{
564 Q_OBJECT 610 Q_OBJECT
565 611
566 public: 612 public:
567 /** 613 /**
568 * Constructor. 614 * Constructor.
569 */ 615 */
570 OPacketCapturer( QObject* parent = 0, const char* name = 0 ); 616 OPacketCapturer( QObject* parent = 0, const char* name = 0 );
571 /** 617 /**
572 * Destructor. 618 * Destructor.
573 */ 619 */
574 ~OPacketCapturer(); 620 ~OPacketCapturer();
575 /** 621 /**
576 * Set the packet capturer to use blocking or non-blocking IO. This can be useful when 622 * Set the packet capturer to use blocking or non-blocking IO. This can be useful when
577 * not using the socket notifier, e.g. without an application object. 623 * not using the socket notifier, e.g. without an application object.
578 */ 624 */
579 void setBlocking( bool ); 625 void setBlocking( bool );
580 /** 626 /**
581 * @returns true if the packet capturer uses blocking IO calls. 627 * @returns true if the packet capturer uses blocking IO calls.
582 */ 628 */
583 bool blocking() const; 629 bool blocking() const;
584 /** 630 /**
585 * Close the packet capturer. This is automatically done in the destructor. 631 * Close the packet capturer. This is automatically done in the destructor.
586 */ 632 */
587 void close(); 633 void close();
588 /** 634 /**
589 * Close the output capture file. 635 * Close the output capture file.
590 */ 636 */
591 void closeDumpFile(); 637 void closeDumpFile();
592 /** 638 /**
593 * @returns the data link type. 639 * @returns the data link type.
594 * @see <pcap.h> for possible values. 640 * @see <pcap.h> for possible values.
595 */ 641 */
@@ -620,52 +666,56 @@ class OPacketCapturer : public QObject
620 /** 666 /**
621 * Open the packet capturer to capture packets in offline-mode from @a file. 667 * Open the packet capturer to capture packets in offline-mode from @a file.
622 */ 668 */
623 bool open( const QFile& file ); 669 bool open( const QFile& file );
624 /** 670 /**
625 * Open a prerecorded tcpdump compatible capture file for use with @ref dump() 671 * Open a prerecorded tcpdump compatible capture file for use with @ref dump()
626 */ 672 */
627 bool openDumpFile( const QString& filename ); 673 bool openDumpFile( const QString& filename );
628 /** 674 /**
629 * @returns true if the packet capturer is open 675 * @returns true if the packet capturer is open
630 */ 676 */
631 bool isOpen() const; 677 bool isOpen() const;
632 /** 678 /**
633 * @returns the snapshot length of this packet capturer 679 * @returns the snapshot length of this packet capturer
634 */ 680 */
635 int snapShot() const; 681 int snapShot() const;
636 /** 682 /**
637 * @returns true if the input capture file has a different byte-order 683 * @returns true if the input capture file has a different byte-order
638 * than the byte-order of the running system. 684 * than the byte-order of the running system.
639 */ 685 */
640 bool swapped() const; 686 bool swapped() const;
641 /** 687 /**
642 * @returns the libpcap version string used to write the input capture file. 688 * @returns the libpcap version string used to write the input capture file.
643 */ 689 */
644 QString version() const; 690 QString version() const;
645 /** 691 /**
646 * @returns the packet statistic database. 692 * @returns the packet statistic database.
647 * @see QMap 693 * @see QMap
648 */ 694 */
649 const QMap<QString,int>& statistics() const; 695 const QMap<QString,int>& statistics() const;
650 696
651 signals: 697 signals:
652 /** 698 /**
653 * This signal is emitted, when a packet has been received. 699 * This signal is emitted, when a packet has been received.
654 */ 700 */
655 void receivedPacket( OPacket* ); 701 void receivedPacket( OPacket* );
656 702
657 protected slots: 703 protected slots:
658 void readyToReceive(); 704 void readyToReceive();
659 705
660 protected: 706 protected:
661 QString _name; // devicename 707 QString _name; // devicename
662 bool _open; // check this before doing pcap calls 708 bool _open; // check this before doing pcap calls
663 pcap_t* _pch; // pcap library handle 709 pcap_t* _pch; // pcap library handle
664 pcap_dumper_t* _pcd; // pcap dumper handle 710 pcap_dumper_t* _pcd; // pcap dumper handle
665 QSocketNotifier* _sn; // socket notifier for main loop 711 QSocketNotifier* _sn; // socket notifier for main loop
666 mutable char _errbuf[PCAP_ERRBUF_SIZE]; // holds error strings from libpcap 712 mutable char _errbuf[PCAP_ERRBUF_SIZE]; // holds error strings from libpcap
667 QMap<QString, int> _stats; // statistics; 713 QMap<QString, int> _stats; // statistics;
714 class Private; // Private Forward declaration
715 Private *d; // if we need to add data
668}; 716};
717}
718}
669 719
670#endif // OPCAP_H 720#endif // OPCAP_H
671 721
diff --git a/libopie2/opienet/ostation.cpp b/libopie2/opienet/ostation.cpp
index 8c989d8..140b924 100644
--- a/libopie2/opienet/ostation.cpp
+++ b/libopie2/opienet/ostation.cpp
@@ -1,64 +1,72 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3              Copyright (C) 2003 by Michael 'Mickey' Lauer <mickey@Vanille.de> 3              Copyright (C) 2003 by Michael 'Mickey' Lauer <mickey@Vanille.de>
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 30
31#include <opie2/ostation.h> 31#include <opie2/ostation.h>
32#include <opie2/odebug.h> 32#include <opie2/odebug.h>
33 33
34
35using namespace Opie::Core;
36
37namespace Opie {
38namespace Net {
34/*====================================================================================== 39/*======================================================================================
35 * OStation 40 * OStation
36 *======================================================================================*/ 41 *======================================================================================*/
37 42
38OStation::OStation() 43OStation::OStation()
39{ 44{
40 odebug << "OStation::OStation()" << oendl; 45 odebug << "OStation::OStation()" << oendl;
41 46
42 type = "<unknown>"; 47 type = "<unknown>";
43 macAddress = OMacAddress::unknown; 48 macAddress = OMacAddress::unknown;
44 ssid = "<unknown>"; 49 ssid = "<unknown>";
45 channel = 0; 50 channel = 0;
46 apAddress = OMacAddress::unknown; 51 apAddress = OMacAddress::unknown;
47 52
48} 53}
49 54
50 55
51OStation::~OStation() 56OStation::~OStation()
52{ 57{
53 odebug << "OStation::~OStation()" << oendl; 58 odebug << "OStation::~OStation()" << oendl;
54} 59}
55 60
56 61
57void OStation::dump() 62void OStation::dump()
58{ 63{
59 odebug << "------- OStation::dump() ------------" << oendl; 64 odebug << "------- OStation::dump() ------------" << oendl;
60 qDebug( "type: %s", (const char*) type ); 65 qDebug( "type: %s", (const char*) type );
61 qDebug( "mac: %s", (const char*) macAddress.toString() ); 66 qDebug( "mac: %s", (const char*) macAddress.toString() );
62 qDebug( "ap: %s", (const char*) apAddress.toString() ); 67 qDebug( "ap: %s", (const char*) apAddress.toString() );
63 qDebug( "ip: %s", (const char*) ipAddress.toString() ); 68 qDebug( "ip: %s", (const char*) ipAddress.toString() );
64} 69}
70
71}
72} \ No newline at end of file
diff --git a/libopie2/opienet/ostation.h b/libopie2/opienet/ostation.h
index 1e7366d..68f1114 100644
--- a/libopie2/opienet/ostation.h
+++ b/libopie2/opienet/ostation.h
@@ -1,73 +1,82 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3              Copyright (C) 2003 by Michael 'Mickey' Lauer <mickey@Vanille.de> 3              Copyright (C) 2003 by Michael 'Mickey' Lauer <mickey@Vanille.de>
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 30
31#ifndef OSTATION_H 31#ifndef OSTATION_H
32#define OSTATION_H 32#define OSTATION_H
33 33
34#include <opie2/onetutils.h> 34#include <opie2/onetutils.h>
35 35
36#include <qlist.h> 36#include <qlist.h>
37#include <qstring.h> 37#include <qstring.h>
38#include <qhostaddress.h> 38#include <qhostaddress.h>
39#include <qobject.h> 39#include <qobject.h>
40 40
41#include <sys/types.h> 41#include <sys/types.h>
42 42
43namespace Opie {
44namespace Net {
45
43class OStation; 46class OStation;
44 47
48
45typedef QList<OStation> OStationList; 49typedef QList<OStation> OStationList;
46 50
47/*====================================================================================== 51/*======================================================================================
48 * OStation 52 * OStation
49 *======================================================================================*/ 53 *======================================================================================*/
50 54
51class OStation 55class OStation
52{ 56{
53 public: 57 public:
54 OStation(); 58 OStation();
55 ~OStation(); 59 ~OStation();
56 60
57 void dump(); 61 void dump();
58 62
59 /* Ethernet */ 63 /* Ethernet */
60 QString type; 64 QString type;
61 OMacAddress macAddress; 65 OMacAddress macAddress;
62 QHostAddress ipAddress; 66 QHostAddress ipAddress;
63 67
64 /* WaveLan */ 68 /* WaveLan */
65 QString ssid; 69 QString ssid;
66 OMacAddress apAddress; 70 OMacAddress apAddress;
67 int channel; 71 int channel;
68 bool encrypted; 72 bool encrypted;
73 private:
74 class Private;
75 Private *d;
69}; 76};
70 77
78}
79}
71 80
72#endif // OSTATION_H 81#endif // OSTATION_H
73 82
diff --git a/libopie2/opiepim/backend/backends.pro b/libopie2/opiepim/backend/backends.pro
index 4231a00..d4867ba 100644
--- a/libopie2/opiepim/backend/backends.pro
+++ b/libopie2/opiepim/backend/backends.pro
@@ -1,31 +1,33 @@
1SOURCES += core/backends/ocontactaccessbackend_sql.cpp \ 1SOURCES += core/backends/ocontactaccessbackend_sql.cpp \
2 core/backends/ocontactaccessbackend_vcard.cpp \ 2 core/backends/ocontactaccessbackend_vcard.cpp \
3 core/backends/ocontactaccessbackend_xml.cpp \ 3 core/backends/ocontactaccessbackend_xml.cpp \
4 core/backends/ocontactaccess.cpp \ 4 core/backends/ocontactaccess.cpp \
5 core/backends/odatebookaccessbackend.cpp \ 5 core/backends/odatebookaccessbackend.cpp \
6 core/backends/odatebookaccessbackend_xml.cpp \ 6 core/backends/odatebookaccessbackend_xml.cpp \
7 core/backends/otodoaccessbackend.cpp \ 7 core/backends/otodoaccessbackend.cpp \
8 core/backends/otodoaccess.cpp \ 8 core/backends/otodoaccess.cpp \
9 core/backends/otodoaccesssql.cpp \ 9 core/backends/otodoaccesssql.cpp \
10 core/backends/otodoaccessvcal.cpp \ 10 core/backends/otodoaccessvcal.cpp \
11 core/backends/otodoaccessxml.cpp \ 11 core/backends/otodoaccessxml.cpp \
12 core/backends/odatebookaccess.cpp \ 12 core/backends/odatebookaccess.cpp \
13 core/backends/odatebookaccessbackend_sql.cpp 13 core/backends/odatebookaccessbackend_sql.cpp \
14 core/backends/private/xmltree.cc
14 15
15HEADERS += core/backends/obackendfactory.h \ 16HEADERS += core/backends/obackendfactory.h \
16 core/backends/ocontactaccessbackend.h \ 17 core/backends/ocontactaccessbackend.h \
17 core/backends/ocontactaccessbackend_sql.h \ 18 core/backends/ocontactaccessbackend_sql.h \
18 core/backends/ocontactaccessbackend_vcard.h \ 19 core/backends/ocontactaccessbackend_vcard.h \
19 core/backends/ocontactaccessbackend_xml.h \ 20 core/backends/ocontactaccessbackend_xml.h \
20 core/backends/ocontactaccess.h \ 21 core/backends/ocontactaccess.h \
21 core/backends/odatebookaccessbackend.h \ 22 core/backends/odatebookaccessbackend.h \
22 core/backends/odatebookaccessbackend_sql.h \ 23 core/backends/odatebookaccessbackend_sql.h \
23 core/backends/odatebookaccessbackend_xml.h \ 24 core/backends/odatebookaccessbackend_xml.h \
24 core/backends/opimaccessbackend.h \ 25 core/backends/opimaccessbackend.h \
25 core/backends/opimaccesstemplate.h \ 26 core/backends/opimaccesstemplate.h \
26 core/backends/otodoaccessbackend.h \ 27 core/backends/otodoaccessbackend.h \
27 core/backends/otodoaccess.h \ 28 core/backends/otodoaccess.h \
28 core/backends/otodoaccesssql.h \ 29 core/backends/otodoaccesssql.h \
29 core/backends/otodoaccessvcal.h \ 30 core/backends/otodoaccessvcal.h \
30 core/backends/otodoaccessxml.h \ 31 core/backends/otodoaccessxml.h \
31 core/backends/odatebookaccess.h 32 core/backends/odatebookaccess.h \
33 core/backends/private/xmltree.h
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp b/libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp
index f121cc2..d16d692 100644
--- a/libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp
+++ b/libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp
@@ -1,97 +1,97 @@
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 * SQL Backend for the OPIE-Contact Database. 30 * SQL Backend for the OPIE-Contact Database.
31 */ 31 */
32 32
33#include "ocontactaccessbackend_sql.h" 33#include "ocontactaccessbackend_sql.h"
34 34
35#include <qarray.h> 35#include <qarray.h>
36#include <qdatetime.h> 36#include <qdatetime.h>
37#include <qstringlist.h> 37#include <qstringlist.h>
38 38
39#include <qpe/global.h> 39#include <qpe/global.h>
40#include <qpe/recordfields.h> 40#include <qpe/recordfields.h>
41 41
42#include <opie2/opimcontactfields.h> 42#include <opie2/opimcontactfields.h>
43#include <opie2/opimdateconversion.h> 43#include <opie2/opimdateconversion.h>
44#include <opie2/osqldriver.h> 44#include <opie2/osqldriver.h>
45#include <opie2/osqlresult.h> 45#include <opie2/osqlresult.h>
46#include <opie2/osqlmanager.h> 46#include <opie2/osqlmanager.h>
47#include <opie2/osqlquery.h> 47#include <opie2/osqlquery.h>
48 48
49 49using namespace Opie::DB;
50 50
51 51
52// If defined, we use a horizontal table ( uid, attr1, attr2, attr3, ..., attrn ) instead 52// If defined, we use a horizontal table ( uid, attr1, attr2, attr3, ..., attrn ) instead
53// vertical like "uid, type, value". 53// vertical like "uid, type, value".
54// DON'T DEACTIVATE THIS DEFINE IN PRODUCTIVE ENVIRONMENTS !! 54// DON'T DEACTIVATE THIS DEFINE IN PRODUCTIVE ENVIRONMENTS !!
55#define __STORE_HORIZONTAL_ 55#define __STORE_HORIZONTAL_
56 56
57// Distinct loading is not very fast. If I expect that every person has just 57// Distinct loading is not very fast. If I expect that every person has just
58// one (and always one) 'Last Name', I can request all uid's for existing lastnames, 58// one (and always one) 'Last Name', I can request all uid's for existing lastnames,
59// which is faster.. 59// which is faster..
60// But this may not be true for all entries, like company contacts.. 60// But this may not be true for all entries, like company contacts..
61// The current AddressBook application handles this problem, but other may not.. (eilers) 61// The current AddressBook application handles this problem, but other may not.. (eilers)
62#define __USE_SUPERFAST_LOADQUERY 62#define __USE_SUPERFAST_LOADQUERY
63 63
64 64
65/* 65/*
66 * Implementation of used query types 66 * Implementation of used query types
67 * CREATE query 67 * CREATE query
68 * LOAD query 68 * LOAD query
69 * INSERT 69 * INSERT
70 * REMOVE 70 * REMOVE
71 * CLEAR 71 * CLEAR
72 */ 72 */
73namespace Opie { 73namespace Opie {
74 /** 74 /**
75 * CreateQuery for the Todolist Table 75 * CreateQuery for the Todolist Table
76 */ 76 */
77 class CreateQuery : public OSQLQuery { 77 class CreateQuery : public OSQLQuery {
78 public: 78 public:
79 CreateQuery(); 79 CreateQuery();
80 ~CreateQuery(); 80 ~CreateQuery();
81 QString query()const; 81 QString query()const;
82 }; 82 };
83 83
84 /** 84 /**
85 * Clears (delete) a Table 85 * Clears (delete) a Table
86 */ 86 */
87 class ClearQuery : public OSQLQuery { 87 class ClearQuery : public OSQLQuery {
88 public: 88 public:
89 ClearQuery(); 89 ClearQuery();
90 ~ClearQuery(); 90 ~ClearQuery();
91 QString query()const; 91 QString query()const;
92 92
93 }; 93 };
94 94
95 95
96 /** 96 /**
97 * LoadQuery 97 * LoadQuery
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_sql.h b/libopie2/opiepim/backend/ocontactaccessbackend_sql.h
index 58ae2ae..ba122ec 100644
--- a/libopie2/opiepim/backend/ocontactaccessbackend_sql.h
+++ b/libopie2/opiepim/backend/ocontactaccessbackend_sql.h
@@ -1,109 +1,113 @@
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/* 29/*
30 * SQL Backend for the OPIE-Contact Database. 30 * SQL Backend for the OPIE-Contact Database.
31 */ 31 */
32 32
33#ifndef _OPimContactAccessBackend_SQL_ 33#ifndef _OPimContactAccessBackend_SQL_
34#define _OPimContactAccessBackend_SQL_ 34#define _OPimContactAccessBackend_SQL_
35 35
36#include <opie2/ocontactaccessbackend.h> 36#include <opie2/ocontactaccessbackend.h>
37#include <opie2/ocontactaccess.h> 37#include <opie2/ocontactaccess.h>
38 38
39#include <qlist.h> 39#include <qlist.h>
40#include <qdict.h> 40#include <qdict.h>
41 41
42/* aren't in namespace Opie yet - alwin */ 42/* aren't in namespace Opie yet - alwin */
43namespace Opie {
44namespace DB {
43class OSQLDriver; 45class OSQLDriver;
44class OSQLResult; 46class OSQLResult;
45class OSQLResultItem; 47class OSQLResultItem;
48}
49}
46 50
47namespace Opie { 51namespace Opie {
48 52
49/* the default xml implementation */ 53/* the default xml implementation */
50/** 54/**
51 * This class is the SQL implementation of a Contact backend 55 * This class is the SQL implementation of a Contact backend
52 * it does implement everything available for OPimContact. 56 * it does implement everything available for OPimContact.
53 * @see OPimAccessBackend for more information of available methods 57 * @see OPimAccessBackend for more information of available methods
54 */ 58 */
55class OPimContactAccessBackend_SQL : public OPimContactAccessBackend { 59class OPimContactAccessBackend_SQL : public OPimContactAccessBackend {
56 public: 60 public:
57 OPimContactAccessBackend_SQL ( const QString& appname, const QString& filename = QString::null ); 61 OPimContactAccessBackend_SQL ( const QString& appname, const QString& filename = QString::null );
58 62
59 ~OPimContactAccessBackend_SQL (); 63 ~OPimContactAccessBackend_SQL ();
60 64
61 bool save(); 65 bool save();
62 66
63 bool load (); 67 bool load ();
64 68
65 void clear (); 69 void clear ();
66 70
67 bool wasChangedExternally(); 71 bool wasChangedExternally();
68 72
69 QArray<int> allRecords() const; 73 QArray<int> allRecords() const;
70 74
71 OPimContact find ( int uid ) const; 75 OPimContact find ( int uid ) const;
72 // FIXME: Add lookahead-cache support ! 76 // FIXME: Add lookahead-cache support !
73 //OPimContact find(int uid, const QArray<int>&, uint cur, Frontend::CacheDirection )const; 77 //OPimContact find(int uid, const QArray<int>&, uint cur, Frontend::CacheDirection )const;
74 78
75 QArray<int> queryByExample ( const OPimContact &query, int settings, 79 QArray<int> queryByExample ( const OPimContact &query, int settings,
76 const QDateTime& d ); 80 const QDateTime& d );
77 81
78 QArray<int> matchRegexp( const QRegExp &r ) const; 82 QArray<int> matchRegexp( const QRegExp &r ) const;
79 83
80 const uint querySettings(); 84 const uint querySettings();
81 85
82 bool hasQuerySettings (uint querySettings) const; 86 bool hasQuerySettings (uint querySettings) const;
83 87
84 // Currently only asc implemented.. 88 // Currently only asc implemented..
85 QArray<int> sorted( bool asc, int , int , int ); 89 QArray<int> sorted( bool asc, int , int , int );
86 bool add ( const OPimContact &newcontact ); 90 bool add ( const OPimContact &newcontact );
87 91
88 bool replace ( const OPimContact &contact ); 92 bool replace ( const OPimContact &contact );
89 93
90 bool remove ( int uid ); 94 bool remove ( int uid );
91 bool reload(); 95 bool reload();
92 96
93 private: 97 private:
94 QArray<int> extractUids( OSQLResult& res ) const; 98 QArray<int> extractUids( Opie::DB::OSQLResult& res ) const;
95 QMap<int, QString> requestNonCustom( int uid ) const; 99 QMap<int, QString> requestNonCustom( int uid ) const;
96 QMap<QString, QString> requestCustom( int uid ) const; 100 QMap<QString, QString> requestCustom( int uid ) const;
97 void update(); 101 void update();
98 102
99 protected: 103 protected:
100 bool m_changed; 104 bool m_changed;
101 QString m_fileName; 105 QString m_fileName;
102 QArray<int> m_uids; 106 QArray<int> m_uids;
103 107
104 OSQLDriver* m_driver; 108 Opie::DB::OSQLDriver* m_driver;
105}; 109};
106 110
107} 111}
108 112
109#endif 113#endif
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp b/libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp
index 5d92b8f..f5e76d5 100644
--- a/libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp
+++ b/libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp
@@ -1,99 +1,100 @@
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/* 29/*
30 * XML Backend for the OPIE-Contact Database. 30 * XML Backend for the OPIE-Contact Database.
31 */ 31 */
32 32
33#include <opie2/ocontactaccessbackend_xml.h> 33#include <opie2/ocontactaccessbackend_xml.h>
34 34
35#include <qasciidict.h> 35#include <qasciidict.h>
36#include <qfile.h> 36#include <qfile.h>
37#include <qfileinfo.h> 37#include <qfileinfo.h>
38#include <qregexp.h> 38#include <qregexp.h>
39#include <qarray.h> 39#include <qarray.h>
40#include <qmap.h> 40#include <qmap.h>
41 41
42#include <qpe/global.h> 42#include <qpe/global.h>
43 43
44#include <opie2/xmltree.h> 44#include "private/xmltree.h"
45#include <opie2/ocontactaccessbackend.h> 45#include <opie2/ocontactaccessbackend.h>
46#include <opie2/ocontactaccess.h> 46#include <opie2/ocontactaccess.h>
47 47
48#include <stdlib.h> 48#include <stdlib.h>
49#include <errno.h> 49#include <errno.h>
50 50
51using namespace Opie; 51using namespace Opie;
52using namespace Opie::Pim::Private;
52 53
53 54
54namespace Opie { 55namespace Opie {
55OPimContactAccessBackend_XML::OPimContactAccessBackend_XML ( const QString& appname, const QString& filename ): 56OPimContactAccessBackend_XML::OPimContactAccessBackend_XML ( const QString& appname, const QString& filename ):
56 m_changed( false ) 57 m_changed( false )
57{ 58{
58 // Just m_contactlist should call delete if an entry 59 // Just m_contactlist should call delete if an entry
59 // is removed. 60 // is removed.
60 m_contactList.setAutoDelete( true ); 61 m_contactList.setAutoDelete( true );
61 m_uidToContact.setAutoDelete( false ); 62 m_uidToContact.setAutoDelete( false );
62 63
63 m_appName = appname; 64 m_appName = appname;
64 65
65 /* Set journalfile name ... */ 66 /* Set journalfile name ... */
66 m_journalName = getenv("HOME"); 67 m_journalName = getenv("HOME");
67 m_journalName +="/.abjournal" + appname; 68 m_journalName +="/.abjournal" + appname;
68 69
69 /* Expecting to access the default filename if nothing else is set */ 70 /* Expecting to access the default filename if nothing else is set */
70 if ( filename.isEmpty() ){ 71 if ( filename.isEmpty() ){
71 m_fileName = Global::applicationFileName( "addressbook","addressbook.xml" ); 72 m_fileName = Global::applicationFileName( "addressbook","addressbook.xml" );
72 } else 73 } else
73 m_fileName = filename; 74 m_fileName = filename;
74 75
75 /* Load Database now */ 76 /* Load Database now */
76 load (); 77 load ();
77} 78}
78 79
79bool OPimContactAccessBackend_XML::save() 80bool OPimContactAccessBackend_XML::save()
80{ 81{
81 82
82 if ( !m_changed ) 83 if ( !m_changed )
83 return true; 84 return true;
84 85
85 QString strNewFile = m_fileName + ".new"; 86 QString strNewFile = m_fileName + ".new";
86 QFile f( strNewFile ); 87 QFile f( strNewFile );
87 if ( !f.open( IO_WriteOnly|IO_Raw ) ) 88 if ( !f.open( IO_WriteOnly|IO_Raw ) )
88 return false; 89 return false;
89 90
90 int total_written; 91 int total_written;
91 int idx_offset = 0; 92 int idx_offset = 0;
92 QString out; 93 QString out;
93 94
94 // Write Header 95 // Write Header
95 out = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><!DOCTYPE Addressbook ><AddressBook>\n" 96 out = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><!DOCTYPE Addressbook ><AddressBook>\n"
96 " <Groups>\n" 97 " <Groups>\n"
97 " </Groups>\n" 98 " </Groups>\n"
98 " <Contacts>\n"; 99 " <Contacts>\n";
99 QCString cstr = out.utf8(); 100 QCString cstr = out.utf8();
diff --git a/libopie2/opiepim/backend/odatebookaccessbackend_sql.cpp b/libopie2/opiepim/backend/odatebookaccessbackend_sql.cpp
index 2ee76cc..a779dc1 100644
--- a/libopie2/opiepim/backend/odatebookaccessbackend_sql.cpp
+++ b/libopie2/opiepim/backend/odatebookaccessbackend_sql.cpp
@@ -1,96 +1,98 @@
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/* 29/*
30 * SQL Backend for the OPIE-Calender Database. 30 * SQL Backend for the OPIE-Calender Database.
31 * 31 *
32 */ 32 */
33 33
34#include <stdio.h> 34#include <stdio.h>
35#include <stdlib.h> 35#include <stdlib.h>
36 36
37#include <qarray.h> 37#include <qarray.h>
38#include <qstringlist.h> 38#include <qstringlist.h>
39 39
40#include <qpe/global.h> 40#include <qpe/global.h>
41 41
42#include <opie2/osqldriver.h> 42#include <opie2/osqldriver.h>
43#include <opie2/osqlmanager.h> 43#include <opie2/osqlmanager.h>
44#include <opie2/osqlquery.h> 44#include <opie2/osqlquery.h>
45 45
46#include <opie2/opimrecurrence.h> 46#include <opie2/opimrecurrence.h>
47#include <opie2/odatebookaccessbackend_sql.h> 47#include <opie2/odatebookaccessbackend_sql.h>
48 48
49using namespace Opie::DB;
50
49namespace Opie { 51namespace Opie {
50 52
51 53
52ODateBookAccessBackend_SQL::ODateBookAccessBackend_SQL( const QString& , 54ODateBookAccessBackend_SQL::ODateBookAccessBackend_SQL( const QString& ,
53 const QString& fileName ) 55 const QString& fileName )
54 : ODateBookAccessBackend(), m_driver( NULL ) 56 : ODateBookAccessBackend(), m_driver( NULL )
55{ 57{
56 m_fileName = fileName.isEmpty() ? Global::applicationFileName( "datebook", "datebook.db" ) : fileName; 58 m_fileName = fileName.isEmpty() ? Global::applicationFileName( "datebook", "datebook.db" ) : fileName;
57 59
58 // Get the standart sql-driver from the OSQLManager.. 60 // Get the standart sql-driver from the OSQLManager..
59 OSQLManager man; 61 OSQLManager man;
60 m_driver = man.standard(); 62 m_driver = man.standard();
61 m_driver->setUrl( m_fileName ); 63 m_driver->setUrl( m_fileName );
62 64
63 initFields(); 65 initFields();
64 66
65 load(); 67 load();
66} 68}
67 69
68ODateBookAccessBackend_SQL::~ODateBookAccessBackend_SQL() { 70ODateBookAccessBackend_SQL::~ODateBookAccessBackend_SQL() {
69 if( m_driver ) 71 if( m_driver )
70 delete m_driver; 72 delete m_driver;
71} 73}
72 74
73void ODateBookAccessBackend_SQL::initFields() 75void ODateBookAccessBackend_SQL::initFields()
74{ 76{
75 77
76 // This map contains the translation of the fieldtype id's to 78 // This map contains the translation of the fieldtype id's to
77 // the names of the table columns 79 // the names of the table columns
78 m_fieldMap.insert( OPimEvent::FUid, "uid" ); 80 m_fieldMap.insert( OPimEvent::FUid, "uid" );
79 m_fieldMap.insert( OPimEvent::FCategories, "Categories" ); 81 m_fieldMap.insert( OPimEvent::FCategories, "Categories" );
80 m_fieldMap.insert( OPimEvent::FDescription, "Description" ); 82 m_fieldMap.insert( OPimEvent::FDescription, "Description" );
81 m_fieldMap.insert( OPimEvent::FLocation, "Location" ); 83 m_fieldMap.insert( OPimEvent::FLocation, "Location" );
82 m_fieldMap.insert( OPimEvent::FType, "Type" ); 84 m_fieldMap.insert( OPimEvent::FType, "Type" );
83 m_fieldMap.insert( OPimEvent::FAlarm, "Alarm" ); 85 m_fieldMap.insert( OPimEvent::FAlarm, "Alarm" );
84 m_fieldMap.insert( OPimEvent::FSound, "Sound" ); 86 m_fieldMap.insert( OPimEvent::FSound, "Sound" );
85 m_fieldMap.insert( OPimEvent::FRType, "RType" ); 87 m_fieldMap.insert( OPimEvent::FRType, "RType" );
86 m_fieldMap.insert( OPimEvent::FRWeekdays, "RWeekdays" ); 88 m_fieldMap.insert( OPimEvent::FRWeekdays, "RWeekdays" );
87 m_fieldMap.insert( OPimEvent::FRPosition, "RPosition" ); 89 m_fieldMap.insert( OPimEvent::FRPosition, "RPosition" );
88 m_fieldMap.insert( OPimEvent::FRFreq, "RFreq" ); 90 m_fieldMap.insert( OPimEvent::FRFreq, "RFreq" );
89 m_fieldMap.insert( OPimEvent::FRHasEndDate, "RHasEndDate" ); 91 m_fieldMap.insert( OPimEvent::FRHasEndDate, "RHasEndDate" );
90 m_fieldMap.insert( OPimEvent::FREndDate, "REndDate" ); 92 m_fieldMap.insert( OPimEvent::FREndDate, "REndDate" );
91 m_fieldMap.insert( OPimEvent::FRCreated, "RCreated" ); 93 m_fieldMap.insert( OPimEvent::FRCreated, "RCreated" );
92 m_fieldMap.insert( OPimEvent::FRExceptions, "RExceptions" ); 94 m_fieldMap.insert( OPimEvent::FRExceptions, "RExceptions" );
93 m_fieldMap.insert( OPimEvent::FStart, "Start" ); 95 m_fieldMap.insert( OPimEvent::FStart, "Start" );
94 m_fieldMap.insert( OPimEvent::FEnd, "End" ); 96 m_fieldMap.insert( OPimEvent::FEnd, "End" );
95 m_fieldMap.insert( OPimEvent::FNote, "Note" ); 97 m_fieldMap.insert( OPimEvent::FNote, "Note" );
96 m_fieldMap.insert( OPimEvent::FTimeZone, "TimeZone" ); 98 m_fieldMap.insert( OPimEvent::FTimeZone, "TimeZone" );
diff --git a/libopie2/opiepim/backend/odatebookaccessbackend_sql.h b/libopie2/opiepim/backend/odatebookaccessbackend_sql.h
index cbfeb97..60d7f21 100644
--- a/libopie2/opiepim/backend/odatebookaccessbackend_sql.h
+++ b/libopie2/opiepim/backend/odatebookaccessbackend_sql.h
@@ -1,93 +1,97 @@
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#ifndef OPIE_DATE_BOOK_ACCESS_BACKEND_SQL__H 29#ifndef OPIE_DATE_BOOK_ACCESS_BACKEND_SQL__H
30#define OPIE_DATE_BOOK_ACCESS_BACKEND_SQL__H 30#define OPIE_DATE_BOOK_ACCESS_BACKEND_SQL__H
31 31
32#include <qmap.h> 32#include <qmap.h>
33#include <opie2/osqlresult.h> 33#include <opie2/osqlresult.h>
34 34
35#include <opie2/odatebookaccessbackend.h> 35#include <opie2/odatebookaccessbackend.h>
36 36
37namespace Opie {
38namespace DB {
37class OSQLDriver; 39class OSQLDriver;
40}
41}
38 42
39namespace Opie { 43namespace Opie {
40/** 44/**
41 * This is the default SQL implementation for DateBoook SQL storage 45 * This is the default SQL implementation for DateBoook SQL storage
42 * It fully implements the interface 46 * It fully implements the interface
43 * @see ODateBookAccessBackend 47 * @see ODateBookAccessBackend
44 * @see OPimAccessBackend 48 * @see OPimAccessBackend
45 */ 49 */
46class ODateBookAccessBackend_SQL : public ODateBookAccessBackend { 50class ODateBookAccessBackend_SQL : public ODateBookAccessBackend {
47public: 51public:
48 ODateBookAccessBackend_SQL( const QString& appName, 52 ODateBookAccessBackend_SQL( const QString& appName,
49 const QString& fileName = QString::null); 53 const QString& fileName = QString::null);
50 ~ODateBookAccessBackend_SQL(); 54 ~ODateBookAccessBackend_SQL();
51 55
52 bool load(); 56 bool load();
53 bool reload(); 57 bool reload();
54 bool save(); 58 bool save();
55 59
56 QArray<int> allRecords()const; 60 QArray<int> allRecords()const;
57 QArray<int> matchRegexp(const QRegExp &r) const; 61 QArray<int> matchRegexp(const QRegExp &r) const;
58 QArray<int> queryByExample( const OPimEvent&, int, const QDateTime& d = QDateTime() ); 62 QArray<int> queryByExample( const OPimEvent&, int, const QDateTime& d = QDateTime() );
59 OPimEvent find( int uid )const; 63 OPimEvent find( int uid )const;
60 void clear(); 64 void clear();
61 bool add( const OPimEvent& ev ); 65 bool add( const OPimEvent& ev );
62 bool remove( int uid ); 66 bool remove( int uid );
63 bool replace( const OPimEvent& ev ); 67 bool replace( const OPimEvent& ev );
64 68
65 QArray<UID> rawEvents()const; 69 QArray<UID> rawEvents()const;
66 QArray<UID> rawRepeats()const; 70 QArray<UID> rawRepeats()const;
67 QArray<UID> nonRepeats()const; 71 QArray<UID> nonRepeats()const;
68 72
69 OPimEvent::ValueList directNonRepeats(); 73 OPimEvent::ValueList directNonRepeats();
70 OPimEvent::ValueList directRawRepeats(); 74 OPimEvent::ValueList directRawRepeats();
71 75
72private: 76private:
73 bool loadFile(); 77 bool loadFile();
74 QString m_fileName; 78 QString m_fileName;
75 QArray<int> m_uids; 79 QArray<int> m_uids;
76 80
77 QMap<int, QString> m_fieldMap; 81 QMap<int, QString> m_fieldMap;
78 QMap<QString, int> m_reverseFieldMap; 82 QMap<QString, int> m_reverseFieldMap;
79 83
80 OSQLDriver* m_driver; 84 Opie::DB::OSQLDriver* m_driver;
81 85
82 class Private; 86 class Private;
83 Private *d; 87 Private *d;
84 88
85 void initFields(); 89 void initFields();
86 void update(); 90 void update();
87 QArray<int> extractUids( OSQLResult& res ) const; 91 QArray<int> extractUids( Opie::DB::OSQLResult& res ) const;
88 92
89}; 93};
90 94
91} 95}
92 96
93#endif 97#endif
diff --git a/libopie2/opiepim/backend/otodoaccesssql.cpp b/libopie2/opiepim/backend/otodoaccesssql.cpp
index 72232e5..d218090 100644
--- a/libopie2/opiepim/backend/otodoaccesssql.cpp
+++ b/libopie2/opiepim/backend/otodoaccesssql.cpp
@@ -1,91 +1,93 @@
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 29
30#include <qdatetime.h> 30#include <qdatetime.h>
31 31
32#include <qpe/global.h> 32#include <qpe/global.h>
33 33
34#include <opie2/osqldriver.h> 34#include <opie2/osqldriver.h>
35#include <opie2/osqlresult.h> 35#include <opie2/osqlresult.h>
36#include <opie2/osqlmanager.h> 36#include <opie2/osqlmanager.h>
37#include <opie2/osqlquery.h> 37#include <opie2/osqlquery.h>
38 38
39#include <opie2/otodoaccesssql.h> 39#include <opie2/otodoaccesssql.h>
40#include <opie2/opimstate.h> 40#include <opie2/opimstate.h>
41#include <opie2/opimnotifymanager.h> 41#include <opie2/opimnotifymanager.h>
42#include <opie2/opimrecurrence.h> 42#include <opie2/opimrecurrence.h>
43 43
44using namespace Opie::DB;
45
44using namespace Opie; 46using namespace Opie;
45/* 47/*
46 * first some query 48 * first some query
47 * CREATE query 49 * CREATE query
48 * LOAD query 50 * LOAD query
49 * INSERT 51 * INSERT
50 * REMOVE 52 * REMOVE
51 * CLEAR 53 * CLEAR
52 */ 54 */
53namespace { 55namespace {
54 /** 56 /**
55 * CreateQuery for the Todolist Table 57 * CreateQuery for the Todolist Table
56 */ 58 */
57 class CreateQuery : public OSQLQuery { 59 class CreateQuery : public OSQLQuery {
58 public: 60 public:
59 CreateQuery(); 61 CreateQuery();
60 ~CreateQuery(); 62 ~CreateQuery();
61 QString query()const; 63 QString query()const;
62 }; 64 };
63 65
64 /** 66 /**
65 * LoadQuery 67 * LoadQuery
66 * this one queries for all uids 68 * this one queries for all uids
67 */ 69 */
68 class LoadQuery : public OSQLQuery { 70 class LoadQuery : public OSQLQuery {
69 public: 71 public:
70 LoadQuery(); 72 LoadQuery();
71 ~LoadQuery(); 73 ~LoadQuery();
72 QString query()const; 74 QString query()const;
73 }; 75 };
74 76
75 /** 77 /**
76 * inserts/adds a OPimTodo to the table 78 * inserts/adds a OPimTodo to the table
77 */ 79 */
78 class InsertQuery : public OSQLQuery { 80 class InsertQuery : public OSQLQuery {
79 public: 81 public:
80 InsertQuery(const OPimTodo& ); 82 InsertQuery(const OPimTodo& );
81 ~InsertQuery(); 83 ~InsertQuery();
82 QString query()const; 84 QString query()const;
83 private: 85 private:
84 OPimTodo m_todo; 86 OPimTodo m_todo;
85 }; 87 };
86 88
87 /** 89 /**
88 * removes one from the table 90 * removes one from the table
89 */ 91 */
90 class RemoveQuery : public OSQLQuery { 92 class RemoveQuery : public OSQLQuery {
91 public: 93 public:
diff --git a/libopie2/opiepim/backend/otodoaccesssql.h b/libopie2/opiepim/backend/otodoaccesssql.h
index e945863..0ae2591 100644
--- a/libopie2/opiepim/backend/otodoaccesssql.h
+++ b/libopie2/opiepim/backend/otodoaccesssql.h
@@ -1,88 +1,92 @@
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#ifndef OPIE_PIM_ACCESS_SQL_H 29#ifndef OPIE_PIM_ACCESS_SQL_H
30#define OPIE_PIM_ACCESS_SQL_H 30#define OPIE_PIM_ACCESS_SQL_H
31 31
32#include <qasciidict.h> 32#include <qasciidict.h>
33 33
34#include <opie2/otodoaccessbackend.h> 34#include <opie2/otodoaccessbackend.h>
35 35
36namespace Opie {
37namespace DB {
36class OSQLDriver; 38class OSQLDriver;
37class OSQLResult; 39class OSQLResult;
38class OSQLResultItem; 40class OSQLResultItem;
41}
42}
39 43
40namespace Opie { 44namespace Opie {
41 45
42class OPimTodoAccessBackendSQL : public OPimTodoAccessBackend { 46class OPimTodoAccessBackendSQL : public OPimTodoAccessBackend {
43public: 47public:
44 OPimTodoAccessBackendSQL( const QString& file ); 48 OPimTodoAccessBackendSQL( const QString& file );
45 ~OPimTodoAccessBackendSQL(); 49 ~OPimTodoAccessBackendSQL();
46 50
47 bool load(); 51 bool load();
48 bool reload(); 52 bool reload();
49 bool save(); 53 bool save();
50 QArray<int> allRecords()const; 54 QArray<int> allRecords()const;
51 55
52 QArray<int> queryByExample( const OPimTodo& t, int settings, const QDateTime& d = QDateTime() ); 56 QArray<int> queryByExample( const OPimTodo& t, int settings, const QDateTime& d = QDateTime() );
53 OPimTodo find(int uid)const; 57 OPimTodo find(int uid)const;
54 OPimTodo find(int uid, const QArray<int>&, uint cur, Frontend::CacheDirection )const; 58 OPimTodo find(int uid, const QArray<int>&, uint cur, Frontend::CacheDirection )const;
55 void clear(); 59 void clear();
56 bool add( const OPimTodo& t ); 60 bool add( const OPimTodo& t );
57 bool remove( int uid ); 61 bool remove( int uid );
58 bool replace( const OPimTodo& t ); 62 bool replace( const OPimTodo& t );
59 63
60 QArray<int> overDue(); 64 QArray<int> overDue();
61 QArray<int> effectiveToDos( const QDate& start, 65 QArray<int> effectiveToDos( const QDate& start,
62 const QDate& end, bool includeNoDates ); 66 const QDate& end, bool includeNoDates );
63 QArray<int> sorted(bool asc, int sortOrder, int sortFilter, int cat ); 67 QArray<int> sorted(bool asc, int sortOrder, int sortFilter, int cat );
64 68
65 QBitArray supports()const; 69 QBitArray supports()const;
66 QArray<int> matchRegexp( const QRegExp &r ) const; 70 QArray<int> matchRegexp( const QRegExp &r ) const;
67 void removeAllCompleted(); 71 void removeAllCompleted();
68 72
69 73
70private: 74private:
71 void update()const; 75 void update()const;
72 void fillDict(); 76 void fillDict();
73 inline bool date( QDate& date, const QString& )const; 77 inline bool date( QDate& date, const QString& )const;
74 inline OPimTodo todo( const OSQLResult& )const; 78 inline OPimTodo todo( const Opie::DB::OSQLResult& )const;
75 inline OPimTodo todo( OSQLResultItem& )const; 79 inline OPimTodo todo( Opie::DB::OSQLResultItem& )const;
76 inline QArray<int> uids( const OSQLResult& )const; 80 inline QArray<int> uids( const Opie::DB::OSQLResult& )const;
77 OPimTodo todo( int uid )const; 81 OPimTodo todo( int uid )const;
78 QBitArray sup() const; 82 QBitArray sup() const;
79 83
80 QAsciiDict<int> m_dict; 84 QAsciiDict<int> m_dict;
81 OSQLDriver* m_driver; 85 Opie::DB::OSQLDriver* m_driver;
82 QArray<int> m_uids; 86 QArray<int> m_uids;
83 bool m_dirty : 1; 87 bool m_dirty : 1;
84}; 88};
85 89
86} 90}
87 91
88#endif 92#endif
diff --git a/libopie2/opiecore/xmltree.cc b/libopie2/opiepim/core/backends/private/xmltree.cc
index 059791b..40749ca 100644
--- a/libopie2/opiecore/xmltree.cc
+++ b/libopie2/opiepim/core/backends/private/xmltree.cc
@@ -1,76 +1,76 @@
1/* This file is part of the KDE project 1/* This file is part of the KDE project
2 Copyright (C) 2001 Simon Hausmann <hausmann@kde.org> 2 Copyright (C) 2001 Simon Hausmann <hausmann@kde.org>
3 3
4 This library is free software; you can redistribute it and/or 4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public 5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either 6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version. 7 version 2 of the License, or (at your option) any later version.
8 8
9 This library is distributed in the hope that it will be useful, 9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details. 12 Library General Public License for more details.
13 13
14 You should have received a copy of the GNU Library General Public License 14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to 15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA. 17 Boston, MA 02111-1307, USA.
18*/ 18*/
19 19
20#include <opie2/xmltree.h> 20#include "xmltree.h"
21 21
22#include <qpe/stringutil.h> 22#include <qpe/stringutil.h>
23 23
24#include <qxml.h> 24#include <qxml.h>
25 25
26#include <assert.h> 26#include <assert.h>
27 27
28using namespace Opie; 28using namespace Opie::Pim::Private;
29 29
30XMLElement::XMLElement() 30XMLElement::XMLElement()
31 : m_parent( 0 ), m_next( 0 ), m_prev( 0 ), m_first( 0 ), m_last( 0 ) 31 : m_parent( 0 ), m_next( 0 ), m_prev( 0 ), m_first( 0 ), m_last( 0 )
32{ 32{
33} 33}
34 34
35XMLElement::~XMLElement() 35XMLElement::~XMLElement()
36{ 36{
37 XMLElement *n = m_first; 37 XMLElement *n = m_first;
38 38
39 while ( n ) 39 while ( n )
40 { 40 {
41 XMLElement *tmp = n; 41 XMLElement *tmp = n;
42 n = n->m_next; 42 n = n->m_next;
43 delete tmp; 43 delete tmp;
44 } 44 }
45} 45}
46 46
47void XMLElement::appendChild( XMLElement *child ) 47void XMLElement::appendChild( XMLElement *child )
48{ 48{
49 if ( child->m_parent ) 49 if ( child->m_parent )
50 child->m_parent->removeChild( child ); 50 child->m_parent->removeChild( child );
51 51
52 child->m_parent = this; 52 child->m_parent = this;
53 53
54 if ( m_last ) 54 if ( m_last )
55 m_last->m_next = child; 55 m_last->m_next = child;
56 56
57 child->m_prev = m_last; 57 child->m_prev = m_last;
58 58
59 if ( !m_first ) 59 if ( !m_first )
60 m_first = child; 60 m_first = child;
61 61
62 m_last = child; 62 m_last = child;
63} 63}
64 64
65void XMLElement::insertAfter( XMLElement *newChild, XMLElement *refChild ) 65void XMLElement::insertAfter( XMLElement *newChild, XMLElement *refChild )
66{ 66{
67 assert( newChild != refChild ); 67 assert( newChild != refChild );
68 68
69 if ( refChild == m_last ) 69 if ( refChild == m_last )
70 { 70 {
71 appendChild( newChild ); 71 appendChild( newChild );
72 return; 72 return;
73 } 73 }
74 74
75 assert( refChild ); 75 assert( refChild );
76 assert( refChild->m_parent ); 76 assert( refChild->m_parent );
diff --git a/libopie2/opiecore/xmltree.h b/libopie2/opiepim/core/backends/private/xmltree.h
index 4b6bdfa..9817a02 100644
--- a/libopie2/opiecore/xmltree.h
+++ b/libopie2/opiepim/core/backends/private/xmltree.h
@@ -1,119 +1,122 @@
1/* This file is part of the KDE project 1/* This file is part of the KDE project
2 Copyright (C) 2000,2001 Simon Hausmann <hausmann@kde.org> 2 Copyright (C) 2000,2001 Simon Hausmann <hausmann@kde.org>
3 3
4 This library is free software; you can redistribute it and/or 4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public 5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either 6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version. 7 version 2 of the License, or (at your option) any later version.
8 8
9 This library is distributed in the hope that it will be useful, 9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details. 12 Library General Public License for more details.
13 13
14 You should have received a copy of the GNU Library General Public License 14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to 15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA. 17 Boston, MA 02111-1307, USA.
18*/ 18*/
19 19
20 20
21#ifndef __bookmarks_h__ 21#ifndef __bookmarks_h__
22#define __bookmarks_h__ 22#define __bookmarks_h__
23 23
24#include <qstring.h> 24#include <qstring.h>
25#include <qmap.h> 25#include <qmap.h>
26#include <qtextstream.h> 26#include <qtextstream.h>
27 27
28namespace Opie 28namespace Opie {
29{ 29namespace Pim {
30namespace Private{
30 31
31/** 32/**
32 * A small xml lib written by Simon Hausmann. 33 * A small xml lib written by Simon Hausmann.
33 */ 34 */
34class XMLElement 35class XMLElement
35{ 36{
36public: 37public:
37 typedef QMap<QString, QString> AttributeMap; 38 typedef QMap<QString, QString> AttributeMap;
38 39
39 /** 40 /**
40 * The constructor of XMLElement 41 * The constructor of XMLElement
41 */ 42 */
42 XMLElement(); 43 XMLElement();
43 ~XMLElement(); 44 ~XMLElement();
44 45
45 /** appendChild appends a child to the XMLElement behind the last element. 46 /** appendChild appends a child to the XMLElement behind the last element.
46 * The ownership of the child get's transfered to the 47 * The ownership of the child get's transfered to the
47 * this XMLElement. 48 * this XMLElement.
48 * If child is already the child of another parent 49 * If child is already the child of another parent
49 * it's get removed from the other parent first. 50 * it's get removed from the other parent first.
50 */ 51 */
51 void appendChild( XMLElement *child ); 52 void appendChild( XMLElement *child );
52 53
53 /** inserts newChild after refChild. If newChild is the child 54 /** inserts newChild after refChild. If newChild is the child
54 * of another parent the child will get removed. 55 * of another parent the child will get removed.
55 * The ownership of child gets transfered. 56 * The ownership of child gets transfered.
56 * 57 *
57 */ 58 */
58 void insertAfter( XMLElement *newChild, XMLElement *refChild ); 59 void insertAfter( XMLElement *newChild, XMLElement *refChild );
59 60
60 /** same as insertAfter but the element get's inserted before refChild. 61 /** same as insertAfter but the element get's inserted before refChild.
61 * 62 *
62 */ 63 */
63 void insertBefore( XMLElement *newChild, XMLElement *refChild ); 64 void insertBefore( XMLElement *newChild, XMLElement *refChild );
64 65
65 /** removeChild removes the child from the XMLElement. 66 /** removeChild removes the child from the XMLElement.
66 * The ownership gets dropped. You need to delete the 67 * The ownership gets dropped. You need to delete the
67 * child yourself. 68 * child yourself.
68 */ 69 */
69 void removeChild( XMLElement *child ); 70 void removeChild( XMLElement *child );
70 71
71 /** parent() returns the parent of this XMLElement 72 /** parent() returns the parent of this XMLElement
72 * If there is no parent 0l gets returned 73 * If there is no parent 0l gets returned
73 */ 74 */
74 XMLElement *parent() const { return m_parent; } 75 XMLElement *parent() const { return m_parent; }
75 XMLElement *firstChild() const { return m_first; } 76 XMLElement *firstChild() const { return m_first; }
76 XMLElement *nextChild() const { return m_next; } 77 XMLElement *nextChild() const { return m_next; }
77 XMLElement *prevChild() const { return m_prev; } 78 XMLElement *prevChild() const { return m_prev; }
78 XMLElement *lastChild() const { return m_last; } 79 XMLElement *lastChild() const { return m_last; }
79 80
80 void setTagName( const QString &tag ) { m_tag = tag; } 81 void setTagName( const QString &tag ) { m_tag = tag; }
81 QString tagName() const { return m_tag; } 82 QString tagName() const { return m_tag; }
82 83
83 void setValue( const QString &val ) { m_value = val; } 84 void setValue( const QString &val ) { m_value = val; }
84 QString value() const { return m_value; } 85 QString value() const { return m_value; }
85 86
86 void setAttributes( const AttributeMap &attrs ) { m_attributes = attrs; } 87 void setAttributes( const AttributeMap &attrs ) { m_attributes = attrs; }
87 AttributeMap attributes() const { return m_attributes; } 88 AttributeMap attributes() const { return m_attributes; }
88 AttributeMap &attributes() { return m_attributes; } 89 AttributeMap &attributes() { return m_attributes; }
89 90
90 QString attribute( const QString & ) const; 91 QString attribute( const QString & ) const;
91 void setAttribute( const QString &attr, const QString &value ); 92 void setAttribute( const QString &attr, const QString &value );
92 void save( QTextStream &stream, uint indent = 0 ); 93 void save( QTextStream &stream, uint indent = 0 );
93 94
94 XMLElement *namedItem( const QString &name ); 95 XMLElement *namedItem( const QString &name );
95 96
96 XMLElement *clone() const; 97 XMLElement *clone() const;
97 98
98 static XMLElement *load( const QString &fileName ); 99 static XMLElement *load( const QString &fileName );
99 100
100private: 101private:
101 QString m_tag; 102 QString m_tag;
102 QString m_value; 103 QString m_value;
103 AttributeMap m_attributes; 104 AttributeMap m_attributes;
104 105
105 XMLElement *m_parent; 106 XMLElement *m_parent;
106 XMLElement *m_next; 107 XMLElement *m_next;
107 XMLElement *m_prev; 108 XMLElement *m_prev;
108 XMLElement *m_first; 109 XMLElement *m_first;
109 XMLElement *m_last; 110 XMLElement *m_last;
110 111
111 XMLElement( const XMLElement &rhs ); 112 XMLElement( const XMLElement &rhs );
112 XMLElement &operator=( const XMLElement &rhs ); 113 XMLElement &operator=( const XMLElement &rhs );
113 class Private; 114 class Private;
114 Private* d; 115 Private* d;
115}; 116};
116 117
118}
119}
117} // namespace Opie 120} // namespace Opie
118 121
119#endif 122#endif
diff --git a/libopie2/opieui/big-screen/obigscreen_p.h b/libopie2/opieui/big-screen/obigscreen_p.h
index db8fc83..a85a56c 100644
--- a/libopie2/opieui/big-screen/obigscreen_p.h
+++ b/libopie2/opieui/big-screen/obigscreen_p.h
@@ -1,28 +1,31 @@
1#ifndef OPIE_BIG_SCREEN_PRIVATE 1#ifndef OPIE_BIG_SCREEN_PRIVATE
2#define OPIE_BIG_SCREEN_PRIVATE 2#define OPIE_BIG_SCREEN_PRIVATE
3 3
4/* QT */ 4/* QT */
5#include <qstring.h> 5#include <qstring.h>
6 6
7class QWidget; 7class QWidget;
8 8
9namespace Opie 9namespace Opie {
10{ 10namespace Ui {
11namespace Private{
11 12
12struct OSplitterContainer 13struct OSplitterContainer
13{ 14{
14 bool operator==( const OSplitterContainer& o) const 15 bool operator==( const OSplitterContainer& o) const
15 { 16 {
16 if (widget != o.widget ) return false; 17 if (widget != o.widget ) return false;
17 if (icon != o.icon ) return false; 18 if (icon != o.icon ) return false;
18 if (name != o.name ) return false; 19 if (name != o.name ) return false;
19 return true; 20 return true;
20 } 21 }
21 QWidget* widget; 22 QWidget* widget;
22 QString icon; 23 QString icon;
23 QString name; 24 QString name;
24}; 25};
25 26
26}; 27}
28}
29}
27 30
28#endif 31#endif
diff --git a/libopie2/opieui/big-screen/osplitter.cpp b/libopie2/opieui/big-screen/osplitter.cpp
index 89f3793..bcfd3a6 100644
--- a/libopie2/opieui/big-screen/osplitter.cpp
+++ b/libopie2/opieui/big-screen/osplitter.cpp
@@ -1,86 +1,87 @@
1/* 1/*
2               =. This file is part of the OPIE Project 2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2003 hOlgAr <zecke@handhelds.org> 3             .=l. Copyright (c) 2003 hOlgAr <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#include "osplitter.h" 29#include "osplitter.h"
30 30
31/* OPIE */ 31/* OPIE */
32#include <opie2/otabwidget.h> 32#include <opie2/otabwidget.h>
33 33
34/* QT */ 34/* QT */
35#include <qvaluelist.h> 35#include <qvaluelist.h>
36#include <qvbox.h> 36#include <qvbox.h>
37 37
38using namespace Opie; 38using namespace Opie::Ui;
39using namespace Opie::Ui::Private;
39 40
40/** 41/**
41 * 42 *
42 * This is the constructor of OSplitter 43 * This is the constructor of OSplitter
43 * You might want to call setSizeChange to tell 44 * You might want to call setSizeChange to tell
44 * OSplitter to change its layout when a specefic 45 * OSplitter to change its layout when a specefic
45 * mark was crossed. OSplitter sets a default value. 46 * mark was crossed. OSplitter sets a default value.
46 * 47 *
47 * You cann add widget with addWidget to the OSplitter. 48 * You cann add widget with addWidget to the OSplitter.
48 * OSplitter supports also grouping of Splitters where they 49 * OSplitter supports also grouping of Splitters where they
49 * can share one OTabBar in small screen mode. This can be used 50 * can share one OTabBar in small screen mode. This can be used
50 * for email clients like vies but see the example. 51 * for email clients like vies but see the example.
51 * 52 *
52 * @param orient The orientation wether to layout horizontal or vertical 53 * @param orient The orientation wether to layout horizontal or vertical
53 * @param parent The parent of this widget 54 * @param parent The parent of this widget
54 * @param name The name passed on to QObject 55 * @param name The name passed on to QObject
55 * @param fl Additional widgets flags passed to QWidget 56 * @param fl Additional widgets flags passed to QWidget
56 * 57 *
57 * @short single c'tor of the OSplitter 58 * @short single c'tor of the OSplitter
58 */ 59 */
59OSplitter::OSplitter( Orientation orient, QWidget* parent, const char* name, WFlags fl ) 60OSplitter::OSplitter( Orientation orient, QWidget* parent, const char* name, WFlags fl )
60 : QFrame( parent, name, fl ) 61 : QFrame( parent, name, fl )
61{ 62{
62 m_orient = orient; 63 m_orient = orient;
63 m_hbox = 0; 64 m_hbox = 0;
64 m_size_policy = 330; 65 m_size_policy = 330;
65 setFontPropagation( AllChildren ); 66 setFontPropagation( AllChildren );
66 setPalettePropagation( AllChildren ); 67 setPalettePropagation( AllChildren );
67 68
68 /* start by default with the tab widget */ 69 /* start by default with the tab widget */
69 m_tabWidget = 0; 70 m_tabWidget = 0;
70 m_parentTab = 0; 71 m_parentTab = 0;
71 changeTab(); 72 changeTab();
72 73
73} 74}
74 75
75 76
76/** 77/**
77 * Destructor destructs this object and cleans up. All child 78 * Destructor destructs this object and cleans up. All child
78 * widgets will be deleted 79 * widgets will be deleted
79 * @see addWidget 80 * @see addWidget
80 */ 81 */
81OSplitter::~OSplitter() 82OSplitter::~OSplitter()
82{ 83{
83 qWarning("Deleted Splitter"); 84 qWarning("Deleted Splitter");
84 m_splitter.setAutoDelete( true ); 85 m_splitter.setAutoDelete( true );
85 m_splitter.clear(); 86 m_splitter.clear();
86 87
@@ -123,142 +124,142 @@ QString OSplitter::iconName()const
123} 124}
124 125
125/** 126/**
126 * returns the label set with setLabel 127 * returns the label set with setLabel
127 * @see setLabel 128 * @see setLabel
128 */ 129 */
129QString OSplitter::label()const 130QString OSplitter::label()const
130{ 131{
131 return m_name; 132 return m_name;
132} 133}
133 134
134/** 135/**
135 * This function sets the size change policy of the splitter. 136 * This function sets the size change policy of the splitter.
136 * If this size marked is crossed the splitter will relayout. 137 * If this size marked is crossed the splitter will relayout.
137 * Note: that depending on the set Orientation it'll either look 138 * Note: that depending on the set Orientation it'll either look
138 * at the width or height. 139 * at the width or height.
139 * Note: If you want to from side to side view to tabbed view you need 140 * Note: If you want to from side to side view to tabbed view you need
140 * to make sure that the size you supply is not smaller than the minimum 141 * to make sure that the size you supply is not smaller than the minimum
141 * size of your added widgets. Note that if you use widgets like QComboBoxes 142 * size of your added widgets. Note that if you use widgets like QComboBoxes
142 * you need to teach them to accept smaller sizes as well @see QWidget::setSizePolicy 143 * you need to teach them to accept smaller sizes as well @see QWidget::setSizePolicy
143 * 144 *
144 * @param width_height The mark that will be watched. Interpreted depending on the Orientation of the Splitter. 145 * @param width_height The mark that will be watched. Interpreted depending on the Orientation of the Splitter.
145 * @return void 146 * @return void
146 */ 147 */
147void OSplitter::setSizeChange( int width_height ) 148void OSplitter::setSizeChange( int width_height )
148{ 149{
149 m_size_policy = width_height; 150 m_size_policy = width_height;
150 QSize sz(width(), height() ); 151 QSize sz(width(), height() );
151 QResizeEvent ev(sz, sz ); 152 QResizeEvent ev(sz, sz );
152 resizeEvent(&ev); 153 resizeEvent(&ev);
153} 154}
154 155
155/** 156/**
156 * This functions allows to add another OSplitter and to share 157 * This functions allows to add another OSplitter and to share
157 * the OTabBar in small screen mode. The ownerships gets transfered. 158 * the OTabBar in small screen mode. The ownerships gets transfered.
158 * OSplitters are always added after normal widget items 159 * OSplitters are always added after normal widget items
159 */ 160 */
160void OSplitter::addWidget( OSplitter* split ) 161void OSplitter::addWidget( OSplitter* split )
161{ 162{
162 m_splitter.append( split ); 163 m_splitter.append( split );
163 164
164 /* 165 /*
165 * set tab widget 166 * set tab widget
166 */ 167 */
167 if (m_tabWidget ) 168 if (m_tabWidget )
168 setTabWidget( m_parentTab ); 169 setTabWidget( m_parentTab );
169 else 170 else
170 { 171 {
171 Opie::OSplitterContainer con; 172 OSplitterContainer con;
172 con.widget =split; 173 con.widget =split;
173 addToBox( con ); 174 addToBox( con );
174 } 175 }
175} 176}
176 177
177/* 178/*
178 * If in a tab it should be removed 179 * If in a tab it should be removed
179 * and if in a hbox the reparent kills it too 180 * and if in a hbox the reparent kills it too
180 */ 181 */
181/** 182/**
182 * This removes the splitter again. You currently need to call this 183 * This removes the splitter again. You currently need to call this
183 * before you delete or otherwise you can get mem corruption 184 * before you delete or otherwise you can get mem corruption
184 * or other weird behaviour. 185 * or other weird behaviour.
185 * Owner ship gets transfered back to you it's current parent 186 * Owner ship gets transfered back to you it's current parent
186 * is 0 187 * is 0
187 */ 188 */
188void OSplitter::removeWidget( OSplitter* split) 189void OSplitter::removeWidget( OSplitter* split)
189{ 190{
190 split->setTabWidget( 0 ); 191 split->setTabWidget( 0 );
191 split->reparent( 0, 0, QPoint(0, 0) ); 192 split->reparent( 0, 0, QPoint(0, 0) );
192} 193}
193 194
194/** 195/**
195 * Adds a widget to the Splitter. The widgets gets inserted 196 * Adds a widget to the Splitter. The widgets gets inserted
196 * at the end of either the Box or TabWidget. 197 * at the end of either the Box or TabWidget.
197 * Ownership gets transfered and the widgets gets reparented. 198 * Ownership gets transfered and the widgets gets reparented.
198 * Note: icon and label is only available on small screensizes 199 * Note: icon and label is only available on small screensizes
199 * if size is smaller than the mark 200 * if size is smaller than the mark
200 * Warning: No null checking of the widget is done. Only on debug 201 * Warning: No null checking of the widget is done. Only on debug
201 * a message will be outputtet 202 * a message will be outputtet
202 * 203 *
203 * @param wid The widget which will be added 204 * @param wid The widget which will be added
204 * @param icon The icon of the possible Tab 205 * @param icon The icon of the possible Tab
205 * @param label The label of the possible Tab 206 * @param label The label of the possible Tab
206 */ 207 */
207void OSplitter::addWidget( QWidget* wid, const QString& icon, const QString& label ) 208void OSplitter::addWidget( QWidget* wid, const QString& icon, const QString& label )
208{ 209{
209#ifdef DEBUG 210#ifdef DEBUG
210 if (!wid ) 211 if (!wid )
211 { 212 {
212 qWarning("Widget is not valid!"); 213 qWarning("Widget is not valid!");
213 return; 214 return;
214 } 215 }
215#endif 216#endif
216 Opie::OSplitterContainer cont; 217 OSplitterContainer cont;
217 cont.widget = wid; 218 cont.widget = wid;
218 cont.icon =icon; 219 cont.icon =icon;
219 cont.name = label; 220 cont.name = label;
220 221
221 m_container.append( cont ); 222 m_container.append( cont );
222 223
223 /* 224 /*
224 * 225 *
225 */ 226 */
226 if (!m_splitter.isEmpty() && (m_tabWidget || m_parentTab ) ) 227 if (!m_splitter.isEmpty() && (m_tabWidget || m_parentTab ) )
227 setTabWidget( m_parentTab ); 228 setTabWidget( m_parentTab );
228 else 229 else
229 { 230 {
230 if (m_hbox ) 231 if (m_hbox )
231 addToBox( cont ); 232 addToBox( cont );
232 else 233 else
233 addToTab( cont ); 234 addToTab( cont );
234 } 235 }
235} 236}
236 237
237 238
238/** 239/**
239 * Removes the widget from the tab widgets if necessary. 240 * Removes the widget from the tab widgets if necessary.
240 * OSplitter drops ownership of this widget and the widget 241 * OSplitter drops ownership of this widget and the widget
241 * will be reparented i tto 0. 242 * will be reparented i tto 0.
242 * The widget will not be deleted. 243 * The widget will not be deleted.
243 * 244 *
244 * @param w The widget to be removed 245 * @param w The widget to be removed
245 */ 246 */
246void OSplitter::removeWidget( QWidget* w) 247void OSplitter::removeWidget( QWidget* w)
247{ 248{
248 ContainerList::Iterator it; 249 ContainerList::Iterator it;
249 for ( it = m_container.begin(); it != m_container.end(); ++it ) 250 for ( it = m_container.begin(); it != m_container.end(); ++it )
250 if ( (*it).widget == w ) 251 if ( (*it).widget == w )
251 break; 252 break;
252 253
253 if (it == m_container.end() ) 254 if (it == m_container.end() )
254 return; 255 return;
255 256
256 257
257 /* only tab needs to be removed.. box recognizes it */ 258 /* only tab needs to be removed.. box recognizes it */
258 if ( !m_hbox ) 259 if ( !m_hbox )
259 removeFromTab( w ); 260 removeFromTab( w );
260 261
261 262
262 /* Find reparent it and remove it from our list */ 263 /* Find reparent it and remove it from our list */
263 264
264 w->reparent( 0, 0, QPoint(0, 0)); 265 w->reparent( 0, 0, QPoint(0, 0));
@@ -351,111 +352,111 @@ QSize OSplitter::minimumSizeHint()const
351 return QFrame::minimumSizeHint(); 352 return QFrame::minimumSizeHint();
352 if (m_hbox) 353 if (m_hbox)
353 return m_hbox->sizeHint(); 354 return m_hbox->sizeHint();
354 else 355 else
355 return m_tabWidget->sizeHint(); 356 return m_tabWidget->sizeHint();
356} 357}
357#endif 358#endif
358 359
359/** 360/**
360 * @reimplemented for internal reasons 361 * @reimplemented for internal reasons
361 */ 362 */
362void OSplitter::resizeEvent( QResizeEvent* res ) 363void OSplitter::resizeEvent( QResizeEvent* res )
363{ 364{
364 QFrame::resizeEvent( res ); 365 QFrame::resizeEvent( res );
365 /* 366 /*
366 * 367 *
367 */ 368 */
368 // qWarning("Old size was width = %d height = %d", res->oldSize().width(), res->oldSize().height() ); 369 // qWarning("Old size was width = %d height = %d", res->oldSize().width(), res->oldSize().height() );
369 bool mode = true; 370 bool mode = true;
370 qWarning("New size is width = %d height = %d %s", res->size().width(), res->size().height(), name() ); 371 qWarning("New size is width = %d height = %d %s", res->size().width(), res->size().height(), name() );
371 if ( res->size().width() > m_size_policy && 372 if ( res->size().width() > m_size_policy &&
372 m_orient == Horizontal ) 373 m_orient == Horizontal )
373 { 374 {
374 changeHBox(); 375 changeHBox();
375 mode = false; 376 mode = false;
376 } 377 }
377 else if ( (res->size().width() <= m_size_policy && 378 else if ( (res->size().width() <= m_size_policy &&
378 m_orient == Horizontal ) || 379 m_orient == Horizontal ) ||
379 (res->size().height() <= m_size_policy && 380 (res->size().height() <= m_size_policy &&
380 m_orient == Vertical ) ) 381 m_orient == Vertical ) )
381 { 382 {
382 changeTab(); 383 changeTab();
383 } 384 }
384 else if ( res->size().height() > m_size_policy && 385 else if ( res->size().height() > m_size_policy &&
385 m_orient == Vertical ) 386 m_orient == Vertical )
386 { 387 {
387 qWarning("Changng to vbox %s", name() ); 388 qWarning("Changng to vbox %s", name() );
388 changeVBox(); 389 changeVBox();
389 mode = false; 390 mode = false;
390 } 391 }
391 392
392 emit sizeChanged(mode, m_orient ); 393 emit sizeChanged(mode, m_orient );
393} 394}
394 395
395/* 396/*
396 * Adds a container to a tab either the parent tab 397 * Adds a container to a tab either the parent tab
397 * or our own 398 * or our own
398 */ 399 */
399void OSplitter::addToTab( const Opie::OSplitterContainer& con ) 400void OSplitter::addToTab( const Opie::Ui::Private::OSplitterContainer& con )
400{ 401{
401 QWidget *wid = con.widget; 402 QWidget *wid = con.widget;
402 // not needed widgetstack will reparent as well wid.reparent(m_tabWidget, wid->getWFlags(), QPoint(0, 0) ); 403 // not needed widgetstack will reparent as well wid.reparent(m_tabWidget, wid->getWFlags(), QPoint(0, 0) );
403 if (m_parentTab ) 404 if (m_parentTab )
404 m_parentTab->addTab( wid, con.icon, con.name ); 405 m_parentTab->addTab( wid, con.icon, con.name );
405 else 406 else
406 m_tabWidget->addTab( wid, con.icon, con.name ); 407 m_tabWidget->addTab( wid, con.icon, con.name );
407} 408}
408 409
409 410
410/* 411/*
411 * adds a container to the box 412 * adds a container to the box
412 */ 413 */
413void OSplitter::addToBox( const Opie::OSplitterContainer& con ) 414void OSplitter::addToBox( const Opie::Ui::Private::OSplitterContainer& con )
414{ 415{
415 QWidget* wid = con.widget; 416 QWidget* wid = con.widget;
416 wid->reparent(m_hbox, 0, QPoint(0, 0) ); 417 wid->reparent(m_hbox, 0, QPoint(0, 0) );
417} 418}
418 419
419 420
420/* 421/*
421 * Removes a widget from the tab 422 * Removes a widget from the tab
422 */ 423 */
423void OSplitter::removeFromTab( QWidget* wid ) 424void OSplitter::removeFromTab( QWidget* wid )
424{ 425{
425 if (m_parentTab ) 426 if (m_parentTab )
426 m_parentTab->removePage( wid ); 427 m_parentTab->removePage( wid );
427 else 428 else
428 m_tabWidget->removePage( wid ); 429 m_tabWidget->removePage( wid );
429} 430}
430 431
431/* 432/*
432 * switches over to a OTabWidget layout 433 * switches over to a OTabWidget layout
433 * it is recursive 434 * it is recursive
434 */ 435 */
435void OSplitter::changeTab() 436void OSplitter::changeTab()
436{ 437{
437 /* if we're the owner of the tab widget */ 438 /* if we're the owner of the tab widget */
438 if (m_tabWidget ) 439 if (m_tabWidget )
439 { 440 {
440 raise(); 441 raise();
441 show(); 442 show();
442 m_tabWidget->setGeometry( frameRect() ); 443 m_tabWidget->setGeometry( frameRect() );
443 return; 444 return;
444 } 445 }
445 446
446 qWarning(" New Tab Widget %s", name() ); 447 qWarning(" New Tab Widget %s", name() );
447 /* 448 /*
448 * and add all widgets this will reparent them 449 * and add all widgets this will reparent them
449 * delete m_hbox set it to 0 450 * delete m_hbox set it to 0
450 * 451 *
451 */ 452 */
452 OTabWidget *tab; 453 OTabWidget *tab;
453 if ( m_parentTab ) 454 if ( m_parentTab )
454 { 455 {
455 hide(); 456 hide();
456 tab = m_parentTab; 457 tab = m_parentTab;
457 /* expensive but needed cause we're called from setTabWidget and resizeEvent*/ 458 /* expensive but needed cause we're called from setTabWidget and resizeEvent*/
458 if (!m_container.isEmpty() ) 459 if (!m_container.isEmpty() )
459 { 460 {
460 ContainerList::Iterator it = m_container.begin(); 461 ContainerList::Iterator it = m_container.begin();
461 for (; it != m_container.end(); ++it ) 462 for (; it != m_container.end(); ++it )
@@ -500,97 +501,97 @@ void OSplitter::changeHBox()
500 if (m_hbox ) 501 if (m_hbox )
501 { 502 {
502 m_hbox->setGeometry( frameRect() ); 503 m_hbox->setGeometry( frameRect() );
503 return; 504 return;
504 } 505 }
505 506
506 qWarning("new HBox %s", name() ); 507 qWarning("new HBox %s", name() );
507 m_hbox = new QHBox( this ); 508 m_hbox = new QHBox( this );
508 commonChangeBox(); 509 commonChangeBox();
509} 510}
510 511
511void OSplitter::changeVBox() 512void OSplitter::changeVBox()
512{ 513{
513 if (m_hbox ) 514 if (m_hbox )
514 { 515 {
515 m_hbox->setGeometry( frameRect() ); 516 m_hbox->setGeometry( frameRect() );
516 return; 517 return;
517 } 518 }
518 519
519 qWarning("New VBOX %s", name() ); 520 qWarning("New VBOX %s", name() );
520 m_hbox = new QVBox( this ); 521 m_hbox = new QVBox( this );
521 522
522 commonChangeBox(); 523 commonChangeBox();
523 524
524} 525}
525 526
526/* 527/*
527 * common box code 528 * common box code
528 * first remove and add children 529 * first remove and add children
529 * the other splitters 530 * the other splitters
530 * it is recursive as well due the call to setTabWidget 531 * it is recursive as well due the call to setTabWidget
531 */ 532 */
532void OSplitter::commonChangeBox() 533void OSplitter::commonChangeBox()
533{ 534{
534 qWarning(" Name of Splitters is %s", name() ); 535 qWarning(" Name of Splitters is %s", name() );
535 536
536 for (ContainerList::Iterator it = m_container.begin(); it != m_container.end(); ++it ) 537 for (ContainerList::Iterator it = m_container.begin(); it != m_container.end(); ++it )
537 { 538 {
538 /* only if parent tab.. m_tabWidgets gets deleted and would do that as well */ 539 /* only if parent tab.. m_tabWidgets gets deleted and would do that as well */
539 if (m_parentTab ) 540 if (m_parentTab )
540 removeFromTab( (*it).widget ); 541 removeFromTab( (*it).widget );
541 qWarning("Adding to box %s", (*it).name.latin1() ); 542 qWarning("Adding to box %s", (*it).name.latin1() );
542 addToBox( (*it) ); 543 addToBox( (*it) );
543 } 544 }
544 for ( OSplitter* split = m_splitter.first(); split; split = m_splitter.next() ) 545 for ( OSplitter* split = m_splitter.first(); split; split = m_splitter.next() )
545 { 546 {
546 /* tell them the world had changed */ 547 /* tell them the world had changed */
547 split->setTabWidget( 0 ); 548 split->setTabWidget( 0 );
548 Opie::OSplitterContainer con; 549 OSplitterContainer con;
549 con.widget = split; 550 con.widget = split;
550 // con.widget = split->m_tabWidget ? static_cast<QWidget*>(split->m_tabWidget) 551 // con.widget = split->m_tabWidget ? static_cast<QWidget*>(split->m_tabWidget)
551 // : static_cast<QWidget*>(split->m_hbox); 552 // : static_cast<QWidget*>(split->m_hbox);
552 addToBox( con ); 553 addToBox( con );
553 } 554 }
554 555
555 556
556 557
557 if (m_parentTab ) 558 if (m_parentTab )
558 m_parentTab->addTab(m_hbox, iconName(), label() ); 559 m_parentTab->addTab(m_hbox, iconName(), label() );
559 else 560 else
560 { 561 {
561 qWarning(" setting Box geometry for %s", name() ); 562 qWarning(" setting Box geometry for %s", name() );
562 m_hbox->setGeometry( frameRect() ); 563 m_hbox->setGeometry( frameRect() );
563 m_hbox->show(); 564 m_hbox->show();
564 delete m_tabWidget; 565 delete m_tabWidget;
565 m_tabWidget = 0; 566 m_tabWidget = 0;
566 show(); // also show this widget 567 show(); // also show this widget
567 } 568 }
568} 569}
569 570
570/* 571/*
571 * sets the tabwidget, removes tabs, and relayouts the widget 572 * sets the tabwidget, removes tabs, and relayouts the widget
572 */ 573 */
573void OSplitter::setTabWidget( OTabWidget* wid) 574void OSplitter::setTabWidget( OTabWidget* wid)
574{ 575{
575 /* clean up cause m_parentTab will not be available for us */ 576 /* clean up cause m_parentTab will not be available for us */
576 if ( m_parentTab ) 577 if ( m_parentTab )
577 { 578 {
578 if (m_hbox ) 579 if (m_hbox )
579 m_parentTab->removePage( m_hbox ); 580 m_parentTab->removePage( m_hbox );
580 else if (!m_container.isEmpty() ) 581 else if (!m_container.isEmpty() )
581 { 582 {
582 ContainerList::Iterator it = m_container.begin(); 583 ContainerList::Iterator it = m_container.begin();
583 for ( ; it != m_container.end(); ++it ) 584 for ( ; it != m_container.end(); ++it )
584 m_parentTab->removePage( (*it).widget ); 585 m_parentTab->removePage( (*it).widget );
585 } 586 }
586 } 587 }
587 /* the parent Splitter changed so either make us indepent or dep */ 588 /* the parent Splitter changed so either make us indepent or dep */
588 589
589 m_parentTab = wid; 590 m_parentTab = wid;
590 591
591 QWidget *tab = m_tabWidget; 592 QWidget *tab = m_tabWidget;
592 QWidget *box = m_hbox; 593 QWidget *box = m_hbox;
593 m_hbox = 0; m_tabWidget = 0; 594 m_hbox = 0; m_tabWidget = 0;
594 595
595 if ( layoutMode() ) 596 if ( layoutMode() )
596 changeTab(); 597 changeTab();
diff --git a/libopie2/opieui/big-screen/osplitter.h b/libopie2/opieui/big-screen/osplitter.h
index 2daae7f..7b5ea53 100644
--- a/libopie2/opieui/big-screen/osplitter.h
+++ b/libopie2/opieui/big-screen/osplitter.h
@@ -1,150 +1,151 @@
1/* 1/*
2               =. This file is part of the OPIE Project 2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2003 hOlgAr <zecke@handhelds.org> 3             .=l. Copyright (c) 2003 hOlgAr <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#ifndef OSPLITTER_H 29#ifndef OSPLITTER_H
30#define OSPLITTER_H 30#define OSPLITTER_H
31 31
32#include "obigscreen_p.h" 32#include "obigscreen_p.h"
33 33
34/* QT */ 34/* QT */
35#include <qframe.h> 35#include <qframe.h>
36#include <qlist.h> 36#include <qlist.h>
37#include <qstring.h> 37#include <qstring.h>
38#include <qvaluelist.h> 38#include <qvaluelist.h>
39 39
40class QHBox; 40class QHBox;
41 41
42//template class QValueList<Opie::OSplitterContainer>; 42//template class QValueList<Opie::OSplitterContainer>;
43 43
44/* 44/*
45 * TODO 45 * TODO
46 * -check API docu 46 * -check API docu
47 * -one more example 47 * -one more example
48 * -allow inserting at a position 48 * -allow inserting at a position
49 */ 49 */
50 50
51namespace Opie 51namespace Opie{
52{ 52namespace Ui {
53class OTabWidget; 53class OTabWidget;
54 54
55/** 55/**
56 * 56 *
57 * If you've widgets that could be placed side by side but you think 57 * If you've widgets that could be placed side by side but you think
58 * on small resolutions is not enough place but it would really make sense 58 * on small resolutions is not enough place but it would really make sense
59 * on bigger resolutions this class will help you. 59 * on bigger resolutions this class will help you.
60 * You can add as many widgets you want to it. Set a poliy on which width/height it 60 * You can add as many widgets you want to it. Set a poliy on which width/height it
61 * should switch the layout. 61 * should switch the layout.
62 * You can either say to place widgets vertical or horizontal. 62 * You can either say to place widgets vertical or horizontal.
63 * This class uses QHBox, QVBox and QTAbWidget internally. 63 * This class uses QHBox, QVBox and QTAbWidget internally.
64 * OSplitter takes ownership of the widgets 64 * OSplitter takes ownership of the widgets
65 * 65 *
66 * @since 1.2 66 * @since 1.2
67 * 67 *
68 * @short a small dynamically changing its layout to store two or more widgets side by side 68 * @short a small dynamically changing its layout to store two or more widgets side by side
69 * @version 0.1 69 * @version 0.1
70 * @author zecke 70 * @author zecke
71 */ 71 */
72class OSplitter : public QFrame 72class OSplitter : public QFrame
73{ 73{
74 Q_OBJECT 74 Q_OBJECT
75public: 75public:
76 typedef QValueList<Opie::OSplitterContainer> ContainerList; 76 typedef QValueList<Opie::Ui::Private::OSplitterContainer> ContainerList;
77 OSplitter( Qt::Orientation = Horizontal, QWidget *parent = 0, 77 OSplitter( Qt::Orientation = Horizontal, QWidget *parent = 0,
78 const char* name = 0, WFlags fl = 0 ); 78 const char* name = 0, WFlags fl = 0 );
79 ~OSplitter(); 79 ~OSplitter();
80 80
81 void setLabel( const QString& name ); 81 void setLabel( const QString& name );
82 void setIconName( const QString& name ); 82 void setIconName( const QString& name );
83 QString label()const; 83 QString label()const;
84 QString iconName()const; 84 QString iconName()const;
85 85
86 void setSizeChange( int width_height ); 86 void setSizeChange( int width_height );
87 87
88 void addWidget( OSplitter* splitter ); 88 void addWidget( OSplitter* splitter );
89 void addWidget( QWidget* wid, const QString& icon, const QString& label ); 89 void addWidget( QWidget* wid, const QString& icon, const QString& label );
90 void removeWidget( QWidget* ); 90 void removeWidget( QWidget* );
91 void removeWidget( OSplitter* ); 91 void removeWidget( OSplitter* );
92 92
93 void setCurrentWidget( QWidget* ); 93 void setCurrentWidget( QWidget* );
94 void setCurrentWidget( const QString& label ); 94 void setCurrentWidget( const QString& label );
95 void setCurrentWidget( int ); 95 void setCurrentWidget( int );
96 QWidget* currentWidget()const; 96 QWidget* currentWidget()const;
97 97
98 98
99signals: 99signals:
100 /** 100 /**
101 * Emitted if in tab and comes directly from the tab widget 101 * Emitted if in tab and comes directly from the tab widget
102 * 102 *
103 */ 103 */
104 void currentChanged( QWidget* ); 104 void currentChanged( QWidget* );
105 105
106 /** 106 /**
107 * emitted whenever a border is crossed 107 * emitted whenever a border is crossed
108 * true if in small screen mode 108 * true if in small screen mode
109 * false if in bigscreen 109 * false if in bigscreen
110 * this signal is emitted after the layout switch 110 * this signal is emitted after the layout switch
111 * @param b The layout mode 111 * @param b The layout mode
112 * @param ori The orientation 112 * @param ori The orientation
113 */ 113 */
114 void sizeChanged( bool b, Orientation ori); 114 void sizeChanged( bool b, Orientation ori);
115public: 115public:
116 // QSize sizeHint()const; 116 // QSize sizeHint()const;
117 // QSize minimumSizeHint()const; 117 // QSize minimumSizeHint()const;
118 118
119protected: 119protected:
120 void resizeEvent( QResizeEvent* ); 120 void resizeEvent( QResizeEvent* );
121 121
122private: 122private:
123 /* true if OTabMode */ 123 /* true if OTabMode */
124 bool layoutMode()const; 124 bool layoutMode()const;
125 // void reparentAll(); 125 // void reparentAll();
126 void setTabWidget( OTabWidget*); 126 void setTabWidget( OTabWidget*);
127 void addToTab( const Opie::OSplitterContainer& ); 127 void addToTab( const Opie::Ui::Private::OSplitterContainer& );
128 void addToBox( const Opie::OSplitterContainer& ); 128 void addToBox( const Opie::Ui::Private::OSplitterContainer& );
129 void removeFromTab( QWidget* ); 129 void removeFromTab( QWidget* );
130 void changeTab(); 130 void changeTab();
131 void changeHBox(); 131 void changeHBox();
132 void changeVBox(); 132 void changeVBox();
133 void commonChangeBox(); 133 void commonChangeBox();
134 QHBox *m_hbox; 134 QHBox *m_hbox;
135 OTabWidget *m_tabWidget; 135 OTabWidget *m_tabWidget;
136 OTabWidget *m_parentTab; 136 OTabWidget *m_parentTab;
137 Orientation m_orient; 137 Orientation m_orient;
138 int m_size_policy; 138 int m_size_policy;
139 139
140 ContainerList m_container; 140 ContainerList m_container;
141 QList<OSplitter> m_splitter; 141 QList<OSplitter> m_splitter;
142 142
143 QString m_icon, m_name; 143 QString m_icon, m_name;
144 144
145 struct Private; 145 struct Private;
146 Private *d; 146 Private *d;
147}; 147};
148}; 148}
149}
149 150
150#endif 151#endif
diff --git a/libopie2/opieui/big-screen/owidgetstack.cpp b/libopie2/opieui/big-screen/owidgetstack.cpp
index 57e97e3..a0a6355 100644
--- a/libopie2/opieui/big-screen/owidgetstack.cpp
+++ b/libopie2/opieui/big-screen/owidgetstack.cpp
@@ -1,87 +1,87 @@
1/* 1/*
2               =. This file is part of the OPIE Project 2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2003 hOlgAr <zecke@handhelds.org> 3             .=l. Copyright (c) 2003 hOlgAr <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#include "owidgetstack.h" 29#include "owidgetstack.h"
30 30
31/* QT */ 31/* QT */
32#include <qapplication.h> 32#include <qapplication.h>
33#include <qwidgetstack.h> 33#include <qwidgetstack.h>
34 34
35namespace { 35namespace Opie {
36namespace Ui {
36 const int mode_size = 330; 37 const int mode_size = 330;
37}
38 38
39using namespace Opie; 39
40 40
41/** 41/**
42 * This is the standard widget. For simple usage see the example. Normally this widget 42 * This is the standard widget. For simple usage see the example. Normally this widget
43 * is the central widget of a QMainWindow. 43 * is the central widget of a QMainWindow.
44 * Use removeWidget before you delete a widget yourself. OWidgetStack does not 44 * Use removeWidget before you delete a widget yourself. OWidgetStack does not
45 * yet recognize removal of children. 45 * yet recognize removal of children.
46 * 46 *
47 * @param parent The parent widget. It maybe 0 but then you need to take care of deletion. 47 * @param parent The parent widget. It maybe 0 but then you need to take care of deletion.
48 * Or you use QPEApplication::showMainWidget(). 48 * Or you use QPEApplication::showMainWidget().
49 * @param name Name will be passed on to QObject 49 * @param name Name will be passed on to QObject
50 * @param fl Additional window flags passed to QFrame. see @Qt::WFlags 50 * @param fl Additional window flags passed to QFrame. see @Qt::WFlags
51 */ 51 */
52OWidgetStack::OWidgetStack( QWidget* parent, const char* name, WFlags fl) 52OWidgetStack::OWidgetStack( QWidget* parent, const char* name, WFlags fl)
53 : QFrame( parent, name, fl ) 53 : QFrame( parent, name, fl )
54{ 54{
55 m_last = m_mWidget = 0; 55 m_last = m_mWidget = 0;
56 m_forced = false; 56 m_forced = false;
57 57
58 QApplication::desktop()->installEventFilter( this ); 58 QApplication::desktop()->installEventFilter( this );
59 setFontPropagation ( AllChildren ); 59 setFontPropagation ( AllChildren );
60 setPalettePropagation( AllChildren ); 60 setPalettePropagation( AllChildren );
61 61
62 /* sets m_mode and initializes more */ 62 /* sets m_mode and initializes more */
63 /* if you change this call change switchTop as well */ 63 /* if you change this call change switchTop as well */
64 m_stack = 0; 64 m_stack = 0;
65 switchStack(); 65 switchStack();
66} 66}
67 67
68/** 68/**
69 * The destructor. It deletes also all added widgets. 69 * The destructor. It deletes also all added widgets.
70 * 70 *
71 */ 71 */
72OWidgetStack::~OWidgetStack() { 72OWidgetStack::~OWidgetStack() {
73 if (m_mode == BigScreen && !m_list.isEmpty() ) { 73 if (m_mode == BigScreen && !m_list.isEmpty() ) {
74 QMap<int, QWidget*>::Iterator it = m_list.begin(); 74 QMap<int, QWidget*>::Iterator it = m_list.begin();
75 for ( ; it != m_list.end(); ++it ) 75 for ( ; it != m_list.end(); ++it )
76 delete it.data(); 76 delete it.data();
77 } 77 }
78 m_list.clear(); 78 m_list.clear();
79 79
80} 80}
81 81
82/** 82/**
83 * return the mode of the desktop. There are currently two modes. SmallScreen 83 * return the mode of the desktop. There are currently two modes. SmallScreen
84 * with a normal PDA resolution and BigScreen with resolutions greater than 84 * with a normal PDA resolution and BigScreen with resolutions greater than
85 * 330 for width and height. 85 * 330 for width and height.
86 * You can also force the mode this widget is in with forceMode() 86 * You can also force the mode this widget is in with forceMode()
87 * Note that NoForce will be never returned from here 87 * Note that NoForce will be never returned from here
@@ -388,48 +388,51 @@ void OWidgetStack::switchStack() {
388 m_stack = new QWidgetStack(this); 388 m_stack = new QWidgetStack(this);
389 389
390 connect(m_stack, SIGNAL(aboutToShow(QWidget*) ), 390 connect(m_stack, SIGNAL(aboutToShow(QWidget*) ),
391 this, SIGNAL(aboutToShow(QWidget*) ) ); 391 this, SIGNAL(aboutToShow(QWidget*) ) );
392 connect(m_stack, SIGNAL(aboutToShow(int) ), 392 connect(m_stack, SIGNAL(aboutToShow(int) ),
393 this, SIGNAL(aboutToShow(int) ) ); 393 this, SIGNAL(aboutToShow(int) ) );
394 394
395 /* now reparent the widgets... luckily QWidgetSatck does most of the work */ 395 /* now reparent the widgets... luckily QWidgetSatck does most of the work */
396 if (m_list.isEmpty() ) 396 if (m_list.isEmpty() )
397 return; 397 return;
398 398
399 QMap<int, QWidget*>::Iterator it = m_list.begin(); 399 QMap<int, QWidget*>::Iterator it = m_list.begin();
400 for ( ; it != m_list.end(); ++it ) 400 for ( ; it != m_list.end(); ++it )
401 m_stack->addWidget( it.data(), it.key() ); 401 m_stack->addWidget( it.data(), it.key() );
402 402
403 403
404} 404}
405 405
406/* 406/*
407 * we will switch to top level mode 407 * we will switch to top level mode
408 * reparent the list of widgets and then delete the stack 408 * reparent the list of widgets and then delete the stack
409 */ 409 */
410void OWidgetStack::switchTop() { 410void OWidgetStack::switchTop() {
411 m_mode = BigScreen; 411 m_mode = BigScreen;
412 /* this works because it is guaranteed that switchStack was called at least once*/ 412 /* this works because it is guaranteed that switchStack was called at least once*/
413 if (!m_stack && m_mWidget) { 413 if (!m_stack && m_mWidget) {
414 m_mWidget->setGeometry( frameRect() ); 414 m_mWidget->setGeometry( frameRect() );
415 return; 415 return;
416 }else if (!m_stack) 416 }else if (!m_stack)
417 return; 417 return;
418 418
419 if (!m_list.isEmpty() ) { 419 if (!m_list.isEmpty() ) {
420 QMap<int, QWidget*>::Iterator it = m_list.begin(); 420 QMap<int, QWidget*>::Iterator it = m_list.begin();
421 for ( ; it != m_list.end(); ++it ) { 421 for ( ; it != m_list.end(); ++it ) {
422 /* better than reparenting twice */ 422 /* better than reparenting twice */
423 if ( it.data() == m_mWidget ) { 423 if ( it.data() == m_mWidget ) {
424 m_mWidget->reparent(this, 0, frameRect().topLeft() ); 424 m_mWidget->reparent(this, 0, frameRect().topLeft() );
425 m_mWidget->setGeometry( frameRect() ); 425 m_mWidget->setGeometry( frameRect() );
426 m_mWidget->show(); 426 m_mWidget->show();
427 }else 427 }else
428 /* ### FIXME we need to place the widget better */ 428 /* ### FIXME we need to place the widget better */
429 it.data()->reparent(0, WType_TopLevel, QPoint(10, 10) ); 429 it.data()->reparent(0, WType_TopLevel, QPoint(10, 10) );
430 } 430 }
431 } 431 }
432 432
433 delete m_stack; 433 delete m_stack;
434 m_stack = 0; 434 m_stack = 0;
435} 435}
436
437}
438} \ No newline at end of file
diff --git a/libopie2/opieui/big-screen/owidgetstack.h b/libopie2/opieui/big-screen/owidgetstack.h
index 53818c8..d2f9a9f 100644
--- a/libopie2/opieui/big-screen/owidgetstack.h
+++ b/libopie2/opieui/big-screen/owidgetstack.h
@@ -1,132 +1,133 @@
1/* 1/*
2               =. This file is part of the OPIE Project 2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2003 hOlgAr <zecke@handhelds.org> 3             .=l. Copyright (c) 2003 hOlgAr <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#ifndef OWIDGETSTACK_H 29#ifndef OWIDGETSTACK_H
30#define OWIDGETSTACK_H 30#define OWIDGETSTACK_H
31 31
32/* QT*/ 32/* QT*/
33#include <qframe.h> 33#include <qframe.h>
34#include <qmap.h> 34#include <qmap.h>
35 35
36class QWidgetStack; 36class QWidgetStack;
37 37
38namespace Opie 38namespace Opie {
39{ 39namespace Ui {
40/** 40/**
41 * 41 *
42 * OWidgetStack is the answer to the problem of using Opie at different screen 42 * OWidgetStack is the answer to the problem of using Opie at different screen
43 * sizes and to have a different behaviour. Most applications use a QWidgetStack 43 * sizes and to have a different behaviour. Most applications use a QWidgetStack
44 * to supply a view on click. And by clicking the (X) you go back but this 44 * to supply a view on click. And by clicking the (X) you go back but this
45 * behaviour feels strange on bigger screens. It's ok on smaller one because 45 * behaviour feels strange on bigger screens. It's ok on smaller one because
46 * one can't determine the difference. 46 * one can't determine the difference.
47 * This stack reads the default out of the size of the desktop widget but 47 * This stack reads the default out of the size of the desktop widget but
48 * can be forced to have either the one or the other behaviour. 48 * can be forced to have either the one or the other behaviour.
49 * The first widget added is considered the 'main' widget and its 49 * The first widget added is considered the 'main' widget and its
50 * sizeHint will be taking if in BigScreen mode. 50 * sizeHint will be taking if in BigScreen mode.
51 * In small screen mode this widget behaves exactly like a QWidgetStack and in BigScreen 51 * In small screen mode this widget behaves exactly like a QWidgetStack and in BigScreen
52 * mode it'll use the MainWindow as child of this widget and arranges the others as 52 * mode it'll use the MainWindow as child of this widget and arranges the others as
53 * hidden top level widgets. 53 * hidden top level widgets.
54 * 54 *
55 * @version 0.1 55 * @version 0.1
56 * @author hOlgAr F. 56 * @author hOlgAr F.
57 * @short Either a true stack or a list of top Level widgets 57 * @short Either a true stack or a list of top Level widgets
58 */ 58 */
59class OWidgetStack : public QFrame { 59class OWidgetStack : public QFrame {
60 Q_OBJECT 60 Q_OBJECT
61public: 61public:
62 enum Mode { SmallScreen, BigScreen, NoForce }; 62 enum Mode { SmallScreen, BigScreen, NoForce };
63 OWidgetStack( QWidget* parent, const char* name = 0, WFlags fl = 0 ); 63 OWidgetStack( QWidget* parent, const char* name = 0, WFlags fl = 0 );
64 ~OWidgetStack(); 64 ~OWidgetStack();
65 65
66 enum Mode mode()const; 66 enum Mode mode()const;
67 void forceMode( enum Mode ); 67 void forceMode( enum Mode );
68 68
69 void addWidget( QWidget* , int ); 69 void addWidget( QWidget* , int );
70 void removeWidget( QWidget* ); 70 void removeWidget( QWidget* );
71 71
72// QSizeHint sizeHint()const; 72// QSizeHint sizeHint()const;
73// QSizeHint minimumSizeHint()const; 73// QSizeHint minimumSizeHint()const;
74 74
75 QWidget *widget( int )const; 75 QWidget *widget( int )const;
76 int id( QWidget* )const; 76 int id( QWidget* )const;
77 77
78 78
79 79
80 QWidget* visibleWidget() const; 80 QWidget* visibleWidget() const;
81 81
82 bool eventFilter( QObject*, QEvent* ); 82 bool eventFilter( QObject*, QEvent* );
83signals: 83signals:
84 /** 84 /**
85 * OWidgetStack monitors the Desktop Widget for 85 * OWidgetStack monitors the Desktop Widget for
86 * size changes if it recignizes a change size it'll 86 * size changes if it recignizes a change size it'll
87 * send a signal and adjust its mode. After the signal 87 * send a signal and adjust its mode. After the signal
88 * was emitted. During the signal a call to mode() the 88 * was emitted. During the signal a call to mode() the
89 * old mode will be returned. Note that if a size change happens 89 * old mode will be returned. Note that if a size change happens
90 * but no modeChange no signal will be emitted 90 * but no modeChange no signal will be emitted
91 * 91 *
92 * 92 *
93 * @param mode The new mode of the desktop 93 * @param mode The new mode of the desktop
94 */ 94 */
95 void modeChanged( enum Mode mode); 95 void modeChanged( enum Mode mode);
96 96
97 /** 97 /**
98 * These two signals are emitted whenever we're about to 98 * These two signals are emitted whenever we're about to
99 * show one of the widgets 99 * show one of the widgets
100 */ 100 */
101 void aboutToShow( QWidget* ); 101 void aboutToShow( QWidget* );
102 void aboutToShow( int ); 102 void aboutToShow( int );
103 103
104public slots: 104public slots:
105 void raiseWidget( int ); 105 void raiseWidget( int );
106 void raiseWidget( QWidget* ); 106 void raiseWidget( QWidget* );
107 void hideWidget( int ); 107 void hideWidget( int );
108 void hideWidget( QWidget* ); 108 void hideWidget( QWidget* );
109 void setMainWindow( QWidget* ); 109 void setMainWindow( QWidget* );
110 void setMainWindow( int ); 110 void setMainWindow( int );
111 111
112protected: 112protected:
113 void resizeEvent( QResizeEvent* ); 113 void resizeEvent( QResizeEvent* );
114 114
115private: 115private:
116 void switchStack(); 116 void switchStack();
117 void switchTop(); 117 void switchTop();
118 QMap<int, QWidget*> m_list; 118 QMap<int, QWidget*> m_list;
119 QWidgetStack *m_stack; 119 QWidgetStack *m_stack;
120 QWidget *m_mWidget; 120 QWidget *m_mWidget;
121 QWidget *m_last; 121 QWidget *m_last;
122 122
123 enum Mode m_mode; 123 enum Mode m_mode;
124 bool m_forced : 1; 124 bool m_forced : 1;
125 125
126 struct Private; 126 struct Private;
127 Private *d; 127 Private *d;
128}; 128};
129 129
130}; 130}
131}
131 132
132#endif 133#endif
diff --git a/libopie2/opieui/fileselector/ofiledialog.cpp b/libopie2/opieui/fileselector/ofiledialog.cpp
index e7daead..beb4d6c 100644
--- a/libopie2/opieui/fileselector/ofiledialog.cpp
+++ b/libopie2/opieui/fileselector/ofiledialog.cpp
@@ -1,90 +1,90 @@
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::Ui;
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,
diff --git a/libopie2/opieui/fileselector/ofiledialog.h b/libopie2/opieui/fileselector/ofiledialog.h
index 01a599b..dfecf3d 100644
--- a/libopie2/opieui/fileselector/ofiledialog.h
+++ b/libopie2/opieui/fileselector/ofiledialog.h
@@ -1,109 +1,110 @@
1/* 1/*
2               =. This file is part of the OPIE Project 2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2002 zecke <zecke@handhelds.org> 3             .=l. Copyright (c) 2002 zecke <zecke@handhelds.org>
4           .>+-= 4           .>+-=
5 _;:,     .>    :=|. This library is free software; you can 5 _;:,     .>    :=|. This library is free software; you can
6.> <`_,   >  .   <= redistribute it and/or modify it under 6.> <`_,   >  .   <= redistribute it and/or modify it under
7:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 7:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
8.="- .-=="i,     .._ License as published by the Free Software 8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; either version 2 of the License, 9 - .   .-<_>     .<> Foundation; either version 2 of the License,
10     ._= =}       : or (at your option) any later version. 10     ._= =}       : or (at your option) any later version.
11    .%`+i>       _;_. 11    .%`+i>       _;_.
12    .i_,=:_.      -<s. This library is distributed in the hope that 12    .i_,=:_.      -<s. This library is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of 14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
17..}^=.=       =       ; Library General Public License for more 17..}^=.=       =       ; Library General Public License for more
18++=   -.     .`     .: details. 18++=   -.     .`     .: details.
19 :     =  ...= . :.=- 19 :     =  ...= . :.=-
20 -.   .:....=;==+<; You should have received a copy of the GNU 20 -.   .:....=;==+<; You should have received a copy of the GNU
21  -_. . .   )=.  = Library General Public License along with 21  -_. . .   )=.  = Library General Public License along with
22    --        :-=` this library; see the file COPYING.LIB. 22    --        :-=` this library; see the file COPYING.LIB.
23 If not, write to the Free Software Foundation, 23 If not, write to the Free Software Foundation,
24 Inc., 59 Temple Place - Suite 330, 24 Inc., 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 26
27*/ 27*/
28 28
29#ifndef OFILEDIALOG_H 29#ifndef OFILEDIALOG_H
30#define OFILEDIALOG_H 30#define OFILEDIALOG_H
31 31
32/* OPIE */ 32/* OPIE */
33#include <opie2/ofileselector.h> 33#include <opie2/ofileselector.h>
34 34
35/* QT */ 35/* QT */
36#include <qdialog.h> 36#include <qdialog.h>
37 37
38namespace Opie 38namespace Opie {
39{ 39namespace Ui {
40 40
41/** 41/**
42 * This class places a OFileSelector inside a QDialog. 42 * This class places a OFileSelector inside a QDialog.
43 * It provides static method for letting a user chose 43 * It provides static method for letting a user chose
44 * a file for either opening or saving. 44 * a file for either opening or saving.
45 * Most of the time the c'tor will not be used instead using 45 * Most of the time the c'tor will not be used instead using
46 * the static member functions is prefered. 46 * the static member functions is prefered.
47 * 47 *
48 * <pre> 48 * <pre>
49 * QMap<QString, QStringList> mimeTypes; 49 * QMap<QString, QStringList> mimeTypes;
50 * QStringList types; 50 * QStringList types;
51 * types << "text[slash]* "; 51 * types << "text[slash]* ";
52 * mimeTypes.insert( tr("Text"), types ); 52 * mimeTypes.insert( tr("Text"), types );
53 * mimeTypes.insert( tr("All"), " * / * " ); // remove the spaces in the 2nd comment 53 * mimeTypes.insert( tr("All"), " * / * " ); // remove the spaces in the 2nd comment
54 * QString fileName= OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL, 54 * QString fileName= OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL,
55 * "foo","bar", mimeTypes); 55 * "foo","bar", mimeTypes);
56 * </pre> 56 * </pre>
57 * 57 *
58 * @short A small QDialog swalloing a FileSelector 58 * @short A small QDialog swalloing a FileSelector
59 * @see QDialog 59 * @see QDialog
60 * @see OFileSelector 60 * @see OFileSelector
61 * @version 0.1-unfinished 61 * @version 0.1-unfinished
62 * @author Holger Freyther ( zecke@handhelds.org ) 62 * @author Holger Freyther ( zecke@handhelds.org )
63 */ 63 */
64class OFileDialog : public QDialog 64class OFileDialog : public QDialog
65{ 65{
66 Q_OBJECT 66 Q_OBJECT
67public: 67public:
68 OFileDialog(const QString &caption, 68 OFileDialog(const QString &caption,
69 QWidget *, int mode, int selector, 69 QWidget *, int mode, int selector,
70 const QString &dirName, 70 const QString &dirName,
71 const QString &fileName = QString::null, 71 const QString &fileName = QString::null,
72 const MimeTypes &mimetypes = MimeTypes() ); 72 const MimeTypes &mimetypes = MimeTypes() );
73 QString mimetype() const; 73 QString mimetype() const;
74 QString fileName() const; 74 QString fileName() const;
75 DocLnk selectedDocument()const; 75 DocLnk selectedDocument()const;
76 76
77 // static methods 77 // static methods
78 static QString getOpenFileName(int selector, 78 static QString getOpenFileName(int selector,
79 const QString& startDir = QString::null, 79 const QString& startDir = QString::null,
80 const QString &fileName = QString::null, 80 const QString &fileName = QString::null,
81 const MimeTypes& mime = MimeTypes(), 81 const MimeTypes& mime = MimeTypes(),
82 QWidget *wid = 0, 82 QWidget *wid = 0,
83 const QString &caption = QString::null ); 83 const QString &caption = QString::null );
84 84
85 static QString getSaveFileName(int selector, 85 static QString getSaveFileName(int selector,
86 const QString& startDir = QString::null, 86 const QString& startDir = QString::null,
87 const QString& fileName = QString::null, 87 const QString& fileName = QString::null,
88 const MimeTypes& mimefilter = MimeTypes(), 88 const MimeTypes& mimefilter = MimeTypes(),
89 QWidget *wid = 0, 89 QWidget *wid = 0,
90 const QString &caption = QString::null ); 90 const QString &caption = QString::null );
91 91
92 //let's OFileSelector catch up first 92 //let's OFileSelector catch up first
93 //static QString getExistingDirectory(const QString& startDir = QString::null, 93 //static QString getExistingDirectory(const QString& startDir = QString::null,
94 //QWidget *parent = 0, const QString& caption = QString::null ); 94 //QWidget *parent = 0, const QString& caption = QString::null );
95 95
96private: 96private:
97 class OFileDialogPrivate; 97 class OFileDialogPrivate;
98 OFileDialogPrivate *d; 98 OFileDialogPrivate *d;
99 OFileSelector *file; 99 OFileSelector *file;
100 100
101private slots: 101private slots:
102 void slotFileSelected( const QString & ); 102 void slotFileSelected( const QString & );
103 void slotDirSelected(const QString & ); 103 void slotDirSelected(const QString & );
104 void slotSelectorOk(); 104 void slotSelectorOk();
105}; 105};
106 106
107}; 107}
108}
108 109
109#endif 110#endif
diff --git a/libopie2/opieui/fileselector/ofileselector.cpp b/libopie2/opieui/fileselector/ofileselector.cpp
index 15cadd4..c4d5033 100644
--- a/libopie2/opieui/fileselector/ofileselector.cpp
+++ b/libopie2/opieui/fileselector/ofileselector.cpp
@@ -10,98 +10,101 @@
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/* 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::Ui::Private;
59 59
60namespace Opie {
61namespace Ui {
62namespace Private {
60OFileViewInterface::OFileViewInterface( OFileSelector* selector ) 63OFileViewInterface::OFileViewInterface( OFileSelector* selector )
61 : m_selector( selector ) 64 : m_selector( selector )
62{} 65{}
63 66
64OFileViewInterface::~OFileViewInterface() 67OFileViewInterface::~OFileViewInterface()
65{} 68{}
66 69
67QString OFileViewInterface::name()const 70QString OFileViewInterface::name()const
68{ 71{
69 return m_name; 72 return m_name;
70} 73}
71 74
72void OFileViewInterface::setName( const QString& name ) 75void OFileViewInterface::setName( const QString& name )
73{ 76{
74 m_name = name; 77 m_name = name;
75} 78}
76 79
77OFileSelector* OFileViewInterface::selector()const 80OFileSelector* OFileViewInterface::selector()const
78{ 81{
79 return m_selector; 82 return m_selector;
80} 83}
81 84
82DocLnk OFileViewInterface::selectedDocument()const 85DocLnk OFileViewInterface::selectedDocument()const
83{ 86{
84 return DocLnk( selectedName() ); 87 return DocLnk( selectedName() );
85} 88}
86 89
87bool OFileViewInterface::showNew()const 90bool OFileViewInterface::showNew()const
88{ 91{
89 return selector()->showNew(); 92 return selector()->showNew();
90} 93}
91 94
92bool OFileViewInterface::showClose()const 95bool OFileViewInterface::showClose()const
93{ 96{
94 return selector()->showClose(); 97 return selector()->showClose();
95} 98}
96 99
97MimeTypes OFileViewInterface::mimeTypes()const 100MimeTypes OFileViewInterface::mimeTypes()const
98{ 101{
99 return selector()->mimeTypes(); 102 return selector()->mimeTypes();
100} 103}
101 104
102QStringList OFileViewInterface::currentMimeType()const 105QStringList OFileViewInterface::currentMimeType()const
103{ 106{
104 return selector()->currentMimeType(); 107 return selector()->currentMimeType();
105} 108}
106 109
107void OFileViewInterface::activate( const QString& ) 110void OFileViewInterface::activate( const QString& )
@@ -765,96 +768,98 @@ QString OFileViewFileSystem::selectedName()const
765} 768}
766 769
767QString OFileViewFileSystem::selectedPath()const 770QString OFileViewFileSystem::selectedPath()const
768{ 771{
769 return QString::null; 772 return QString::null;
770} 773}
771 774
772QString OFileViewFileSystem::directory()const 775QString OFileViewFileSystem::directory()const
773{ 776{
774 if (!m_view) 777 if (!m_view)
775 return QString::null; 778 return QString::null;
776 779
777 OFileSelectorItem* item = m_view->currentItem(); 780 OFileSelectorItem* item = m_view->currentItem();
778 if (!item ) 781 if (!item )
779 return QString::null; 782 return QString::null;
780 783
781 return QDir(item->directory() ).absPath(); 784 return QDir(item->directory() ).absPath();
782} 785}
783 786
784void OFileViewFileSystem::reread() 787void OFileViewFileSystem::reread()
785{ 788{
786 if (!m_view) 789 if (!m_view)
787 return; 790 return;
788 791
789 m_view->reread( m_all ); 792 m_view->reread( m_all );
790} 793}
791 794
792int OFileViewFileSystem::fileCount()const 795int OFileViewFileSystem::fileCount()const
793{ 796{
794 if (!m_view ) 797 if (!m_view )
795 return -1; 798 return -1;
796 return m_view->fileCount(); 799 return m_view->fileCount();
797} 800}
798 801
799QWidget* OFileViewFileSystem::widget( QWidget* parent ) 802QWidget* OFileViewFileSystem::widget( QWidget* parent )
800{ 803{
801 if (!m_view ) 804 if (!m_view )
802 { 805 {
803 m_view = new OFileViewFileListView( parent, startDirectory(), selector() ); 806 m_view = new OFileViewFileListView( parent, startDirectory(), selector() );
804 } 807 }
805 return m_view; 808 return m_view;
806} 809}
807 810
808void OFileViewFileSystem::activate( const QString& str) 811void OFileViewFileSystem::activate( const QString& str)
809{ 812{
810 m_all = (str != QObject::tr("Files") ); 813 m_all = (str != QObject::tr("Files") );
811} 814}
812 815
816
817}
813/* Selector */ 818/* Selector */
814/** 819/**
815 * @short new and complete c'tor 820 * @short new and complete c'tor
816 * 821 *
817 * Create a OFileSelector to let the user select a file. It can 822 * 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 823 * either be used to open a file, select a save name in a dir or
819 * as a dropin for the FileSelector. 824 * as a dropin for the FileSelector.
820 * 825 *
821 * <pre> 826 * <pre>
822 * QMap<QString, QStringList> mimeTypes; 827 * QMap<QString, QStringList> mimeTypes;
823 * QStringList types; 828 * QStringList types;
824 * types << "text@slash* "; 829 * types << "text@slash* ";
825 * types << "audio@slash*"; 830 * types << "audio@slash*";
826 * mimeTypes.insert( tr("Audio and Text"), types ); 831 * mimeTypes.insert( tr("Audio and Text"), types );
827 * mimeTypes.insert( tr("All"), "*@slash*); 832 * mimeTypes.insert( tr("All"), "*@slash*);
828 * 833 *
829 * now you could create your fileselector 834 * now you could create your fileselector
830 * </pre> 835 * </pre>
831 * 836 *
832 * 837 *
833 * @param parent the parent of this widget 838 * @param parent the parent of this widget
834 * @param mode The mode from the enum Mode (Open,Save,FILESELECTOR) 839 * @param mode The mode from the enum Mode (Open,Save,FILESELECTOR)
835 * @param sel The selector to be used 840 * @param sel The selector to be used
836 * @param dirName The name of the dir to start int 841 * @param dirName The name of the dir to start int
837 * @param fileName The fileName placed in the fileselector lineedit 842 * @param fileName The fileName placed in the fileselector lineedit
838 * @param mimetypes The MimeType map of used mimetypes 843 * @param mimetypes The MimeType map of used mimetypes
839 * @param showNew Show a New Button. Most likely to be used in the FileSelector view. 844 * @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. 845 * @param showClose Show a Close Button. Most likely to be used in FileSelector view.
841 * 846 *
842 */ 847 */
843OFileSelector::OFileSelector( QWidget* parent, int mode, int sel, 848OFileSelector::OFileSelector( QWidget* parent, int mode, int sel,
844 const QString& dirName, const QString& fileName, 849 const QString& dirName, const QString& fileName,
845 const MimeTypes& mimetypes, 850 const MimeTypes& mimetypes,
846 bool showNew, bool showClose) 851 bool showNew, bool showClose)
847 :QWidget( parent, "OFileSelector" ) 852 :QWidget( parent, "OFileSelector" )
848{ 853{
849 m_current = 0; 854 m_current = 0;
850 m_shNew = showNew; 855 m_shNew = showNew;
851 m_shClose = showClose; 856 m_shClose = showClose;
852 m_mimeType = mimetypes; 857 m_mimeType = mimetypes;
853 m_startDir = dirName; 858 m_startDir = dirName;
854 859
855 m_mode = mode; 860 m_mode = mode;
856 m_selector = sel; 861 m_selector = sel;
857 862
858 initUI(); 863 initUI();
859 m_lneEdit->setText( fileName ); 864 m_lneEdit->setText( fileName );
860 initMime(); 865 initMime();
@@ -1119,48 +1124,50 @@ void OFileSelector::slotDocLnkBridge( const DocLnk& lnk)
1119 1124
1120void OFileSelector::slotFileBridge( const QString& str) 1125void OFileSelector::slotFileBridge( const QString& str)
1121{ 1126{
1122 DocLnk lnk( str ); 1127 DocLnk lnk( str );
1123 emit fileSelected( lnk ); 1128 emit fileSelected( lnk );
1124} 1129}
1125 1130
1126void OFileSelector::slotViewChange( const QString& view ) 1131void OFileSelector::slotViewChange( const QString& view )
1127{ 1132{
1128 OFileViewInterface* interface = m_views[view]; 1133 OFileViewInterface* interface = m_views[view];
1129 if (!interface) 1134 if (!interface)
1130 return; 1135 return;
1131 1136
1132 interface->activate( view ); 1137 interface->activate( view );
1133 if (m_current) 1138 if (m_current)
1134 m_stack->removeWidget( m_current->widget( m_stack ) ); 1139 m_stack->removeWidget( m_current->widget( m_stack ) );
1135 1140
1136 static int id = 1; 1141 static int id = 1;
1137 1142
1138 m_stack->addWidget( interface->widget(m_stack), id ); 1143 m_stack->addWidget( interface->widget(m_stack), id );
1139 m_stack->raiseWidget( id ); 1144 m_stack->raiseWidget( id );
1140 1145
1141 interface->reread(); 1146 interface->reread();
1142 m_current = interface; 1147 m_current = interface;
1143 1148
1144 id++; 1149 id++;
1145} 1150}
1146 1151
1147void OFileSelector::setNewVisible( bool b ) 1152void OFileSelector::setNewVisible( bool b )
1148{ 1153{
1149 m_shNew = b; 1154 m_shNew = b;
1150 currentView()->reread(); 1155 currentView()->reread();
1151} 1156}
1152 1157
1153void OFileSelector::setCloseVisible( bool b ) 1158void OFileSelector::setCloseVisible( bool b )
1154{ 1159{
1155 m_shClose = b; 1160 m_shClose = b;
1156 currentView()->reread(); 1161 currentView()->reread();
1157} 1162}
1158 1163
1159void OFileSelector::setNameVisible( bool b ) 1164void OFileSelector::setNameVisible( bool b )
1160{ 1165{
1161 if ( b ) 1166 if ( b )
1162 m_nameBox->show(); 1167 m_nameBox->show();
1163 else 1168 else
1164 m_nameBox->hide(); 1169 m_nameBox->hide();
1165} 1170}
1166 1171
1172}
1173}
diff --git a/libopie2/opieui/fileselector/ofileselector.h b/libopie2/opieui/fileselector/ofileselector.h
index 7fa657b..2205963 100644
--- a/libopie2/opieui/fileselector/ofileselector.h
+++ b/libopie2/opieui/fileselector/ofileselector.h
@@ -7,119 +7,121 @@
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 This is based on code and ideas of 30 This is based on code and ideas of
31 L. J. Potter ljp@llornkcor.com 31 L. J. Potter ljp@llornkcor.com
32 Thanks a lot 32 Thanks a lot
33*/ 33*/
34 34
35#ifndef OFILESELECTOR_H 35#ifndef OFILESELECTOR_H
36#define OFILESELECTOR_H 36#define OFILESELECTOR_H
37 37
38/* OPIE */ 38/* OPIE */
39#include <qpe/applnk.h> 39#include <qpe/applnk.h>
40 40
41/* QT */ 41/* QT */
42#include <qlist.h> 42#include <qlist.h>
43#include <qwidget.h> 43#include <qwidget.h>
44#include <qmap.h> 44#include <qmap.h>
45#include <qvaluelist.h> 45#include <qvaluelist.h>
46#include <qstringlist.h> 46#include <qstringlist.h>
47 47
48class QLineEdit; 48class QLineEdit;
49class QComboBox; 49class QComboBox;
50class QWidgetStack; 50class QWidgetStack;
51class QHBox; 51class QHBox;
52 52
53typedef QMap<QString, QStringList> MimeTypes; 53typedef QMap<QString, QStringList> MimeTypes;
54 54
55namespace Opie 55namespace Opie {
56{ 56namespace Ui {
57 57
58namespace Private {
58class OFileViewInterface; 59class OFileViewInterface;
59class OFileViewFileListView; 60class OFileViewFileListView;
61}
60 62
61 63
62/** 64/**
63 * @short a dropin replacement for the FileSelector 65 * @short a dropin replacement for the FileSelector
64 * 66 *
65 * This class is first used insert the OFileDialog. 67 * This class is first used insert the OFileDialog.
66 * It supports multiple view and mimetype filtering for now. 68 * It supports multiple view and mimetype filtering for now.
67 * 69 *
68 * @see OFileDialog 70 * @see OFileDialog
69 * @see FileSelector 71 * @see FileSelector
70 * @author zecke 72 * @author zecke
71 * @version 0.1 73 * @version 0.1
72 */ 74 */
73class OFileSelector : public QWidget 75class OFileSelector : public QWidget
74{ 76{
75 Q_OBJECT 77 Q_OBJECT
76 friend class Opie::OFileViewInterface; 78 friend class Private::OFileViewInterface;
77 friend class Opie::OFileViewFileListView; 79 friend class Private::OFileViewFileListView;
78 80
79public: 81public:
80 /** 82 /**
81 * The Mode of the Fileselector 83 * The Mode of the Fileselector
82 * Open = Open A File 84 * Open = Open A File
83 * Save = Save a File 85 * Save = Save a File
84 * FILESELECTOR = As A GUI in a screen to select a file 86 * FILESELECTOR = As A GUI in a screen to select a file
85 */ 87 */
86 enum Mode { Open=1, Save=2, FileSelector=4, OPEN=1, SAVE=2, FILESELECTOR=4 }; 88 enum Mode { Open=1, Save=2, FileSelector=4, OPEN=1, SAVE=2, FILESELECTOR=4 };
87 // enum OldMode { OPEN=1, SAVE=2, FILESELECTOR = 4 }; 89 // enum OldMode { OPEN=1, SAVE=2, FILESELECTOR = 4 };
88 /** 90 /**
89 * Normal = The old FileSelector 91 * Normal = The old FileSelector
90 * Extended = Dir View 92 * Extended = Dir View
91 * ExtendedAll = Dir View with all hidden files 93 * ExtendedAll = Dir View with all hidden files
92 * Default = What the vendor considers best 94 * Default = What the vendor considers best
93 */ 95 */
94 enum Selector { Normal = 0, Extended=1, ExtendedAll =2, Default=3, NORMAL=0,EXTENDED=1, EXTENDED_ALL =2, DEFAULT=3 }; 96 enum Selector { Normal = 0, Extended=1, ExtendedAll =2, Default=3, NORMAL=0,EXTENDED=1, EXTENDED_ALL =2, DEFAULT=3 };
95 // enum OldSelector { NORMAL = 0, EXTENDED =1, EXTENDED_ALL = 2}; 97 // enum OldSelector { NORMAL = 0, EXTENDED =1, EXTENDED_ALL = 2};
96 98
97 OFileSelector(QWidget* parent, int mode, int selector, 99 OFileSelector(QWidget* parent, int mode, int selector,
98 const QString& dirName, 100 const QString& dirName,
99 const QString& fileName, 101 const QString& fileName,
100 const MimeTypes& mimetypes = MimeTypes(), 102 const MimeTypes& mimetypes = MimeTypes(),
101 bool newVisible = FALSE, bool closeVisible = FALSE ); 103 bool newVisible = FALSE, bool closeVisible = FALSE );
102 104
103 OFileSelector(const QString& mimeFilter, QWidget* parent, 105 OFileSelector(const QString& mimeFilter, QWidget* parent,
104 const char* name = 0, bool newVisible = TRUE, bool closeVisible = FALSE ); 106 const char* name = 0, bool newVisible = TRUE, bool closeVisible = FALSE );
105 ~OFileSelector(); 107 ~OFileSelector();
106 108
107 const DocLnk* selected(); 109 const DocLnk* selected();
108 110
109 QString selectedName()const; 111 QString selectedName()const;
110 QString selectedPath()const; 112 QString selectedPath()const;
111 QString directory()const; 113 QString directory()const;
112 114
113 DocLnk selectedDocument()const; 115 DocLnk selectedDocument()const;
114 116
115 int fileCount()const; 117 int fileCount()const;
116 void reread(); 118 void reread();
117 119
118 int mode()const; 120 int mode()const;
119 int selector()const; 121 int selector()const;
120 122
121 /** 123 /**
122 * Set the Icon visible 124 * Set the Icon visible
123 * @param b Show or Hide the New Button 125 * @param b Show or Hide the New Button
124 */ 126 */
125 void setNewVisible( bool b ); 127 void setNewVisible( bool b );
@@ -140,80 +142,81 @@ signals:
140 */ 142 */
141 void dirSelected( const QString& ); 143 void dirSelected( const QString& );
142 144
143 /** 145 /**
144 * fileSelected is emitted when a file is selected 146 * fileSelected is emitted when a file is selected
145 * it uses a DocLnk as parameter 147 * it uses a DocLnk as parameter
146 */ 148 */
147 void fileSelected( const DocLnk& ); 149 void fileSelected( const DocLnk& );
148 150
149 /** 151 /**
150 * fileSelected is emitted when a file is selected 152 * fileSelected is emitted when a file is selected
151 * the complete path is a parameter 153 * the complete path is a parameter
152 */ 154 */
153 void fileSelected( const QString& ); 155 void fileSelected( const QString& );
154 156
155 /** 157 /**
156 * Create a new File with a DocLnk 158 * Create a new File with a DocLnk
157 */ 159 */
158 void newSelected( const DocLnk& ); 160 void newSelected( const DocLnk& );
159 161
160 void closeMe(); 162 void closeMe();
161 163
162 /** 164 /**
163 * Ok is emitted on a Qt::Key_Return or Q::Key_Enter 165 * Ok is emitted on a Qt::Key_Return or Q::Key_Enter
164 * in the line edit 166 * in the line edit
165 */ 167 */
166 void ok(); 168 void ok();
167 void cancel(); 169 void cancel();
168 170
169 /* used by the ViewInterface */ 171 /* used by the ViewInterface */
170private: 172private:
171 bool showNew()const; 173 bool showNew()const;
172 bool showClose()const; 174 bool showClose()const;
173 MimeTypes mimeTypes()const; 175 MimeTypes mimeTypes()const;
174 QStringList currentMimeType()const; 176 QStringList currentMimeType()const;
175 177
176private: 178private:
177 /* inits the Widgets */ 179 /* inits the Widgets */
178 void initUI(); 180 void initUI();
179 /* inits the MimeType ComboBox content + connects signals and slots */ 181 /* inits the MimeType ComboBox content + connects signals and slots */
180 void initMime(); 182 void initMime();
181 /* init the Views :) */ 183 /* init the Views :) */
182 void initViews(); 184 void initViews();
183 185
184private: 186private:
185 QLineEdit* m_lneEdit; // the LineEdit for the Name 187 QLineEdit* m_lneEdit; // the LineEdit for the Name
186 QComboBox *m_cmbView, *m_cmbMime; // two ComboBoxes to select the View and MimeType 188 QComboBox *m_cmbView, *m_cmbMime; // two ComboBoxes to select the View and MimeType
187 QWidgetStack* m_stack; // our widget stack which will contain the views 189 QWidgetStack* m_stack; // our widget stack which will contain the views
188 OFileViewInterface* currentView() const; // returns the currentView 190 Private::OFileViewInterface* currentView() const; // returns the currentView
189 OFileViewInterface* m_current; // here is the view saved 191 Private::OFileViewInterface* m_current; // here is the view saved
190 bool m_shNew : 1; // should we show New? 192 bool m_shNew : 1; // should we show New?
191 bool m_shClose : 1; // should we show Close? 193 bool m_shClose : 1; // should we show Close?
192 MimeTypes m_mimeType; // list of mimetypes 194 MimeTypes m_mimeType; // list of mimetypes
193 195
194 QMap<QString, OFileViewInterface*> m_views; // QString translated view name + ViewInterface Ptr 196 QMap<QString, Private::OFileViewInterface*> m_views; // QString translated view name + ViewInterface Ptr
195 QHBox* m_nameBox; // the LineEdit + Label is hold here 197 QHBox* m_nameBox; // the LineEdit + Label is hold here
196 QHBox* m_cmbBox; // this holds the two combo boxes 198 QHBox* m_cmbBox; // this holds the two combo boxes
197 199
198 QString m_startDir; 200 QString m_startDir;
199 int m_mode; 201 int m_mode;
200 int m_selector; 202 int m_selector;
201 203
202 struct Data; // used for future versions 204 struct Data; // used for future versions
203 Data *d; 205 Data *d;
204 206
205private slots: 207private slots:
206 void slotMimeTypeChanged(); 208 void slotMimeTypeChanged();
207 209
208 /* will set the text of the lineedit and emit a fileChanged signal */ 210 /* will set the text of the lineedit and emit a fileChanged signal */
209 void slotDocLnkBridge( const DocLnk& ); 211 void slotDocLnkBridge( const DocLnk& );
210 void slotFileBridge( const QString& ); 212 void slotFileBridge( const QString& );
211 void slotViewChange( const QString& ); 213 void slotViewChange( const QString& );
212 214
213 bool eventFilter (QObject *o, QEvent *e); 215 bool eventFilter (QObject *o, QEvent *e);
214 216
215}; 217};
216 218
217}; 219}
220}
218 221
219#endif 222#endif
diff --git a/libopie2/opieui/fileselector/ofileselector_p.h b/libopie2/opieui/fileselector/ofileselector_p.h
index 818ced9..376dc98 100644
--- a/libopie2/opieui/fileselector/ofileselector_p.h
+++ b/libopie2/opieui/fileselector/ofileselector_p.h
@@ -11,100 +11,100 @@
11    .%`+i>       _;_. 11    .%`+i>       _;_.
12    .i_,=:_.      -<s. This library is distributed in the hope that 12    .i_,=:_.      -<s. This library is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of 14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
17..}^=.=       =       ; Library General Public License for more 17..}^=.=       =       ; Library General Public License for more
18++=   -.     .`     .: details. 18++=   -.     .`     .: details.
19 :     =  ...= . :.=- 19 :     =  ...= . :.=-
20 -.   .:....=;==+<; You should have received a copy of the GNU 20 -.   .:....=;==+<; You should have received a copy of the GNU
21  -_. . .   )=.  = Library General Public License along with 21  -_. . .   )=.  = Library General Public License along with
22    --        :-=` this library; see the file COPYING.LIB. 22    --        :-=` this library; see the file COPYING.LIB.
23 If not, write to the Free Software Foundation, 23 If not, write to the Free Software Foundation,
24 Inc., 59 Temple Place - Suite 330, 24 Inc., 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 26
27*/ 27*/
28 28
29#ifndef OFILESELECTOR_PRIVATE_H 29#ifndef OFILESELECTOR_PRIVATE_H
30#define OFILESELECTOR_PRIVATE_H 30#define OFILESELECTOR_PRIVATE_H
31 31
32/* OPIE */ 32/* OPIE */
33#include <qpe/applnk.h> 33#include <qpe/applnk.h>
34#include <qpe/fileselector.h> 34#include <qpe/fileselector.h>
35 35
36/* QT */ 36/* QT */
37#include <qmap.h> 37#include <qmap.h>
38#include <qstringlist.h> 38#include <qstringlist.h>
39#include <qwidget.h> 39#include <qwidget.h>
40#include <qlistview.h> 40#include <qlistview.h>
41 41
42/* 42/*
43 * How to avoid having really two different objects 43 * How to avoid having really two different objects
44 * for Extended and ExtendedAll 44 * for Extended and ExtendedAll
45 * The only difference is the Lister... 45 * The only difference is the Lister...
46 * a) static object? 46 * a) static object?
47 * b) leave some object inside the OFileSelector which can be used? 47 * b) leave some object inside the OFileSelector which can be used?
48 * c) when switching views tell which view we want o have.. internally we can switch then 48 * c) when switching views tell which view we want o have.. internally we can switch then
49 * 49 *
50 * I'll take c) -zecke 50 * I'll take c) -zecke
51 */ 51 */
52 52
53typedef QMap<QString, QStringList> MimeTypes; 53typedef QMap<QString, QStringList> MimeTypes;
54 54
55/* the View Interface */ 55/* the View Interface */
56class QFileInfo; 56class QFileInfo;
57class QToolButton; 57class QToolButton;
58 58
59namespace Opie 59namespace Opie{
60{ 60namespace Ui{
61
62class OFileSelector; 61class OFileSelector;
62namespace Private {
63 63
64class OFileViewInterface 64class OFileViewInterface
65{ 65{
66public: 66public:
67 OFileViewInterface( OFileSelector* selector ); 67 OFileViewInterface( OFileSelector* selector );
68 virtual ~OFileViewInterface(); 68 virtual ~OFileViewInterface();
69 virtual QString selectedName()const = 0; 69 virtual QString selectedName()const = 0;
70 virtual QString selectedPath()const = 0; 70 virtual QString selectedPath()const = 0;
71 virtual QString directory()const = 0; 71 virtual QString directory()const = 0;
72 virtual void reread() = 0; 72 virtual void reread() = 0;
73 virtual int fileCount()const = 0; 73 virtual int fileCount()const = 0;
74 virtual DocLnk selectedDocument()const; 74 virtual DocLnk selectedDocument()const;
75 virtual QWidget* widget( QWidget* parent) = 0; 75 virtual QWidget* widget( QWidget* parent) = 0;
76 virtual void activate( const QString& ); 76 virtual void activate( const QString& );
77 QString name()const; 77 QString name()const;
78protected: 78protected:
79 OFileSelector* selector()const; 79 OFileSelector* selector()const;
80 void setName( const QString& ); 80 void setName( const QString& );
81 bool showNew()const; 81 bool showNew()const;
82 bool showClose()const; 82 bool showClose()const;
83 MimeTypes mimeTypes()const; 83 MimeTypes mimeTypes()const;
84 QStringList currentMimeType()const; 84 QStringList currentMimeType()const;
85 QString startDirectory()const; 85 QString startDirectory()const;
86protected: 86protected:
87 void ok(); 87 void ok();
88 void cancel(); 88 void cancel();
89 void closeMe(); 89 void closeMe();
90 void fileSelected( const QString& ); 90 void fileSelected( const QString& );
91 void fileSelected( const DocLnk& ); 91 void fileSelected( const DocLnk& );
92 void setCurrentFileName( const QString& ); 92 void setCurrentFileName( const QString& );
93 QString currentFileName()const; 93 QString currentFileName()const;
94 94
95private: 95private:
96 QString m_name; 96 QString m_name;
97 OFileSelector* m_selector; 97 OFileSelector* m_selector;
98}; 98};
99 99
100 100
101/* THE Document View hosting a FileSelector*/ 101/* THE Document View hosting a FileSelector*/
102class ODocumentFileView : public OFileViewInterface 102class ODocumentFileView : public OFileViewInterface
103{ 103{
104public: 104public:
105 ODocumentFileView( OFileSelector* selector ); 105 ODocumentFileView( OFileSelector* selector );
106 ~ODocumentFileView(); 106 ~ODocumentFileView();
107 107
108 QString selectedName() const; 108 QString selectedName() const;
109 QString selectedPath() const; 109 QString selectedPath() const;
110 110
@@ -141,51 +141,53 @@ private:
141 QString m_dir; 141 QString m_dir;
142}; 142};
143 143
144class OFileViewFileListView : public QWidget 144class OFileViewFileListView : public QWidget
145{ 145{
146 Q_OBJECT 146 Q_OBJECT
147public: 147public:
148 OFileViewFileListView( QWidget* parent, const QString& dir, OFileSelector* selector ); 148 OFileViewFileListView( QWidget* parent, const QString& dir, OFileSelector* selector );
149 ~OFileViewFileListView(); 149 ~OFileViewFileListView();
150 150
151 OFileSelectorItem* currentItem()const; 151 OFileSelectorItem* currentItem()const;
152 void reread( bool all = false ); 152 void reread( bool all = false );
153 int fileCount()const; 153 int fileCount()const;
154 QString currentDir()const; 154 QString currentDir()const;
155protected: 155protected:
156 bool eventFilter (QObject *o, QEvent *e); 156 bool eventFilter (QObject *o, QEvent *e);
157private slots: 157private slots:
158 void slotNew(); // will emit newSelected 158 void slotNew(); // will emit newSelected
159 void cdUP(); 159 void cdUP();
160 void cdHome(); 160 void cdHome();
161 void cdDoc(); 161 void cdDoc();
162 void changeDir( const QString& ); 162 void changeDir( const QString& );
163 void slotCurrentChanged( QListViewItem* ); 163 void slotCurrentChanged( QListViewItem* );
164 void slotClicked(int, QListViewItem*, const QPoint&, int ); 164 void slotClicked(int, QListViewItem*, const QPoint&, int );
165 void slotFSActivated(int); 165 void slotFSActivated(int);
166 166
167protected: 167protected:
168 OFileSelector* selector(); 168 OFileSelector* selector();
169 169
170private: 170private:
171 QMap<QString, QString> m_dev; 171 QMap<QString, QString> m_dev;
172 bool m_all : 1; 172 bool m_all : 1;
173 OFileSelector* m_sel; 173 OFileSelector* m_sel;
174 QPopupMenu* m_fsPop; 174 QPopupMenu* m_fsPop;
175 bool compliesMime( const QString& ); 175 bool compliesMime( const QString& );
176 QStringList m_mimes; // used in compy mime 176 QStringList m_mimes; // used in compy mime
177 QString m_currentDir; 177 QString m_currentDir;
178 QToolButton *m_btnNew, *m_btnClose; 178 QToolButton *m_btnNew, *m_btnClose;
179 void connectSlots(); 179 void connectSlots();
180 void addFile( QFileInfo* info, bool symlink = FALSE ); 180 void addFile( QFileInfo* info, bool symlink = FALSE );
181 void addDir ( QFileInfo* info, bool symlink = FALSE ); 181 void addDir ( QFileInfo* info, bool symlink = FALSE );
182 void addSymlink( QFileInfo* info, bool = FALSE ); 182 void addSymlink( QFileInfo* info, bool = FALSE );
183 183
184 184
185private: 185private:
186 QListView* m_view; 186 QListView* m_view;
187}; 187};
188 188
189}; 189}
190}
191}
190 192
191#endif 193#endif
diff --git a/libopie2/opieui/fileselector/ofileview.h b/libopie2/opieui/fileselector/ofileview.h
index 495401b..aaf56b1 100644
--- a/libopie2/opieui/fileselector/ofileview.h
+++ b/libopie2/opieui/fileselector/ofileview.h
@@ -1,95 +1,98 @@
1/* 1/*
2               =. This file is part of the OPIE Project 2               =. This file is part of the OPIE Project
3             .=l. Copyright (C) 2002 Holger Freyther <zecke@handhelds.org> 3             .=l. Copyright (C) 2002 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#ifndef OFILEVIEW_H 29#ifndef OFILEVIEW_H
30#define OFILEVIEW_H 30#define OFILEVIEW_H
31 31
32/* QT */ 32/* QT */
33#include <qobject.h> 33#include <qobject.h>
34#include <qwidget.h> 34#include <qwidget.h>
35 35
36class QFileInfo; 36class QFileInfo;
37class QDir; 37class QDir;
38class DocLnk; 38class DocLnk;
39 39
40namespace Opie 40namespace Opie {
41{ 41namespace Ui {
42namespace Private {
42 43
43/** 44/**
44 * A OFileView is a specialised View for the 45 * A OFileView is a specialised View for the
45 * OFileSelector 46 * OFileSelector
46 * With a View you can chage the user visible 47 * With a View you can chage the user visible
47 * representation of a OFileLister 48 * representation of a OFileLister
48 * OFileView is just a basic interface which helps you to 49 * OFileView is just a basic interface which helps you to
49 * write new views 50 * write new views
50 */ 51 */
51class OFileView : public QWidget 52class OFileView : public QWidget
52{ 53{
53 Q_OBJECT 54 Q_OBJECT
54public: 55public:
55 OFileView(QWidget *widget, 56 OFileView(QWidget *widget,
56 const char *name ); 57 const char *name );
57 58
58 OFileView(); 59 OFileView();
59 60
60 virtual void addFile(const QString &mine, 61 virtual void addFile(const QString &mine,
61 QFileInfo *info, 62 QFileInfo *info,
62 bool isSymlink = FALSE ) = 0; 63 bool isSymlink = FALSE ) = 0;
63 64
64 virtual void addDir (const QString &mine, 65 virtual void addDir (const QString &mine,
65 QFileInfo *info, 66 QFileInfo *info,
66 bool isSymlink = FALSE ) = 0; 67 bool isSymlink = FALSE ) = 0;
67 68
68 virtual void addSymlink(const QString &mime, 69 virtual void addSymlink(const QString &mime,
69 QFileInfo *info, 70 QFileInfo *info,
70 bool isSymlink = FALSE ) = 0; 71 bool isSymlink = FALSE ) = 0;
71 72
72 virtual void cd(const QString &path ) = 0; 73 virtual void cd(const QString &path ) = 0;
73signals: 74signals:
74 void fileSelected(const QString &); 75 void fileSelected(const QString &);
75 void fileSelected(const DocLnk & ); 76 void fileSelected(const DocLnk & );
76 void contextMenu(); 77 void contextMenu();
77 void changedDir(const QString &); 78 void changedDir(const QString &);
78 void changedDir(const QDir & ); 79 void changedDir(const QDir & );
79}; 80};
80 81
81 82
82class OFileViewFactory 83class OFileViewFactory
83{ 84{
84 // Q_OBJECT 85 // Q_OBJECT
85public: 86public:
86 OFileViewFactory() {} ; 87 OFileViewFactory() {} ;
87 virtual ~OFileViewFactory() = 0; 88 virtual ~OFileViewFactory() = 0;
88 89
89 OFileView* newView(QWidget *parent, const char *name ); 90 OFileView* newView(QWidget *parent, const char *name );
90 QString name()const; 91 QString name()const;
91}; 92};
92 93
93}; 94}
95}
96}
94 97
95#endif 98#endif
diff --git a/libopie2/opieui/oclickablelabel.cpp b/libopie2/opieui/oclickablelabel.cpp
index 4c4e581..53cb77a 100644
--- a/libopie2/opieui/oclickablelabel.cpp
+++ b/libopie2/opieui/oclickablelabel.cpp
@@ -1,80 +1,80 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) Maximillian Reiß <harlekin@handhelds.org> 3 Copyright (C) Maximillian Reiß <harlekin@handhelds.org>
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org> 4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 .=l. 5 .=l.
6           .>+-= 6           .>+-=
7 _;:,     .>    :=|. This program is free software; you can 7 _;:,     .>    :=|. This program is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under 8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
10.="- .-=="i,     .._ License as published by the Free Software 10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License, 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version. 12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_. 13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This program is distributed in the hope that 14    .i_,=:_.      -<s. This program is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of 16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more 19..}^=.=       =       ; Library General Public License for more
20++=   -.     .`     .: details. 20++=   -.     .`     .: details.
21 :     =  ...= . :.=- 21 :     =  ...= . :.=-
22 -.   .:....=;==+<; You should have received a copy of the GNU 22 -.   .:....=;==+<; You should have received a copy of the GNU
23  -_. . .   )=.  = Library General Public License along with 23  -_. . .   )=.  = Library General Public License along with
24    --        :-=` this library; see the file COPYING.LIB. 24    --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29 29
30#include <opie2/oclickablelabel.h> 30#include <opie2/oclickablelabel.h>
31 31
32using namespace Opie; 32using namespace Opie::Ui;
33 33
34/** 34/**
35 * This constructs the clickable ButtonLabel 35 * This constructs the clickable ButtonLabel
36 * 36 *
37 * @param parent The parent of this label 37 * @param parent The parent of this label
38 * @param name A name of this label @see QObject 38 * @param name A name of this label @see QObject
39 * @param fl The windowing flags 39 * @param fl The windowing flags
40 */ 40 */
41OClickableLabel::OClickableLabel(QWidget* parent, const char* name, WFlags fl) 41OClickableLabel::OClickableLabel(QWidget* parent, const char* name, WFlags fl)
42 :QLabel(parent,name,fl) 42 :QLabel(parent,name,fl)
43{ 43{
44 textInverted=false; 44 textInverted=false;
45 isToggle=false; 45 isToggle=false;
46 isDown=false; 46 isDown=false;
47 showState(false); 47 showState(false);
48 setFrameShadow(Sunken); 48 setFrameShadow(Sunken);
49} 49}
50 50
51/** 51/**
52 * This method makes the label behave as a toggle button 52 * This method makes the label behave as a toggle button
53 * 53 *
54 * @param t Whether or not to behave like a toggle button 54 * @param t Whether or not to behave like a toggle button
55 */ 55 */
56void OClickableLabel::setToggleButton(bool t) 56void OClickableLabel::setToggleButton(bool t)
57{ 57{
58 isToggle=t; 58 isToggle=t;
59} 59}
60 60
61/** 61/**
62 * @internal 62 * @internal
63 */ 63 */
64void OClickableLabel::mousePressEvent( QMouseEvent * /*e*/ ) 64void OClickableLabel::mousePressEvent( QMouseEvent * /*e*/ )
65{ 65{
66 if (isToggle && isDown) 66 if (isToggle && isDown)
67 { 67 {
68 showState(false); 68 showState(false);
69 } 69 }
70 else 70 else
71 { 71 {
72 showState(true); 72 showState(true);
73 } 73 }
74} 74}
75 75
76/** 76/**
77 * @internal 77 * @internal
78 */ 78 */
79void OClickableLabel::mouseReleaseEvent( QMouseEvent *e ) 79void OClickableLabel::mouseReleaseEvent( QMouseEvent *e )
80{ 80{
diff --git a/libopie2/opieui/oclickablelabel.h b/libopie2/opieui/oclickablelabel.h
index b224d61..90859a0 100644
--- a/libopie2/opieui/oclickablelabel.h
+++ b/libopie2/opieui/oclickablelabel.h
@@ -1,103 +1,104 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) Maximillian Reiß <harlekin@handhelds.org> 3 Copyright (C) Maximillian Reiß <harlekin@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#ifndef OCLICKABLELABEL_H 30#ifndef OCLICKABLELABEL_H
31#define OCLICKABLELABEL_H 31#define OCLICKABLELABEL_H
32 32
33/* QT */ 33/* QT */
34#include <qlabel.h> 34#include <qlabel.h>
35 35
36namespace Opie 36namespace Opie{
37{ 37namespace Ui {
38 38
39/** 39/**
40 * This class is a special QLabel which can behave 40 * This class is a special QLabel which can behave
41 * as a QPushButton or QToggleButton. 41 * as a QPushButton or QToggleButton.
42 * The reason to use a clickable is if you want to save space 42 * The reason to use a clickable is if you want to save space
43 * or you want to skip the border of a normal button 43 * or you want to skip the border of a normal button
44 * 44 *
45 * <pre> 45 * <pre>
46 * QLabel* lbl = new OClickableLabel( parent, "PushLabel" ); 46 * QLabel* lbl = new OClickableLabel( parent, "PushLabel" );
47 * lbl->setPixmap( "config" ); 47 * lbl->setPixmap( "config" );
48 * QWhatsThis::add( lbl, tr("Click here to do something") ); 48 * QWhatsThis::add( lbl, tr("Click here to do something") );
49 * </pre> 49 * </pre>
50 * 50 *
51 * @short A Label behaving as button 51 * @short A Label behaving as button
52 * @author Hakan Ardo, Maximillian Reiß ( harlekin@handhelds.org ) 52 * @author Hakan Ardo, Maximillian Reiß ( harlekin@handhelds.org )
53 * @see QLabel 53 * @see QLabel
54 * @see QPushButton 54 * @see QPushButton
55 * @see QToggleButton 55 * @see QToggleButton
56 * @version 1.0 56 * @version 1.0
57 */ 57 */
58 58
59class OClickableLabel: public QLabel 59class OClickableLabel: public QLabel
60{ 60{
61 Q_OBJECT 61 Q_OBJECT
62public: 62public:
63 OClickableLabel(QWidget* parent = 0, const char* name = 0, 63 OClickableLabel(QWidget* parent = 0, const char* name = 0,
64 WFlags fl = 0); 64 WFlags fl = 0);
65 void setToggleButton(bool t); 65 void setToggleButton(bool t);
66 66
67protected: 67protected:
68 /** @internal */ 68 /** @internal */
69 void mousePressEvent( QMouseEvent *e ); 69 void mousePressEvent( QMouseEvent *e );
70 /** @internal */ 70 /** @internal */
71 void mouseReleaseEvent( QMouseEvent *e ); 71 void mouseReleaseEvent( QMouseEvent *e );
72 /** @internal */ 72 /** @internal */
73 void mouseMoveEvent( QMouseEvent *e ); 73 void mouseMoveEvent( QMouseEvent *e );
74 74
75public slots: 75public slots:
76 void setOn(bool on); 76 void setOn(bool on);
77signals: 77signals:
78 /** 78 /**
79 * emitted when the labels gets clicked 79 * emitted when the labels gets clicked
80 */ 80 */
81 void clicked(); 81 void clicked();
82 82
83 /** 83 /**
84 * emitted when the labels gets toggled 84 * emitted when the labels gets toggled
85 * @param on the new new state of the label 85 * @param on the new new state of the label
86 */ 86 */
87 void toggled(bool on); 87 void toggled(bool on);
88private: 88private:
89 bool isToggle : 1; 89 bool isToggle : 1;
90 bool isDown : 1; 90 bool isDown : 1;
91 bool textInverted : 1; 91 bool textInverted : 1;
92 92
93 void showState(bool on); 93 void showState(bool on);
94 void setInverted(bool on); 94 void setInverted(bool on);
95 95
96private: 96private:
97 class Private; 97 class Private;
98 Private *d; // private d pointer 98 Private *d; // private d pointer
99}; 99};
100 100
101}; 101}
102}
102 103
103#endif 104#endif
diff --git a/libopie2/opieui/odialog.cpp b/libopie2/opieui/odialog.cpp
index 4d269d4..27f8d20 100644
--- a/libopie2/opieui/odialog.cpp
+++ b/libopie2/opieui/odialog.cpp
@@ -1,55 +1,57 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3              Copyright (C) 2003 Michael 'Mickey' Lauer <mickey@Vanille.de> 3              Copyright (C) 2003 Michael 'Mickey' Lauer <mickey@Vanille.de>
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 30
31#include <opie2/odialog.h> 31#include <opie2/odialog.h>
32 32
33#warning Make Margin and Spacing device dependend and configurable! 33#warning Make Margin and Spacing device dependend and configurable!
34 34
35using namespace Opie::Ui;
36
35int ODialog::mMarginSize = 5; 37int ODialog::mMarginSize = 5;
36int ODialog::mSpacingSize = 2; 38int ODialog::mSpacingSize = 2;
37 39
38ODialog::ODialog(QWidget *parent, const char *name, bool modal, WFlags f) 40ODialog::ODialog(QWidget *parent, const char *name, bool modal, WFlags f)
39 :QDialog(parent, name, modal, f) 41 :QDialog(parent, name, modal, f)
40{ 42{
41 // d = new ODialogPrivate(); 43 // d = new ODialogPrivate();
42} 44}
43 45
44int ODialog::marginHint() 46int ODialog::marginHint()
45{ 47{
46 return( mMarginSize ); 48 return( mMarginSize );
47} 49}
48 50
49 51
50int ODialog::spacingHint() 52int ODialog::spacingHint()
51{ 53{
52 return( mSpacingSize ); 54 return( mSpacingSize );
53} 55}
54 56
55// Placeholder for even more sophisticed things 57// Placeholder for even more sophisticed things
diff --git a/libopie2/opieui/odialog.h b/libopie2/opieui/odialog.h
index ceff612..57f534c 100644
--- a/libopie2/opieui/odialog.h
+++ b/libopie2/opieui/odialog.h
@@ -10,82 +10,87 @@
10.="- .-=="i,     .._ License as published by the Free Software 10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License, 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version. 12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_. 13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This program is distributed in the hope that 14    .i_,=:_.      -<s. This program is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of 16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more 19..}^=.=       =       ; Library General Public License for more
20++=   -.     .`     .: details. 20++=   -.     .`     .: details.
21 :     =  ...= . :.=- 21 :     =  ...= . :.=-
22 -.   .:....=;==+<; You should have received a copy of the GNU 22 -.   .:....=;==+<; You should have received a copy of the GNU
23  -_. . .   )=.  = Library General Public License along with 23  -_. . .   )=.  = Library General Public License along with
24    --        :-=` this library; see the file COPYING.LIB. 24    --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28 28
29*/ 29*/
30 30
31#ifndef ODIALOG_H 31#ifndef ODIALOG_H
32#define ODIALOG_H 32#define ODIALOG_H
33 33
34class QLayoutItem; 34class QLayoutItem;
35 35
36#include <qdialog.h> 36#include <qdialog.h>
37 37
38/** 38/**
39 * Dialog with extended nonmodal support and methods for OPIE standard 39 * Dialog with extended nonmodal support and methods for OPIE standard
40 * compliance. 40 * compliance.
41 * 41 *
42 * The @ref marginHint() and @ref spacingHint() sizes shall be used 42 * The @ref marginHint() and @ref spacingHint() sizes shall be used
43 * whenever you layout the interior of a dialog. One special note. If 43 * whenever you layout the interior of a dialog. One special note. If
44 * you make your own action buttons (OK, Cancel etc), the space 44 * you make your own action buttons (OK, Cancel etc), the space
45 * beteween the buttons shall be @ref spacingHint(), whereas the space 45 * beteween the buttons shall be @ref spacingHint(), whereas the space
46 * above, below, to the right and to the left shall be @ref marginHint(). 46 * above, below, to the right and to the left shall be @ref marginHint().
47 * If you add a separator line above the buttons, there shall be a 47 * If you add a separator line above the buttons, there shall be a
48 * @ref marginHint() between the buttons and the separator and a 48 * @ref marginHint() between the buttons and the separator and a
49 * @ref marginHint() above the separator as well. 49 * @ref marginHint() above the separator as well.
50 * 50 *
51 * @author Michael 'Mickey' Lauer <mickey@Vanille.de> 51 * @author Michael 'Mickey' Lauer <mickey@Vanille.de>
52 */ 52 */
53 53
54 // lets fix up Qt instead! Size does matter. -zecke 54 // lets fix up Qt instead! Size does matter. -zecke
55 // while that may be true, reducing maintainance effort for the future does also matter - 55 // while that may be true, reducing maintainance effort for the future does also matter -
56 // and I believe that maintaining a patch against QtE is more work than our classes -mml 56 // and I believe that maintaining a patch against QtE is more work than our classes -mml
57 57
58namespace Opie {
59namespace Ui {
60
58class ODialog : public QDialog 61class ODialog : public QDialog
59{ 62{
60 Q_OBJECT 63 Q_OBJECT
61 64
62 public: 65 public:
63 66
64 /** 67 /**
65 * Constructor. 68 * Constructor.
66 * 69 *
67 * Takes the same arguments as @ref QDialog. 70 * Takes the same arguments as @ref QDialog.
68 */ 71 */
69 ODialog(QWidget *parent = 0, const char *name = 0, bool modal = false, WFlags f = 0); 72 ODialog(QWidget *parent = 0, const char *name = 0, bool modal = false, WFlags f = 0);
70 73
71 /** 74 /**
72 * Return the number of pixels you shall use between a 75 * Return the number of pixels you shall use between a
73 * dialog edge and the outermost widget(s) according to the KDE standard. 76 * dialog edge and the outermost widget(s) according to the KDE standard.
74 **/ 77 **/
75 static int marginHint(); 78 static int marginHint();
76 79
77 /** 80 /**
78 * Return the number of pixels you shall use between 81 * Return the number of pixels you shall use between
79 * widgets inside a dialog according to the KDE standard. 82 * widgets inside a dialog according to the KDE standard.
80 */ 83 */
81 static int spacingHint(); 84 static int spacingHint();
82 85
83 private: 86 private:
84 static int mMarginSize; 87 static int mMarginSize;
85 static int mSpacingSize; 88 static int mSpacingSize;
86 89
87 class ODialogPrivate; 90 class ODialogPrivate;
88 ODialogPrivate *d; 91 ODialogPrivate *d;
89 92
90}; 93};
94}
95}
91#endif // ODIALOG_H 96#endif // ODIALOG_H
diff --git a/libopie2/opieui/ofontselector.cpp b/libopie2/opieui/ofontselector.cpp
index f93781f..b19c26e 100644
--- a/libopie2/opieui/ofontselector.cpp
+++ b/libopie2/opieui/ofontselector.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 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;
42 41
43namespace Opie 42namespace Opie {
44{ 43namespace Ui {
44namespace Private {
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};
60
61namespace
62{
63
64class FontListItem : public QListBoxText 59class FontListItem : public QListBoxText
65{ 60{
66public: 61public:
67 FontListItem ( const QString &t, const QStringList &styles, const QValueList<int> &sizes ) : QListBoxText() 62 FontListItem ( const QString &t, const QStringList &styles, const QValueList<int> &sizes ) : QListBoxText()
68 { 63 {
69 m_name = t; 64 m_name = t;
70 m_styles = styles; 65 m_styles = styles;
71 m_sizes = sizes; 66 m_sizes = sizes;
72 67
73 QString str = t; 68 QString str = t;
74 str [0] = str [0]. upper(); 69 str [0] = str [0]. upper();
75 setText ( str ); 70 setText ( str );
76 } 71 }
77 72
78 QString family() const 73 QString family() const
79 { 74 {
80 return m_name; 75 return m_name;
81 } 76 }
82 77
83 const QStringList &styles() const 78 const QStringList &styles() const
84 { 79 {
85 return m_styles; 80 return m_styles;
86 } 81 }
87 82
88 const QValueList<int> &sizes() const 83 const QValueList<int> &sizes() const
89 { 84 {
90 return m_sizes; 85 return m_sizes;
91 } 86 }
92 87
93private: 88private:
94 QStringList m_styles; 89 QStringList m_styles;
95 QValueList<int> m_sizes; 90 QValueList<int> m_sizes;
96 QString m_name; 91 QString m_name;
97}; 92};
93}
94}
95}
96
98 97
98using namespace Opie::Ui;
99using namespace Opie::Ui::Private;
99 100
100static int findItemCB( QComboBox *box, const QString &str ) 101static int findItemCB( QComboBox *box, const QString &str )
101{ 102{
102 for ( int i = 0; i < box->count(); i++ ) 103 for ( int i = 0; i < box->count(); i++ )
103 { 104 {
104 if ( box->text ( i ) == str ) 105 if ( box->text ( i ) == str )
105 return i; 106 return i;
106 } 107 }
107 return -1; 108 return -1;
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 );
@@ -381,48 +381,49 @@ void OFontSelector::fontSizeClicked ( int /*index*/ )
381} 381}
382 382
383void OFontSelector::changeFont() 383void OFontSelector::changeFont()
384{ 384{
385 QFont f = selectedFont(); 385 QFont f = selectedFont();
386 386
387 if ( d->m_preview ) 387 if ( d->m_preview )
388 d->m_preview->setFont ( f ); 388 d->m_preview->setFont ( f );
389 389
390 emit fontSelected ( f ); 390 emit fontSelected ( f );
391} 391}
392 392
393/** 393/**
394 * Return the selected font 394 * Return the selected font
395 */ 395 */
396QFont OFontSelector::selectedFont() 396QFont OFontSelector::selectedFont()
397{ 397{
398 int ffa = d->m_font_family_list->currentItem(); 398 int ffa = d->m_font_family_list->currentItem();
399 int fst = d->m_font_style_list->currentItem(); 399 int fst = d->m_font_style_list->currentItem();
400 int fsi = d->m_font_size_list->currentItem(); 400 int fsi = d->m_font_size_list->currentItem();
401 401
402 FontListItem *fli = (FontListItem *) d->m_font_family_list->item ( ffa ); 402 FontListItem *fli = (FontListItem *) d->m_font_family_list->item ( ffa );
403 403
404 if ( fli ) 404 if ( fli )
405 { 405 {
406 return d->m_fdb. font ( fli->family(), \ 406 return d->m_fdb. font ( fli->family(), \
407 fst >= 0 ? fli->styles() [fst] : QString::null, \ 407 fst >= 0 ? fli->styles() [fst] : QString::null, \
408 fsi >= 0 ? fli->sizes() [fsi] : 10, \ 408 fsi >= 0 ? fli->sizes() [fsi] : 10, \
409 d->m_fdb. charSets ( fli->family()) [0] ); 409 d->m_fdb. charSets ( fli->family()) [0] );
410 } 410 }
411 else 411 else
412 return QFont(); 412 return QFont();
413} 413}
414 414
415void OFontSelector::resizeEvent ( QResizeEvent *re ) 415void OFontSelector::resizeEvent ( QResizeEvent *re )
416{ 416{
417 if ( d->m_preview ) 417 if ( d->m_preview )
418 { 418 {
419 d->m_preview->setMinimumHeight ( 1 ); 419 d->m_preview->setMinimumHeight ( 1 );
420 d->m_preview->setMaximumHeight ( 32767 ); 420 d->m_preview->setMaximumHeight ( 32767 );
421 } 421 }
422 422
423 QWidget::resizeEvent ( re ); 423 QWidget::resizeEvent ( re );
424 424
425 if ( d->m_preview ) 425 if ( d->m_preview )
426 d->m_preview->setFixedHeight ( d->m_preview->height()); 426 d->m_preview->setFixedHeight ( d->m_preview->height());
427 427
428} 428}
429
diff --git a/libopie2/opieui/ofontselector.h b/libopie2/opieui/ofontselector.h
index ad51819..1d97233 100644
--- a/libopie2/opieui/ofontselector.h
+++ b/libopie2/opieui/ofontselector.h
@@ -1,104 +1,106 @@
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#ifndef OFONTSELECTOR_H 30#ifndef OFONTSELECTOR_H
31#define OFONTSELECTOR_H 31#define OFONTSELECTOR_H
32 32
33/* QT */ 33/* QT */
34#include <qwidget.h> 34#include <qwidget.h>
35 35
36class QListBox; 36class QListBox;
37 37
38namespace Opie 38namespace Opie {
39{ 39namespace Ui {
40 40namespace Private {
41class OFontSelectorPrivate; 41class OFontSelectorPrivate;
42}
42 43
43/** 44/**
44 * This class lets you chose a Font out of a list of Fonts. 45 * This class lets you chose a Font out of a list of Fonts.
45 * It can show a preview too. This selector will use all available 46 * It can show a preview too. This selector will use all available
46 * fonts 47 * fonts
47 * 48 *
48 * 49 *
49 * @short A widget to select a font 50 * @short A widget to select a font
50 * @see QWidget 51 * @see QWidget
51 * @see QFont 52 * @see QFont
52 * @author Rober Griebl 53 * @author Rober Griebl
53 */ 54 */
54class OFontSelector : public QWidget 55class OFontSelector : public QWidget
55{ 56{
56 Q_OBJECT 57 Q_OBJECT
57 58
58public: 59public:
59 OFontSelector ( bool withpreview, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); 60 OFontSelector ( bool withpreview, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
60 virtual ~OFontSelector ( ); 61 virtual ~OFontSelector ( );
61 62
62 bool selectedFont ( QString &family, QString &style, int &size ); 63 bool selectedFont ( QString &family, QString &style, int &size );
63 bool selectedFont ( QString &family, QString &style, int &size, QString &charset ); 64 bool selectedFont ( QString &family, QString &style, int &size, QString &charset );
64 65
65 QFont selectedFont ( ); 66 QFont selectedFont ( );
66 67
67 bool setSelectedFont ( const QFont & ); 68 bool setSelectedFont ( const QFont & );
68 bool setSelectedFont ( const QString &family, const QString &style, int size, const QString &charset = 0 ); 69 bool setSelectedFont ( const QString &family, const QString &style, int size, const QString &charset = 0 );
69 70
70 QString fontFamily ( ) const; 71 QString fontFamily ( ) const;
71 QString fontStyle ( ) const; 72 QString fontStyle ( ) const;
72 int fontSize ( ) const; 73 int fontSize ( ) const;
73 QString fontCharSet ( ) const; 74 QString fontCharSet ( ) const;
74 75
75signals: 76signals:
76 /** 77 /**
77 * This signal gets emitted when a font got chosen 78 * This signal gets emitted when a font got chosen
78 */ 79 */
79 void fontSelected ( const QFont & ); 80 void fontSelected ( const QFont & );
80 81
81protected slots: 82protected slots:
82 /** @internal */ 83 /** @internal */
83 virtual void fontFamilyClicked ( int ); 84 virtual void fontFamilyClicked ( int );
84 /** @internal */ 85 /** @internal */
85 virtual void fontStyleClicked ( int ); 86 virtual void fontStyleClicked ( int );
86 /** @internal */ 87 /** @internal */
87 virtual void fontSizeClicked ( int ); 88 virtual void fontSizeClicked ( int );
88 89
89protected: 90protected:
90 virtual void resizeEvent ( QResizeEvent *re ); 91 virtual void resizeEvent ( QResizeEvent *re );
91 92
92private: 93private:
93 void loadFonts ( QListBox * ); 94 void loadFonts ( QListBox * );
94 95
95 void changeFont ( ); 96 void changeFont ( );
96 97
97private: 98private:
98 OFontSelectorPrivate *d; 99 Private::OFontSelectorPrivate *d;
99}; 100};
100 101
101}; 102}
103}
102 104
103#endif 105#endif
104 106
diff --git a/libopie2/opieui/oimageeffect.cpp b/libopie2/opieui/oimageeffect.cpp
index 9a58bb9..be47eb2 100644
--- a/libopie2/opieui/oimageeffect.cpp
+++ b/libopie2/opieui/oimageeffect.cpp
@@ -1,91 +1,95 @@
1/* This file is part of the KDE libraries 1/* This file is part of the KDE libraries
2 Copyright (C) 1998, 1999, 2001, 2002 Daniel M. Duley <mosfet@kde.org> 2 Copyright (C) 1998, 1999, 2001, 2002 Daniel M. Duley <mosfet@kde.org>
3 (C) 1998, 1999 Christian Tibirna <ctibirna@total.net> 3 (C) 1998, 1999 Christian Tibirna <ctibirna@total.net>
4 (C) 1998, 1999 Dirk A. Mueller <mueller@kde.org> 4 (C) 1998, 1999 Dirk A. Mueller <mueller@kde.org>
5 (C) 2000 Josef Weidendorfer <weidendo@in.tum.de> 5 (C) 2000 Josef Weidendorfer <weidendo@in.tum.de>
6 6
7Redistribution and use in source and binary forms, with or without 7Redistribution and use in source and binary forms, with or without
8modification, are permitted provided that the following conditions 8modification, are permitted provided that the following conditions
9are met: 9are met:
10 10
111. Redistributions of source code must retain the above copyright 111. Redistributions of source code must retain the above copyright
12 notice, this list of conditions and the following disclaimer. 12 notice, this list of conditions and the following disclaimer.
132. Redistributions in binary form must reproduce the above copyright 132. Redistributions in binary form must reproduce the above copyright
14 notice, this list of conditions and the following disclaimer in the 14 notice, this list of conditions and the following disclaimer in the
15 documentation and/or other materials provided with the distribution. 15 documentation and/or other materials provided with the distribution.
16 16
17THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28*/ 28*/
29 29
30// $Id$ 30// $Id$
31 31
32#include <math.h> 32#include <math.h>
33 33
34#include <qimage.h> 34#include <qimage.h>
35#include <stdlib.h> 35#include <stdlib.h>
36 36
37#include <opie2/oimageeffect.h> 37#include <opie2/oimageeffect.h>
38#include <opie2/odebug.h> 38#include <opie2/odebug.h>
39 39
40#define MaxRGB 255L 40#define MaxRGB 255L
41#define DegreesToRadians(x) ((x)*M_PI/180.0) 41#define DegreesToRadians(x) ((x)*M_PI/180.0)
42 42
43using namespace std; 43using namespace std;
44using namespace Opie::Core;
45
46namespace Opie {
47namespace Ui {
44 48
45inline unsigned int intensityValue(unsigned int color) 49inline unsigned int intensityValue(unsigned int color)
46{ 50{
47 return((unsigned int)((0.299*qRed(color) + 51 return((unsigned int)((0.299*qRed(color) +
48 0.587*qGreen(color) + 52 0.587*qGreen(color) +
49 0.1140000000000001*qBlue(color)))); 53 0.1140000000000001*qBlue(color))));
50} 54}
51 55
52//====================================================================== 56//======================================================================
53// 57//
54// Gradient effects 58// Gradient effects
55// 59//
56//====================================================================== 60//======================================================================
57 61
58QImage OImageEffect::gradient(const QSize &size, const QColor &ca, 62QImage OImageEffect::gradient(const QSize &size, const QColor &ca,
59 const QColor &cb, GradientType eff, int ncols) 63 const QColor &cb, GradientType eff, int ncols)
60{ 64{
61 int rDiff, gDiff, bDiff; 65 int rDiff, gDiff, bDiff;
62 int rca, gca, bca, rcb, gcb, bcb; 66 int rca, gca, bca, rcb, gcb, bcb;
63 67
64 QImage image(size, 32); 68 QImage image(size, 32);
65 69
66 if (size.width() == 0 || size.height() == 0) { 70 if (size.width() == 0 || size.height() == 0) {
67 odebug << "WARNING: OImageEffect::gradient: invalid image" << oendl; 71 odebug << "WARNING: OImageEffect::gradient: invalid image" << oendl;
68 return image; 72 return image;
69 } 73 }
70 74
71 register int x, y; 75 register int x, y;
72 76
73 rDiff = (rcb = cb.red()) - (rca = ca.red()); 77 rDiff = (rcb = cb.red()) - (rca = ca.red());
74 gDiff = (gcb = cb.green()) - (gca = ca.green()); 78 gDiff = (gcb = cb.green()) - (gca = ca.green());
75 bDiff = (bcb = cb.blue()) - (bca = ca.blue()); 79 bDiff = (bcb = cb.blue()) - (bca = ca.blue());
76 80
77 if( eff == VerticalGradient || eff == HorizontalGradient ){ 81 if( eff == VerticalGradient || eff == HorizontalGradient ){
78 82
79 uint *p; 83 uint *p;
80 uint rgb; 84 uint rgb;
81 85
82 register int rl = rca << 16; 86 register int rl = rca << 16;
83 register int gl = gca << 16; 87 register int gl = gca << 16;
84 register int bl = bca << 16; 88 register int bl = bca << 16;
85 89
86 if( eff == VerticalGradient ) { 90 if( eff == VerticalGradient ) {
87 91
88 int rcdelta = ((1<<16) / size.height()) * rDiff; 92 int rcdelta = ((1<<16) / size.height()) * rDiff;
89 int gcdelta = ((1<<16) / size.height()) * gDiff; 93 int gcdelta = ((1<<16) / size.height()) * gDiff;
90 int bcdelta = ((1<<16) / size.height()) * bDiff; 94 int bcdelta = ((1<<16) / size.height()) * bDiff;
91 95
@@ -3720,49 +3724,50 @@ QImage OImageEffect::blur(QImage &src, double factor)
3720 *q++=(*(cTable+(*p))); 3724 *q++=(*(cTable+(*p)));
3721 } 3725 }
3722 } 3726 }
3723 return(dest); 3727 return(dest);
3724} 3728}
3725 3729
3726// High quality, expensive HSV contrast. You can do a faster one by just 3730// High quality, expensive HSV contrast. You can do a faster one by just
3727// taking a grayscale threshold (ie: 128) and incrementing RGB color 3731// taking a grayscale threshold (ie: 128) and incrementing RGB color
3728// channels above it and decrementing those below it, but this gives much 3732// channels above it and decrementing those below it, but this gives much
3729// better results. (mosfet 12/28/01) 3733// better results. (mosfet 12/28/01)
3730void OImageEffect::contrastHSV(QImage &img, bool sharpen) 3734void OImageEffect::contrastHSV(QImage &img, bool sharpen)
3731{ 3735{
3732 int i, sign; 3736 int i, sign;
3733 unsigned int *data; 3737 unsigned int *data;
3734 int count; 3738 int count;
3735 double brightness, scale, theta; 3739 double brightness, scale, theta;
3736 QColor c; 3740 QColor c;
3737 int h, s, v; 3741 int h, s, v;
3738 3742
3739 sign = sharpen ? 1 : -1; 3743 sign = sharpen ? 1 : -1;
3740 scale=0.5000000000000001; 3744 scale=0.5000000000000001;
3741 if(img.depth() > 8){ 3745 if(img.depth() > 8){
3742 count = img.width()*img.height(); 3746 count = img.width()*img.height();
3743 data = (unsigned int *)img.bits(); 3747 data = (unsigned int *)img.bits();
3744 } 3748 }
3745 else{ 3749 else{
3746 count = img.numColors(); 3750 count = img.numColors();
3747 data = (unsigned int *)img.colorTable(); 3751 data = (unsigned int *)img.colorTable();
3748 } 3752 }
3749 for(i=0; i < count; ++i){ 3753 for(i=0; i < count; ++i){
3750 c.setRgb(data[i]); 3754 c.setRgb(data[i]);
3751 c.hsv(&h, &s, &v); 3755 c.hsv(&h, &s, &v);
3752 brightness = v/255.0; 3756 brightness = v/255.0;
3753 theta=(brightness-0.5)*M_PI; 3757 theta=(brightness-0.5)*M_PI;
3754 brightness+=scale*(((scale*((sin(theta)+1.0)))-brightness)*sign); 3758 brightness+=scale*(((scale*((sin(theta)+1.0)))-brightness)*sign);
3755 if (brightness > 1.0) 3759 if (brightness > 1.0)
3756 brightness=1.0; 3760 brightness=1.0;
3757 else 3761 else
3758 if (brightness < 0) 3762 if (brightness < 0)
3759 brightness=0.0; 3763 brightness=0.0;
3760 v = (int)(brightness*255); 3764 v = (int)(brightness*255);
3761 c.setHsv(h, s, v); 3765 c.setHsv(h, s, v);
3762 data[i] = qRgba(c.red(), c.green(), c.blue(), qAlpha(data[i])); 3766 data[i] = qRgba(c.red(), c.green(), c.blue(), qAlpha(data[i]));
3763 } 3767 }
3764} 3768}
3765 3769
3766 3770
3767 3771
3768 3772}
3773}
diff --git a/libopie2/opieui/oimageeffect.h b/libopie2/opieui/oimageeffect.h
index fb4d22d..4f86d5b 100644
--- a/libopie2/opieui/oimageeffect.h
+++ b/libopie2/opieui/oimageeffect.h
@@ -1,89 +1,91 @@
1//FIXME: Revise for Opie - do we really need such fancy stuff on PDA's? 1//FIXME: Revise for Opie - do we really need such fancy stuff on PDA's?
2//FIXME: Maybe not on SL5xxx, but surely on C700 :)) 2//FIXME: Maybe not on SL5xxx, but surely on C700 :))
3//FIXME: I think we don#t need that -zecke 3//FIXME: I think we don#t need that -zecke
4 4
5/* This file is part of the KDE libraries 5/* This file is part of the KDE libraries
6 Copyright (C) 1998, 1999, 2001, 2002 Daniel M. Duley <mosfet@interaccess.com> 6 Copyright (C) 1998, 1999, 2001, 2002 Daniel M. Duley <mosfet@interaccess.com>
7 (C) 1998, 1999 Christian Tibirna <ctibirna@total.net> 7 (C) 1998, 1999 Christian Tibirna <ctibirna@total.net>
8 (C) 1998, 1999 Dirk A. Mueller <mueller@kde.org> 8 (C) 1998, 1999 Dirk A. Mueller <mueller@kde.org>
9 9
10Redistribution and use in source and binary forms, with or without 10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions 11modification, are permitted provided that the following conditions
12are met: 12are met:
13 13
141. Redistributions of source code must retain the above copyright 141. Redistributions of source code must retain the above copyright
15 notice, this list of conditions and the following disclaimer. 15 notice, this list of conditions and the following disclaimer.
162. Redistributions in binary form must reproduce the above copyright 162. Redistributions in binary form must reproduce the above copyright
17 notice, this list of conditions and the following disclaimer in the 17 notice, this list of conditions and the following disclaimer in the
18 documentation and/or other materials provided with the distribution. 18 documentation and/or other materials provided with the distribution.
19 19
20THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 30
31*/ 31*/
32 32
33// $Id$ 33// $Id$
34 34
35#ifndef OIMAGEEFFECT_H 35#ifndef OIMAGEEFFECT_H
36#define OIMAGEEFFECT_H 36#define OIMAGEEFFECT_H
37 37
38class QImage; 38class QImage;
39class QSize; 39class QSize;
40class QColor; 40class QColor;
41 41
42namespace Opie {
43namespace Ui {
42/** 44/**
43 * This class includes various @ref QImage based graphical effects. 45 * This class includes various @ref QImage based graphical effects.
44 * 46 *
45 * Everything is 47 * Everything is
46 * static, so there is no need to create an instance of this class. You can 48 * static, so there is no need to create an instance of this class. You can
47 * just call the static methods. They are encapsulated here merely to provide 49 * just call the static methods. They are encapsulated here merely to provide
48 * a common namespace. 50 * a common namespace.
49 */ 51 */
50 52
51class OImageEffect 53class OImageEffect
52{ 54{
53public: 55public:
54 enum GradientType { VerticalGradient, HorizontalGradient, 56 enum GradientType { VerticalGradient, HorizontalGradient,
55 DiagonalGradient, CrossDiagonalGradient, 57 DiagonalGradient, CrossDiagonalGradient,
56 PyramidGradient, RectangleGradient, 58 PyramidGradient, RectangleGradient,
57 PipeCrossGradient, EllipticGradient }; 59 PipeCrossGradient, EllipticGradient };
58 enum RGBComponent { Red, Green, Blue, Gray, All }; 60 enum RGBComponent { Red, Green, Blue, Gray, All };
59 61
60 enum Lighting {NorthLite, NWLite, WestLite, SWLite, 62 enum Lighting {NorthLite, NWLite, WestLite, SWLite,
61 SouthLite, SELite, EastLite, NELite}; 63 SouthLite, SELite, EastLite, NELite};
62 64
63 enum ModulationType { Intensity, Saturation, HueShift, Contrast }; 65 enum ModulationType { Intensity, Saturation, HueShift, Contrast };
64 66
65 enum NoiseType { UniformNoise=0, GaussianNoise, MultiplicativeGaussianNoise, 67 enum NoiseType { UniformNoise=0, GaussianNoise, MultiplicativeGaussianNoise,
66 ImpulseNoise, LaplacianNoise, PoissonNoise}; 68 ImpulseNoise, LaplacianNoise, PoissonNoise};
67 69
68 enum RotateDirection{ Rotate90, Rotate180, Rotate270 }; 70 enum RotateDirection{ Rotate90, Rotate180, Rotate270 };
69 71
70 /** 72 /**
71 * Create a gradient from color a to color b of the specified type. 73 * Create a gradient from color a to color b of the specified type.
72 * 74 *
73 * @param size The desired size of the gradient. 75 * @param size The desired size of the gradient.
74 * @param ca Color a 76 * @param ca Color a
75 * @param cb Color b 77 * @param cb Color b
76 * @param type The type of gradient. 78 * @param type The type of gradient.
77 * @param ncols The number of colors to use when not running on a 79 * @param ncols The number of colors to use when not running on a
78 * truecolor display. The gradient will be dithered to this number of 80 * truecolor display. The gradient will be dithered to this number of
79 * colors. Pass 0 to prevent dithering. 81 * colors. Pass 0 to prevent dithering.
80 */ 82 */
81 static QImage gradient(const QSize &size, const QColor &ca, 83 static QImage gradient(const QSize &size, const QColor &ca,
82 const QColor &cb, GradientType type, int ncols=3); 84 const QColor &cb, GradientType type, int ncols=3);
83 85
84 /** 86 /**
85 * Create an unbalanced gradient. 87 * Create an unbalanced gradient.
86 88
87 * An unbalanced gradient is a gradient where the transition from 89 * An unbalanced gradient is a gradient where the transition from
88 * color a to color b is not linear, but in this case, exponential. 90 * color a to color b is not linear, but in this case, exponential.
89 * 91 *
@@ -511,49 +513,52 @@ public:
511 double elevation=30.0); 513 double elevation=30.0);
512 /** 514 /**
513 * Swirls the image by a specified amount 515 * Swirls the image by a specified amount
514 * 516 *
515 * @author Daniel M. Duley (mosfet) 517 * @author Daniel M. Duley (mosfet)
516 * @param src The QImage to process. 518 * @param src The QImage to process.
517 * @param degrees The tightness of the swirl. 519 * @param degrees The tightness of the swirl.
518 * @param background An RGBA value to use for the background. After the 520 * @param background An RGBA value to use for the background. After the
519 * effect some pixels may be "empty". This value is used for those pixels. 521 * effect some pixels may be "empty". This value is used for those pixels.
520 * @return The swirled image. The original is not changed. 522 * @return The swirled image. The original is not changed.
521 */ 523 */
522 static QImage swirl(QImage &src, double degrees=50.0, unsigned int background = 524 static QImage swirl(QImage &src, double degrees=50.0, unsigned int background =
523 0xFFFFFFFF); 525 0xFFFFFFFF);
524 526
525 /** 527 /**
526 * Modifies the pixels along a sine wave. 528 * Modifies the pixels along a sine wave.
527 * 529 *
528 * @author Daniel M. Duley (mosfet) 530 * @author Daniel M. Duley (mosfet)
529 * @param src The QImage to process. 531 * @param src The QImage to process.
530 * @param amplitude The amplitude of the sine wave. 532 * @param amplitude The amplitude of the sine wave.
531 * @param wavelength The frequency of the sine wave. 533 * @param wavelength The frequency of the sine wave.
532 * @return The new image. The original is not changed. 534 * @return The new image. The original is not changed.
533 */ 535 */
534 static QImage wave(QImage &src, double amplitude=25.0, double frequency=150.0, 536 static QImage wave(QImage &src, double amplitude=25.0, double frequency=150.0,
535 unsigned int background = 0xFFFFFFFF); 537 unsigned int background = 0xFFFFFFFF);
536 538
537private: 539private:
538 540
539 /** 541 /**
540 * Helper function to fast calc some altered (lighten, shaded) colors 542 * Helper function to fast calc some altered (lighten, shaded) colors
541 * 543 *
542 */ 544 */
543 static unsigned int lHash(unsigned int c); 545 static unsigned int lHash(unsigned int c);
544 static unsigned int uHash(unsigned int c); 546 static unsigned int uHash(unsigned int c);
545 547
546 /** 548 /**
547 * Helper function to find the nearest color to the RBG triplet 549 * Helper function to find the nearest color to the RBG triplet
548 */ 550 */
549 static int nearestColor( int r, int g, int b, const QColor *pal, int size ); 551 static int nearestColor( int r, int g, int b, const QColor *pal, int size );
550 552
551 static void hull(const int x_offset, const int y_offset, const int polarity, 553 static void hull(const int x_offset, const int y_offset, const int polarity,
552 const int width, const int height, 554 const int width, const int height,
553 unsigned int *f, unsigned int *g); 555 unsigned int *f, unsigned int *g);
554 static unsigned int generateNoise(unsigned int pixel, NoiseType type); 556 static unsigned int generateNoise(unsigned int pixel, NoiseType type);
555 static unsigned int interpolateColor(QImage *image, double x, double y, 557 static unsigned int interpolateColor(QImage *image, double x, double y,
556 unsigned int background); 558 unsigned int background);
557}; 559};
558 560
561}
562}
563
559#endif 564#endif
diff --git a/libopie2/opieui/olistview.cpp b/libopie2/opieui/olistview.cpp
index 0ee2fde..38670b4 100644
--- a/libopie2/opieui/olistview.cpp
+++ b/libopie2/opieui/olistview.cpp
@@ -1,86 +1,91 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3 =. (C) 2003-2004 Michael 'Mickey' Lauer <mickey@Vanille.de> 3 =. (C) 2003-2004 Michael 'Mickey' Lauer <mickey@Vanille.de>
4 .=l. 4 .=l.
5           .>+-= 5           .>+-=
6 _;:,     .>    :=|. This program is free software; you can 6 _;:,     .>    :=|. This program is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under 7.> <`_,   >  .   <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 8:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
9.="- .-=="i,     .._ License as published by the Free Software 9.="- .-=="i,     .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; either version 2 of the License, 10 - .   .-<_>     .<> Foundation; either version 2 of the License,
11     ._= =}       : or (at your option) any later version. 11     ._= =}       : or (at your option) any later version.
12    .%`+i>       _;_. 12    .%`+i>       _;_.
13    .i_,=:_.      -<s. This program is distributed in the hope that 13    .i_,=:_.      -<s. This program is distributed in the hope that
14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15    : ..    .:,     . . . without even the implied warranty of 15    : ..    .:,     . . . without even the implied warranty of
16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
18..}^=.=       =       ; Library General Public License for more 18..}^=.=       =       ; Library General Public License for more
19++=   -.     .`     .: details. 19++=   -.     .`     .: details.
20 :     =  ...= . :.=- 20 :     =  ...= . :.=-
21 -.   .:....=;==+<; You should have received a copy of the GNU 21 -.   .:....=;==+<; You should have received a copy of the GNU
22  -_. . .   )=.  = Library General Public License along with 22  -_. . .   )=.  = Library General Public License along with
23    --        :-=` this library; see the file COPYING.LIB. 23    --        :-=` this library; see the file COPYING.LIB.
24 If not, write to the Free Software Foundation, 24 If not, write to the Free Software Foundation,
25 Inc., 59 Temple Place - Suite 330, 25 Inc., 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA. 26 Boston, MA 02111-1307, USA.
27 27
28*/ 28*/
29 29
30/* QT */ 30/* QT */
31 31
32#include <qpixmap.h> 32#include <qpixmap.h>
33 33
34/* OPIE */ 34/* OPIE */
35 35
36#include <opie2/odebug.h> 36#include <opie2/odebug.h>
37#include <opie2/olistview.h> 37#include <opie2/olistview.h>
38 38
39using namespace Opie::Core;
40
41
42namespace Opie {
43namespace Ui {
39/*====================================================================================== 44/*======================================================================================
40 * OListView 45 * OListView
41 *======================================================================================*/ 46 *======================================================================================*/
42 47
43OListView::OListView( QWidget *parent, const char *name ) 48OListView::OListView( QWidget *parent, const char *name )
44 :QListView( parent, name ) 49 :QListView( parent, name )
45{ 50{
46 //FIXME: get from global settings and calculate ==> see oglobalsettings.* 51 //FIXME: get from global settings and calculate ==> see oglobalsettings.*
47 52
48 m_alternateBackground = QColor( 238, 246, 255 ); 53 m_alternateBackground = QColor( 238, 246, 255 );
49 m_columnSeparator = QPen( QColor( 150, 160, 170 ), 0, DotLine ); 54 m_columnSeparator = QPen( QColor( 150, 160, 170 ), 0, DotLine );
50 m_fullWidth = true; 55 m_fullWidth = true;
51 connect( this, SIGNAL(expanded(QListViewItem*)), SLOT(expand(QListViewItem*))); 56 connect( this, SIGNAL(expanded(QListViewItem*)), SLOT(expand(QListViewItem*)));
52} 57}
53 58
54OListView::~OListView() 59OListView::~OListView()
55{ 60{
56} 61}
57 62
58void OListView::setFullWidth( bool fullWidth ) 63void OListView::setFullWidth( bool fullWidth )
59{ 64{
60 m_fullWidth = m_fullWidth; 65 m_fullWidth = m_fullWidth;
61 #if QT_VERSION > 290 66 #if QT_VERSION > 290
62 header()->setStretchEnabled( fullWidth, columns()-1 ); 67 header()->setStretchEnabled( fullWidth, columns()-1 );
63 #endif 68 #endif
64} 69}
65 70
66bool OListView::fullWidth() const 71bool OListView::fullWidth() const
67{ 72{
68 return m_fullWidth; 73 return m_fullWidth;
69} 74}
70 75
71int OListView::addColumn( const QString& label, int width ) 76int OListView::addColumn( const QString& label, int width )
72{ 77{
73 int result = QListView::addColumn( label, width ); 78 int result = QListView::addColumn( label, width );
74 #if QT_VERSION > 290 79 #if QT_VERSION > 290
75 if (m_fullWidth) { 80 if (m_fullWidth) {
76 header()->setStretchEnabled( false, columns()-2 ); 81 header()->setStretchEnabled( false, columns()-2 );
77 header()->setStretchEnabled( true, columns()-1 ); 82 header()->setStretchEnabled( true, columns()-1 );
78 } 83 }
79 #endif 84 #endif
80 return result; 85 return result;
81} 86}
82 87
83int OListView::addColumn( const QIconSet& iconset, const QString& label, int width ) 88int OListView::addColumn( const QIconSet& iconset, const QString& label, int width )
84{ 89{
85 int result = QListView::addColumn( iconset, label, width ); 90 int result = QListView::addColumn( iconset, label, width );
86 #if QT_VERSION > 290 91 #if QT_VERSION > 290
@@ -710,48 +715,50 @@ ONamedListViewItem::ONamedListViewItem( QListViewItem* parent, QListViewItem* af
710} 715}
711 716
712 717
713ONamedListViewItem::~ONamedListViewItem() 718ONamedListViewItem::~ONamedListViewItem()
714{ 719{
715} 720}
716 721
717 722
718void ONamedListViewItem::setText( const QStringList& texts ) 723void ONamedListViewItem::setText( const QStringList& texts )
719{ 724{
720 int col = 0; 725 int col = 0;
721 for ( QStringList::ConstIterator it = texts.begin(); it != texts.end(); ++it ) 726 for ( QStringList::ConstIterator it = texts.begin(); it != texts.end(); ++it )
722 { 727 {
723 qDebug( "setting column %d = text %s", col, (const char*) *it ); 728 qDebug( "setting column %d = text %s", col, (const char*) *it );
724 OListViewItem::setText( col++, *it ); 729 OListViewItem::setText( col++, *it );
725 } 730 }
726 731
727} 732}
728 733
729 734
730void ONamedListViewItem::setText( const QString& column, const QString& text ) 735void ONamedListViewItem::setText( const QString& column, const QString& text )
731{ 736{
732 //FIXME: If used excessively, this will slow down performance of updates 737 //FIXME: If used excessively, this will slow down performance of updates
733 //FIXME: because of the linear search over all column texts. 738 //FIXME: because of the linear search over all column texts.
734 //FIXME: I will optimize later by using a hash map. 739 //FIXME: I will optimize later by using a hash map.
735 int col = ( (ONamedListView*) listView() )->findColumn( column ); 740 int col = ( (ONamedListView*) listView() )->findColumn( column );
736 if ( col != -1 ) 741 if ( col != -1 )
737 OListViewItem::setText( col, text ); 742 OListViewItem::setText( col, text );
738 else 743 else
739 qWarning( "ONamedListViewItem::setText(): Warning! Columntext '%s' not found.", (const char*) column ); 744 qWarning( "ONamedListViewItem::setText(): Warning! Columntext '%s' not found.", (const char*) column );
740} 745}
741 746
742 747
743ONamedListViewItem* ONamedListViewItem::find( int column, const QString& text, int recurse ) const 748ONamedListViewItem* ONamedListViewItem::find( int column, const QString& text, int recurse ) const
744{ 749{
745 return ( (ONamedListView*) listView() )->find( (ONamedListViewItem*) firstChild(), column, text, recurse ); 750 return ( (ONamedListView*) listView() )->find( (ONamedListViewItem*) firstChild(), column, text, recurse );
746} 751}
747 752
748 753
749ONamedListViewItem* ONamedListViewItem::find( const QString& column, const QString& text, int recurse ) const 754ONamedListViewItem* ONamedListViewItem::find( const QString& column, const QString& text, int recurse ) const
750{ 755{
751 int col = ( (ONamedListView*) listView() )->findColumn( column ); 756 int col = ( (ONamedListView*) listView() )->findColumn( column );
752 if ( col != -1 ) 757 if ( col != -1 )
753 return ( (ONamedListView*) listView() )->find( (ONamedListViewItem*) firstChild(), col, text, recurse ); 758 return ( (ONamedListView*) listView() )->find( (ONamedListViewItem*) firstChild(), col, text, recurse );
754 else 759 else
755 return 0; 760 return 0;
756} 761}
757 762
763}
764}
diff --git a/libopie2/opieui/olistview.h b/libopie2/opieui/olistview.h
index 59b0973..8195a62 100644
--- a/libopie2/opieui/olistview.h
+++ b/libopie2/opieui/olistview.h
@@ -1,191 +1,197 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3 =. (C) 2003-2004 Michael 'Mickey' Lauer <mickey@vanille.de> 3 =. (C) 2003-2004 Michael 'Mickey' Lauer <mickey@vanille.de>
4 .=l. 4 .=l.
5           .>+-= 5           .>+-=
6 _;:,     .>    :=|. This program is free software; you can 6 _;:,     .>    :=|. This program is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under 7.> <`_,   >  .   <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 8:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
9.="- .-=="i,     .._ License as published by the Free Software 9.="- .-=="i,     .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; either version 2 of the License, 10 - .   .-<_>     .<> Foundation; either version 2 of the License,
11     ._= =}       : or (at your option) any later version. 11     ._= =}       : or (at your option) any later version.
12    .%`+i>       _;_. 12    .%`+i>       _;_.
13    .i_,=:_.      -<s. This program is distributed in the hope that 13    .i_,=:_.      -<s. This program is distributed in the hope that
14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15    : ..    .:,     . . . without even the implied warranty of 15    : ..    .:,     . . . without even the implied warranty of
16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
18..}^=.=       =       ; Library General Public License for more 18..}^=.=       =       ; Library General Public License for more
19++=   -.     .`     .: details. 19++=   -.     .`     .: details.
20 :     =  ...= . :.=- 20 :     =  ...= . :.=-
21 -.   .:....=;==+<; You should have received a copy of the GNU 21 -.   .:....=;==+<; You should have received a copy of the GNU
22  -_. . .   )=.  = Library General Public License along with 22  -_. . .   )=.  = Library General Public License along with
23    --        :-=` this library; see the file COPYING.LIB. 23    --        :-=` this library; see the file COPYING.LIB.
24 If not, write to the Free Software Foundation, 24 If not, write to the Free Software Foundation,
25 Inc., 59 Temple Place - Suite 330, 25 Inc., 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA. 26 Boston, MA 02111-1307, USA.
27 27
28*/ 28*/
29 29
30#ifndef OLISTVIEW_H 30#ifndef OLISTVIEW_H
31#define OLISTVIEW_H 31#define OLISTVIEW_H
32 32
33#include <qcolor.h> 33#include <qcolor.h>
34#include <qlistview.h> 34#include <qlistview.h>
35#include <qpen.h> 35#include <qpen.h>
36#include <qdatastream.h> 36#include <qdatastream.h>
37#include <qstringlist.h> 37#include <qstringlist.h>
38 38
39
40namespace Opie {
41namespace Ui {
39class OListViewItem; 42class OListViewItem;
40 43
41 44
42/*====================================================================================== 45/*======================================================================================
43 * OListView 46 * OListView
44 *======================================================================================*/ 47 *======================================================================================*/
45 48
46/** 49/**
47 * @brief A list/tree widget. 50 * @brief A list/tree widget.
48 * 51 *
49 * A @ref QListView variant featuring visual and functional enhancements 52 * A @ref QListView variant featuring visual and functional enhancements
50 * like an alternate background for odd rows, an autostretch mode 53 * like an alternate background for odd rows, an autostretch mode
51 * for the width of the widget ( >= Qt 3 only ) and persistence capabilities. 54 * for the width of the widget ( >= Qt 3 only ) and persistence capabilities.
52 * 55 *
53 * @author Michael 'Mickey' Lauer <mickey@vanille.de> 56 * @author Michael 'Mickey' Lauer <mickey@vanille.de>
54 */ 57 */
55class OListView: public QListView 58class OListView: public QListView
56{ 59{
60 Q_OBJECT
57 public: 61 public:
58 /** 62 /**
59 * Constructor. 63 * Constructor.
60 * 64 *
61 * The parameters @a parent and @a name are handled by 65 * The parameters @a parent and @a name are handled by
62 * @ref QListView, as usual. 66 * @ref QListView, as usual.
63 */ 67 */
64 OListView( QWidget* parent = 0, const char* name = 0 ); 68 OListView( QWidget* parent = 0, const char* name = 0 );
65 /** 69 /**
66 * Destructor. 70 * Destructor.
67 */ 71 */
68 virtual ~OListView(); 72 virtual ~OListView();
69 /** 73 /**
70 * Let the last column fit exactly all the available width. 74 * Let the last column fit exactly all the available width.
71 */ 75 */
72 void setFullWidth( bool fullWidth ); 76 void setFullWidth( bool fullWidth );
73 /** 77 /**
74 * Returns whether the last column is set to fit the available width. 78 * Returns whether the last column is set to fit the available width.
75 */ 79 */
76 bool fullWidth() const; 80 bool fullWidth() const;
77 /** 81 /**
78 * Reimplemented for full width support 82 * Reimplemented for full width support
79 */ 83 */
80 virtual int addColumn( const QString& label, int width = -1 ); 84 virtual int addColumn( const QString& label, int width = -1 );
81 /** 85 /**
82 * Reimplemented for full width support 86 * Reimplemented for full width support
83 */ 87 */
84 virtual int addColumn( const QIconSet& iconset, const QString& label, int width = -1 ); 88 virtual int addColumn( const QIconSet& iconset, const QString& label, int width = -1 );
85 /** 89 /**
86 * Reimplemented for full width support 90 * Reimplemented for full width support
87 */ 91 */
88 virtual void removeColumn(int index); 92 virtual void removeColumn(int index);
89 /** 93 /**
90 * Set the alternate background background @a color. 94 * Set the alternate background background @a color.
91 * Set to an invalid color to disable alternate colors. 95 * Set to an invalid color to disable alternate colors.
92 * This only has an effect if the items are OListViewItems 96 * This only has an effect if the items are OListViewItems
93 */ 97 */
94 void setAlternateBackground( const QColor& color ); 98 void setAlternateBackground( const QColor& color );
95 /** 99 /**
96 * Sets the column separator @a pen. 100 * Sets the column separator @a pen.
97 */ 101 */
98 void setColumnSeparator( const QPen& pen ); 102 void setColumnSeparator( const QPen& pen );
99 103
100 /** 104 /**
101 * @returns the alternate background color 105 * @returns the alternate background color
102 */ 106 */
103 const QColor& alternateBackground() const; 107 const QColor& alternateBackground() const;
104 /** 108 /**
105 * @return the column separator pen 109 * @return the column separator pen
106 */ 110 */
107 const QPen& columnSeparator() const; 111 const QPen& columnSeparator() const;
108 /** 112 /**
109 * Create a list view item as child of this object 113 * Create a list view item as child of this object
110 * @returns the new object 114 * @returns the new object
111 */ 115 */
112 virtual OListViewItem* childFactory(); 116 virtual OListViewItem* childFactory();
113#ifndef QT_NO_DATASTREAM 117#ifndef QT_NO_DATASTREAM
114 /** 118 /**
115 * Serialize this object to @ref QDataStream @a stream 119 * Serialize this object to @ref QDataStream @a stream
116 */ 120 */
117 virtual void serializeTo( QDataStream& stream ) const; 121 virtual void serializeTo( QDataStream& stream ) const;
118 /** 122 /**
119 * Serialize this object from a @ref QDataStream @a stream 123 * Serialize this object from a @ref QDataStream @a stream
120 */ 124 */
121 virtual void serializeFrom( QDataStream& s ); 125 virtual void serializeFrom( QDataStream& s );
122#endif 126#endif
123 127
124 public slots: 128 public slots:
125 /** 129 /**
126 * Expand all items 130 * Expand all items
127 */ 131 */
128 void expand(); 132 void expand();
129 /** 133 /**
130 * Collapse all items 134 * Collapse all items
131 */ 135 */
132 void collapse(); 136 void collapse();
133 137
134 protected slots: 138 protected slots:
135 /** 139 /**
136 * expand the current OListViewItem 140 * expand the current OListViewItem
137 */ 141 */
138 void expand(QListViewItem*); 142 void expand(QListViewItem*);
139 143
140 private: 144 private:
141 QColor m_alternateBackground; 145 QColor m_alternateBackground;
142 bool m_fullWidth; 146 bool m_fullWidth : 1;
143 QPen m_columnSeparator; 147 QPen m_columnSeparator;
148 class Private;
149 Private *d;
144}; 150};
145 151
146#ifndef QT_NO_DATASTREAM 152#ifndef QT_NO_DATASTREAM
147/** 153/**
148 * @relates OListView 154 * @relates OListView
149 * Writes @a listview to the @a stream and returns a reference to the stream. 155 * Writes @a listview to the @a stream and returns a reference to the stream.
150 */ 156 */
151QDataStream& operator<<( QDataStream& stream, const OListView& listview ); 157QDataStream& operator<<( QDataStream& stream, const OListView& listview );
152/** 158/**
153 * @relates OListView 159 * @relates OListView
154 * Reads @a listview from the @a stream and returns a reference to the stream. 160 * Reads @a listview from the @a stream and returns a reference to the stream.
155 */ 161 */
156QDataStream& operator>>( QDataStream& stream, OListView& listview ); 162QDataStream& operator>>( QDataStream& stream, OListView& listview );
157#endif // QT_NO_DATASTREAM 163#endif // QT_NO_DATASTREAM
158 164
159/*====================================================================================== 165/*======================================================================================
160 * OListViewItem 166 * OListViewItem
161 *======================================================================================*/ 167 *======================================================================================*/
162 168
163class OListViewItem: public QListViewItem 169class OListViewItem: public QListViewItem
164{ 170{
165 friend class OCheckListItem; 171 friend class OCheckListItem;
166 public: 172 public:
167 /** 173 /**
168 * Constructors. 174 * Constructors.
169 */ 175 */
170 OListViewItem( QListView * parent ); 176 OListViewItem( QListView * parent );
171 OListViewItem( QListViewItem * parent ); 177 OListViewItem( QListViewItem * parent );
172 OListViewItem( QListView * parent, QListViewItem * after ); 178 OListViewItem( QListView * parent, QListViewItem * after );
173 OListViewItem( QListViewItem * parent, QListViewItem * after ); 179 OListViewItem( QListViewItem * parent, QListViewItem * after );
174 180
175 OListViewItem( QListView * parent, 181 OListViewItem( QListView * parent,
176 QString, QString = QString::null, 182 QString, QString = QString::null,
177 QString = QString::null, QString = QString::null, 183 QString = QString::null, QString = QString::null,
178 QString = QString::null, QString = QString::null, 184 QString = QString::null, QString = QString::null,
179 QString = QString::null, QString = QString::null ); 185 QString = QString::null, QString = QString::null );
180 186
181 OListViewItem( QListViewItem * parent, 187 OListViewItem( QListViewItem * parent,
182 QString, QString = QString::null, 188 QString, QString = QString::null,
183 QString = QString::null, QString = QString::null, 189 QString = QString::null, QString = QString::null,
184 QString = QString::null, QString = QString::null, 190 QString = QString::null, QString = QString::null,
185 QString = QString::null, QString = QString::null ); 191 QString = QString::null, QString = QString::null );
186 192
187 OListViewItem( QListView * parent, QListViewItem * after, 193 OListViewItem( QListView * parent, QListViewItem * after,
188 QString, QString = QString::null, 194 QString, QString = QString::null,
189 QString = QString::null, QString = QString::null, 195 QString = QString::null, QString = QString::null,
190 QString = QString::null, QString = QString::null, 196 QString = QString::null, QString = QString::null,
191 QString = QString::null, QString = QString::null ); 197 QString = QString::null, QString = QString::null );
@@ -197,98 +203,100 @@ class OListViewItem: public QListViewItem
197 QString = QString::null, QString = QString::null ); 203 QString = QString::null, QString = QString::null );
198 /** 204 /**
199 * Destructor. 205 * Destructor.
200 */ 206 */
201 virtual ~OListViewItem(); 207 virtual ~OListViewItem();
202 /** 208 /**
203 * @returns the background color of the list item. 209 * @returns the background color of the list item.
204 */ 210 */
205 const QColor& backgroundColor(); 211 const QColor& backgroundColor();
206 /** 212 /**
207 * @returns true, if the item is at an odd position and 213 * @returns true, if the item is at an odd position and
208 * thus have to be painted with the alternate background color. 214 * thus have to be painted with the alternate background color.
209 */ 215 */
210 bool isAlternate(); 216 bool isAlternate();
211 /** 217 /**
212 * @note: Reimplemented for internal purposes - the API is not affected 218 * @note: Reimplemented for internal purposes - the API is not affected
213 * 219 *
214 */ 220 */
215 void paintCell( QPainter *p, const QColorGroup &cg, int column, int width, int alignment ); 221 void paintCell( QPainter *p, const QColorGroup &cg, int column, int width, int alignment );
216 /** 222 /**
217 * Perform object initialization. 223 * Perform object initialization.
218 */ 224 */
219 void init(); 225 void init();
220 /** 226 /**
221 * create a list view item as child of this object 227 * create a list view item as child of this object
222 * @returns the new object 228 * @returns the new object
223 */ 229 */
224 virtual OListViewItem* childFactory(); 230 virtual OListViewItem* childFactory();
225 #ifndef QT_NO_DATASTREAM 231 #ifndef QT_NO_DATASTREAM
226 /** 232 /**
227 * serialize this object to or from a @ref QDataStream 233 * serialize this object to or from a @ref QDataStream
228 * @param s the stream used to serialize this object. 234 * @param s the stream used to serialize this object.
229 */ 235 */
230 virtual void serializeTo( QDataStream& s ) const; 236 virtual void serializeTo( QDataStream& s ) const;
231 237
232 /** 238 /**
233 * serialize this object to or from a @ref QDataStream 239 * serialize this object to or from a @ref QDataStream
234 * @param s the stream used to serialize this object. 240 * @param s the stream used to serialize this object.
235 */ 241 */
236 virtual void serializeFrom( QDataStream& s ); 242 virtual void serializeFrom( QDataStream& s );
237 #endif 243 #endif
238 244
239 /** 245 /**
240 * expand the the item 246 * expand the the item
241 */ 247 */
242 virtual void expand(){}; 248 virtual void expand(){};
243 249
244 private: 250 private:
245 bool m_known; 251 bool m_known : 1;
246 bool m_odd; 252 bool m_odd : 1;
253 class Private;
254 Private *d;
247}; 255};
248 256
249#ifndef QT_NO_DATASTREAM 257#ifndef QT_NO_DATASTREAM
250/** 258/**
251 * @relates QListViewItem 259 * @relates QListViewItem
252 * Writes listview @a item and all subitems recursively to @a stream 260 * Writes listview @a item and all subitems recursively to @a stream
253 * and returns a reference to the stream. 261 * and returns a reference to the stream.
254 */ 262 */
255QDataStream& operator<<( QDataStream& stream, const OListViewItem& item ); 263QDataStream& operator<<( QDataStream& stream, const OListViewItem& item );
256/** 264/**
257 * @relates QListViewItem 265 * @relates QListViewItem
258 * Reads listview @a item from @a stream and returns a reference to the stream. 266 * Reads listview @a item from @a stream and returns a reference to the stream.
259 */ 267 */
260QDataStream& operator>>( QDataStream& stream, OListViewItem& item ); 268QDataStream& operator>>( QDataStream& stream, OListViewItem& item );
261#endif // QT_NO_DATASTREAM 269#endif // QT_NO_DATASTREAM
262 270
263 271
264/*====================================================================================== 272/*======================================================================================
265 * OCheckListItem 273 * OCheckListItem
266 *======================================================================================*/ 274 *======================================================================================*/
267 275
268class OCheckListItem : public QCheckListItem 276class OCheckListItem : public QCheckListItem
269{ 277{
270 public: 278 public:
271 279
272 OCheckListItem( QCheckListItem *parent, const QString &text, 280 OCheckListItem( QCheckListItem *parent, const QString &text,
273 Type = Controller ); 281 Type = Controller );
274 OCheckListItem( QListViewItem *parent, const QString &text, 282 OCheckListItem( QListViewItem *parent, const QString &text,
275 Type = Controller ); 283 Type = Controller );
276 OCheckListItem( QListView *parent, const QString &text, 284 OCheckListItem( QListView *parent, const QString &text,
277 Type = Controller ); 285 Type = Controller );
278 OCheckListItem( QListViewItem *parent, const QString &text, 286 OCheckListItem( QListViewItem *parent, const QString &text,
279 const QPixmap & ); 287 const QPixmap & );
280 OCheckListItem( QListView *parent, const QString &text, 288 OCheckListItem( QListView *parent, const QString &text,
281 const QPixmap & ); 289 const QPixmap & );
282 ~OCheckListItem(); 290 ~OCheckListItem();
283 /** 291 /**
284 * @returns the background color of the list item. 292 * @returns the background color of the list item.
285 */ 293 */
286 const QColor& backgroundColor(); 294 const QColor& backgroundColor();
287 /** 295 /**
288 * @returns true, if the item is at an odd position and 296 * @returns true, if the item is at an odd position and
289 * thus have to be painted with the alternate background color. 297 * thus have to be painted with the alternate background color.
290 */ 298 */
291 bool isAlternate(); 299 bool isAlternate();
292 /** 300 /**
293 * @note: Reimplemented for internal purposes - the API is not affected 301 * @note: Reimplemented for internal purposes - the API is not affected
294 * 302 *
@@ -309,101 +317,110 @@ class OCheckListItem : public QCheckListItem
309 * ONamedListView 317 * ONamedListView
310 *======================================================================================*/ 318 *======================================================================================*/
311 319
312class ONamedListViewItem; 320class ONamedListViewItem;
313 321
314/** 322/**
315 * @brief An OListView variant with named columns. 323 * @brief An OListView variant with named columns.
316 * 324 *
317 * This class provides a higher-level interface to an OListView. 325 * This class provides a higher-level interface to an OListView.
318 * 326 *
319 * @author Michael 'Mickey' Lauer <mickey@vanille.de> 327 * @author Michael 'Mickey' Lauer <mickey@vanille.de>
320 */ 328 */
321class ONamedListView: public OListView 329class ONamedListView: public OListView
322{ 330{
323 public: 331 public:
324 /** 332 /**
325 * Constructor. 333 * Constructor.
326 * 334 *
327 * The parameters @a parent and @a name are handled by 335 * The parameters @a parent and @a name are handled by
328 * @ref OListView, as usual. 336 * @ref OListView, as usual.
329 */ 337 */
330 ONamedListView( QWidget* parent = 0, const char* name = 0 ); 338 ONamedListView( QWidget* parent = 0, const char* name = 0 );
331 /** 339 /**
332 * Destructor. 340 * Destructor.
333 */ 341 */
334 virtual ~ONamedListView(); 342 virtual ~ONamedListView();
335 /** 343 /**
336 * Add a number of @a columns to the listview. 344 * Add a number of @a columns to the listview.
337 */ 345 */
338 virtual void addColumns( const QStringList& columns ); 346 virtual void addColumns( const QStringList& columns );
339 /** 347 /**
340 * @returns the column index matching to @a text or -1 if not found. 348 * @returns the column index matching to @a text or -1 if not found.
341 */ 349 */
342 virtual int findColumn( const QString& text ) const; 350 virtual int findColumn( const QString& text ) const;
343 /** 351 /**
344 * @returns the first item which has a @a text in column @a column. 352 * @returns the first item which has a @a text in column @a column.
345 * Set @a recurse to indicate how much subchild levels to search, e.g.<ul> 353 * Set @a recurse to indicate how much subchild levels to search, e.g.<ul>
346 * <li>set it to 0 to search only among direct childs, 354 * <li>set it to 0 to search only among direct childs,
347 * <li>set it to 1 to search direct childs and all 1st order subchilds 355 * <li>set it to 1 to search direct childs and all 1st order subchilds
348 * <li>set it to -1 for maximum recursion. 356 * <li>set it to -1 for maximum recursion.
349 * </ul> 357 * </ul>
350 * @sa ONamedListViewItem::find() 358 * @sa ONamedListViewItem::find()
351 */ 359 */
352 virtual ONamedListViewItem* find( ONamedListViewItem* start, int column, const QString& text, int recurse = -1 ) const; 360 virtual ONamedListViewItem* find( ONamedListViewItem* start, int column, const QString& text, int recurse = -1 ) const;
353 virtual ONamedListViewItem* find( int column, const QString& text, int recurse = -1 ) const; 361 virtual ONamedListViewItem* find( int column, const QString& text, int recurse = -1 ) const;
354 362
355 virtual ONamedListViewItem* find( ONamedListViewItem* start, const QString& column, const QString& text, int recurse = -1 ) const; 363 virtual ONamedListViewItem* find( ONamedListViewItem* start, const QString& column, const QString& text, int recurse = -1 ) const;
356 virtual ONamedListViewItem* find( const QString& column, const QString& text, int recurse = -1 ) const; 364 virtual ONamedListViewItem* find( const QString& column, const QString& text, int recurse = -1 ) const;
365 private:
366 class Private;
367 Private *d;
357}; 368};
358 369
359/*====================================================================================== 370/*======================================================================================
360 * ONamedListViewItem 371 * ONamedListViewItem
361 *======================================================================================*/ 372 *======================================================================================*/
362 373
363/** 374/**
364 * @brief An OListView variant with named columns. 375 * @brief An OListView variant with named columns.
365 * 376 *
366 * This class provides a higher-level interface to an OListViewItem. 377 * This class provides a higher-level interface to an OListViewItem.
367 * 378 *
368 * @author Michael 'Mickey' Lauer <mickey@vanille.de> 379 * @author Michael 'Mickey' Lauer <mickey@vanille.de>
369 */ 380 */
370class ONamedListViewItem: public OListViewItem 381class ONamedListViewItem: public OListViewItem
371{ 382{
372 public: 383 public:
373 /** 384 /**
374 * Constructor. Accepts the same parameters as a @ref OListViewItem, 385 * Constructor. Accepts the same parameters as a @ref OListViewItem,
375 * plus a @ref QStringList which holds an arbitrary number of @a texts. 386 * plus a @ref QStringList which holds an arbitrary number of @a texts.
376 */ 387 */
377 ONamedListViewItem( QListView* parent, const QStringList& texts ); 388 ONamedListViewItem( QListView* parent, const QStringList& texts );
378 ONamedListViewItem( QListViewItem* parent, const QStringList& texts ); 389 ONamedListViewItem( QListViewItem* parent, const QStringList& texts );
379 ONamedListViewItem( QListView* parent, QListViewItem* after, const QStringList& texts ); 390 ONamedListViewItem( QListView* parent, QListViewItem* after, const QStringList& texts );
380 ONamedListViewItem( QListViewItem* parent, QListViewItem* after, const QStringList& texts ); 391 ONamedListViewItem( QListViewItem* parent, QListViewItem* after, const QStringList& texts );
381 /** 392 /**
382 * Destructor. 393 * Destructor.
383 */ 394 */
384 virtual ~ONamedListViewItem(); 395 virtual ~ONamedListViewItem();
385 /** 396 /**
386 * Sets the text in column @a column to @a text. 397 * Sets the text in column @a column to @a text.
387 * This method differs from @ref QListViewItem::setText() in that it 398 * This method differs from @ref QListViewItem::setText() in that it
388 * accepts a string as column indicator instead of an int. 399 * accepts a string as column indicator instead of an int.
389 */ 400 */
390 virtual void setText( const QString& column, const QString& text ); 401 virtual void setText( const QString& column, const QString& text );
391 /** 402 /**
392 * Sets a number of @a texts for this item. 403 * Sets a number of @a texts for this item.
393 */ 404 */
394 virtual void setText( const QStringList& texts ); 405 virtual void setText( const QStringList& texts );
395 /** 406 /**
396 * @returns the first child which has a @a text in column @a column. 407 * @returns the first child which has a @a text in column @a column.
397 * Set @a recurse to indicate how much subchild levels to search, e.g.<ul> 408 * Set @a recurse to indicate how much subchild levels to search, e.g.<ul>
398 * <li>set it to 0 to search only among direct childs, 409 * <li>set it to 0 to search only among direct childs,
399 * <li>set it to 1 to search direct childs and all 1st order subchilds 410 * <li>set it to 1 to search direct childs and all 1st order subchilds
400 * <li>set it to -1 for maximum recursion. 411 * <li>set it to -1 for maximum recursion.
401 * </ul> 412 * </ul>
402 * @sa ONamedListView::find() 413 * @sa ONamedListView::find()
403 */ 414 */
404 virtual ONamedListViewItem* find( int column, const QString& text, int recurse = -1 ) const; 415 virtual ONamedListViewItem* find( int column, const QString& text, int recurse = -1 ) const;
405 virtual ONamedListViewItem* find( const QString& column, const QString& text, int recurse = -1 ) const; 416 virtual ONamedListViewItem* find( const QString& column, const QString& text, int recurse = -1 ) const;
406};
407 417
418 private:
419 class Private;
420 Private *d;
421
422};
423}
424}
408 425
409#endif // OLISTVIEW_H 426#endif // OLISTVIEW_H
diff --git a/libopie2/opieui/opieui.pro b/libopie2/opieui/opieui.pro
index 1be8db5..e895edc 100644
--- a/libopie2/opieui/opieui.pro
+++ b/libopie2/opieui/opieui.pro
@@ -1,66 +1,63 @@
1TEMPLATE = lib 1TEMPLATE = lib
2CONFIG += qt warn_on debug 2CONFIG += qt warn_on debug
3DESTDIR = $(OPIEDIR)/lib 3DESTDIR = $(OPIEDIR)/lib
4HEADERS = oclickablelabel.h \ 4HEADERS = oclickablelabel.h \
5 odialog.h \ 5 odialog.h \
6 ofontselector.h \ 6 ofontselector.h \
7 oimageeffect.h \ 7 oimageeffect.h \
8 olistview.h \ 8 olistview.h \
9 omessagebox.h \
10 opixmapeffect.h \ 9 opixmapeffect.h \
11 opopupmenu.h \ 10 opopupmenu.h \
12 opixmapprovider.h \ 11 opixmapprovider.h \
13 oresource.h \
14 oselector.h \ 12 oselector.h \
15 oseparator.h \ 13 oseparator.h \
16 otabinfo.h \ 14 otabinfo.h \
17 otabbar.h \ 15 otabbar.h \
18 otabwidget.h \ 16 otabwidget.h \
19 otaskbarapplet.h \ 17 otaskbarapplet.h \
20 oticker.h \ 18 oticker.h \
21 otimepicker.h \ 19 otimepicker.h \
22 oversatileview.h \ 20 oversatileview.h \
23 oversatileviewitem.h \ 21 oversatileviewitem.h \
24 owait.h 22 owait.h
25 23
26SOURCES = oclickablelabel.cpp \ 24SOURCES = oclickablelabel.cpp \
27 odialog.cpp \ 25 odialog.cpp \
28 ofontselector.cpp \ 26 ofontselector.cpp \
29 oimageeffect.cpp \ 27 oimageeffect.cpp \
30 olistview.cpp \ 28 olistview.cpp \
31 opixmapeffect.cpp \ 29 opixmapeffect.cpp \
32 opopupmenu.cpp \ 30 opopupmenu.cpp \
33 opixmapprovider.cpp \ 31 opixmapprovider.cpp \
34 oresource.cpp \
35 oselector.cpp \ 32 oselector.cpp \
36 oseparator.cpp \ 33 oseparator.cpp \
37 otabbar.cpp \ 34 otabbar.cpp \
38 otabwidget.cpp \ 35 otabwidget.cpp \
39 otaskbarapplet.cpp \ 36 otaskbarapplet.cpp \
40 oticker.cpp \ 37 oticker.cpp \
41 otimepicker.cpp \ 38 otimepicker.cpp \
42 oversatileview.cpp \ 39 oversatileview.cpp \
43 oversatileviewitem.cpp \ 40 oversatileviewitem.cpp \
44 owait.cpp 41 owait.cpp
45 42
46include ( big-screen/big-screen.pro ) 43include ( big-screen/big-screen.pro )
47include ( fileselector/fileselector.pro ) 44include ( fileselector/fileselector.pro )
48 45
49INTERFACES = otimepickerbase.ui 46INTERFACES = otimepickerbase.ui
50 47
51TARGET = opieui2 48TARGET = opieui2
52VERSION = 1.8.5 49VERSION = 1.8.5
53 50
54INCLUDEPATH += $(OPIEDIR)/include 51INCLUDEPATH += $(OPIEDIR)/include
55DEPENDPATH += $(OPIEDIR)/include 52DEPENDPATH += $(OPIEDIR)/include
56 53
57LIBS += -lopiecore2 54LIBS += -lopiecore2
58 55
59!contains( platform, x11 ) { 56!contains( platform, x11 ) {
60 include ( $(OPIEDIR)/include.pro ) 57 include ( $(OPIEDIR)/include.pro )
61} 58}
62 59
63contains( platform, x11 ) { 60contains( platform, x11 ) {
64 LIBS += -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib 61 LIBS += -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib
65} 62}
66 63
diff --git a/libopie2/opieui/opixmapeffect.cpp b/libopie2/opieui/opixmapeffect.cpp
index 05f851d..794c7b2 100644
--- a/libopie2/opieui/opixmapeffect.cpp
+++ b/libopie2/opieui/opixmapeffect.cpp
@@ -1,67 +1,69 @@
1/* This file is part of the KDE libraries 1/* This file is part of the KDE libraries
2 Copyright (C) 1998, 1999 Christian Tibirna <ctibirna@total.net> 2 Copyright (C) 1998, 1999 Christian Tibirna <ctibirna@total.net>
3 (C) 1998, 1999 Daniel M. Duley <mosfet@kde.org> 3 (C) 1998, 1999 Daniel M. Duley <mosfet@kde.org>
4 (C) 1998, 1999 Dirk A. Mueller <mueller@kde.org> 4 (C) 1998, 1999 Dirk A. Mueller <mueller@kde.org>
5 5
6*/ 6*/
7 7
8// $Id$ 8// $Id$
9 9
10/* QT */ 10/* QT */
11 11
12#include <qimage.h> 12#include <qimage.h>
13#include <qpainter.h> 13#include <qpainter.h>
14 14
15/* OPIE */ 15/* OPIE */
16 16
17#include <opie2/opixmapeffect.h> 17#include <opie2/opixmapeffect.h>
18#include <opie2/oimageeffect.h> 18#include <opie2/oimageeffect.h>
19 19
20
21using namespace Opie::Ui;
20//====================================================================== 22//======================================================================
21// 23//
22// Gradient effects 24// Gradient effects
23// 25//
24//====================================================================== 26//======================================================================
25 27
26 28
27OPixmap& OPixmapEffect::gradient(OPixmap &pixmap, const QColor &ca, 29OPixmap& OPixmapEffect::gradient(OPixmap &pixmap, const QColor &ca,
28 const QColor &cb, GradientType eff, int ncols) 30 const QColor &cb, GradientType eff, int ncols)
29{ 31{
30 if(pixmap.depth() > 8 && 32 if(pixmap.depth() > 8 &&
31 (eff == VerticalGradient || eff == HorizontalGradient)) { 33 (eff == VerticalGradient || eff == HorizontalGradient)) {
32 34
33 int rDiff, gDiff, bDiff; 35 int rDiff, gDiff, bDiff;
34 int rca, gca, bca /*, rcb, gcb, bcb*/; 36 int rca, gca, bca /*, rcb, gcb, bcb*/;
35 37
36 register int x, y; 38 register int x, y;
37 39
38 rDiff = (/*rcb = */ cb.red()) - (rca = ca.red()); 40 rDiff = (/*rcb = */ cb.red()) - (rca = ca.red());
39 gDiff = (/*gcb = */ cb.green()) - (gca = ca.green()); 41 gDiff = (/*gcb = */ cb.green()) - (gca = ca.green());
40 bDiff = (/*bcb = */ cb.blue()) - (bca = ca.blue()); 42 bDiff = (/*bcb = */ cb.blue()) - (bca = ca.blue());
41 43
42 register int rl = rca << 16; 44 register int rl = rca << 16;
43 register int gl = gca << 16; 45 register int gl = gca << 16;
44 register int bl = bca << 16; 46 register int bl = bca << 16;
45 47
46 int rcdelta = ((1<<16) / (eff == VerticalGradient ? pixmap.height() : pixmap.width())) * rDiff; 48 int rcdelta = ((1<<16) / (eff == VerticalGradient ? pixmap.height() : pixmap.width())) * rDiff;
47 int gcdelta = ((1<<16) / (eff == VerticalGradient ? pixmap.height() : pixmap.width())) * gDiff; 49 int gcdelta = ((1<<16) / (eff == VerticalGradient ? pixmap.height() : pixmap.width())) * gDiff;
48 int bcdelta = ((1<<16) / (eff == VerticalGradient ? pixmap.height() : pixmap.width())) * bDiff; 50 int bcdelta = ((1<<16) / (eff == VerticalGradient ? pixmap.height() : pixmap.width())) * bDiff;
49 51
50 QPainter p(&pixmap); 52 QPainter p(&pixmap);
51 53
52 // these for-loops could be merged, but the if's in the inner loop 54 // these for-loops could be merged, but the if's in the inner loop
53 // would make it slow 55 // would make it slow
54 switch(eff) { 56 switch(eff) {
55 case VerticalGradient: 57 case VerticalGradient:
56 for ( y = 0; y < pixmap.height(); y++ ) { 58 for ( y = 0; y < pixmap.height(); y++ ) {
57 rl += rcdelta; 59 rl += rcdelta;
58 gl += gcdelta; 60 gl += gcdelta;
59 bl += bcdelta; 61 bl += bcdelta;
60 62
61 p.setPen(QColor(rl>>16, gl>>16, bl>>16)); 63 p.setPen(QColor(rl>>16, gl>>16, bl>>16));
62 p.drawLine(0, y, pixmap.width()-1, y); 64 p.drawLine(0, y, pixmap.width()-1, y);
63 } 65 }
64 break; 66 break;
65 case HorizontalGradient: 67 case HorizontalGradient:
66 for( x = 0; x < pixmap.width(); x++) { 68 for( x = 0; x < pixmap.width(); x++) {
67 rl += rcdelta; 69 rl += rcdelta;
diff --git a/libopie2/opieui/opixmapeffect.h b/libopie2/opieui/opixmapeffect.h
index 283fe2d..b780f9f 100644
--- a/libopie2/opieui/opixmapeffect.h
+++ b/libopie2/opieui/opixmapeffect.h
@@ -1,65 +1,68 @@
1/* This file is part of the KDE libraries 1/* This file is part of the KDE libraries
2 Copyright (C) 1998, 1999 Christian Tibirna <ctibirna@total.net> 2 Copyright (C) 1998, 1999 Christian Tibirna <ctibirna@total.net>
3 (C) 1998, 1999 Daniel M. Duley <mosfet@kde.org> 3 (C) 1998, 1999 Daniel M. Duley <mosfet@kde.org>
4 (C) 1998, 1999 Dirk A. Mueller <mueller@kde.org> 4 (C) 1998, 1999 Dirk A. Mueller <mueller@kde.org>
5 5
6*/ 6*/
7 7
8// $Id$ 8// $Id$
9 9
10#ifndef __OPIXMAP_EFFECT_H 10#ifndef __OPIXMAP_EFFECT_H
11#define __OPIXMAP_EFFECT_H 11#define __OPIXMAP_EFFECT_H
12 12
13 13
14#include <qsize.h> 14#include <qsize.h>
15typedef QPixmap OPixmap; 15typedef QPixmap OPixmap;
16class QColor; 16class QColor;
17 17
18
19namespace Opie {
20namespace Ui {
18/** 21/**
19 * This class includes various pixmap-based graphical effects. 22 * This class includes various pixmap-based graphical effects.
20 * 23 *
21 * Everything is 24 * Everything is
22 * static, so there is no need to create an instance of this class. You can 25 * static, so there is no need to create an instance of this class. You can
23 * just call the static methods. They are encapsulated here merely to provide 26 * just call the static methods. They are encapsulated here merely to provide
24 * a common namespace. 27 * a common namespace.
25 */ 28 */
26class OPixmapEffect 29class OPixmapEffect
27{ 30{
28public: 31public:
29 enum GradientType { VerticalGradient, HorizontalGradient, 32 enum GradientType { VerticalGradient, HorizontalGradient,
30 DiagonalGradient, CrossDiagonalGradient, 33 DiagonalGradient, CrossDiagonalGradient,
31 PyramidGradient, RectangleGradient, 34 PyramidGradient, RectangleGradient,
32 PipeCrossGradient, EllipticGradient }; 35 PipeCrossGradient, EllipticGradient };
33 enum RGBComponent { Red, Green, Blue }; 36 enum RGBComponent { Red, Green, Blue };
34 37
35 enum Lighting {NorthLite, NWLite, WestLite, SWLite, 38 enum Lighting {NorthLite, NWLite, WestLite, SWLite,
36 SouthLite, SELite, EastLite, NELite}; 39 SouthLite, SELite, EastLite, NELite};
37 40
38 /** 41 /**
39 * Creates a gradient from color a to color b of the specified type. 42 * Creates a gradient from color a to color b of the specified type.
40 * 43 *
41 * @param pixmap The pixmap to process. 44 * @param pixmap The pixmap to process.
42 * @param ca Color a. 45 * @param ca Color a.
43 * @param cb Color b. 46 * @param cb Color b.
44 * @param type The type of gradient. 47 * @param type The type of gradient.
45 * @param ncols The number of colors to use when not running on a 48 * @param ncols The number of colors to use when not running on a
46 * truecolor display. The gradient will be dithered to this number of 49 * truecolor display. The gradient will be dithered to this number of
47 * colors. Pass 0 to prevent dithering. 50 * colors. Pass 0 to prevent dithering.
48 * @return Returns the generated pixmap, for convenience. 51 * @return Returns the generated pixmap, for convenience.
49 */ 52 */
50 static OPixmap& gradient(OPixmap& pixmap, const QColor &ca, const QColor &cb, 53 static OPixmap& gradient(OPixmap& pixmap, const QColor &ca, const QColor &cb,
51 GradientType type, int ncols=3); 54 GradientType type, int ncols=3);
52 55
53 /** 56 /**
54 * Creates an unbalanced gradient. 57 * Creates an unbalanced gradient.
55 * 58 *
56 * An unbalanced gradient is a gradient where the transition from 59 * An unbalanced gradient is a gradient where the transition from
57 * color a to color b is not linear, but in this case, exponential. 60 * color a to color b is not linear, but in this case, exponential.
58 * 61 *
59 * @param pixmap The pixmap that should be written. 62 * @param pixmap The pixmap that should be written.
60 * @param ca Color a. 63 * @param ca Color a.
61 * @param cb Color b. 64 * @param cb Color b.
62 * @param type The type of gradient. 65 * @param type The type of gradient.
63 * @param xfactor The x decay length. Use a value between -200 and 200. 66 * @param xfactor The x decay length. Use a value between -200 and 200.
64 * @param yfactor The y decay length. 67 * @param yfactor The y decay length.
65 * @param ncols The number of colors. See #gradient. 68 * @param ncols The number of colors. See #gradient.
@@ -165,51 +168,52 @@ public:
165 168
166 /** 169 /**
167 * Converts a pixmap to grayscale. 170 * Converts a pixmap to grayscale.
168 * 171 *
169 * @param pixmap The pixmap to process. 172 * @param pixmap The pixmap to process.
170 * @param fast Set to @p true in order to use a faster but non-photographic 173 * @param fast Set to @p true in order to use a faster but non-photographic
171 * quality algorithm. Appropriate for things such as toolbar icons. 174 * quality algorithm. Appropriate for things such as toolbar icons.
172 * @return Returns the @ref pixmap(), provided for convenience. 175 * @return Returns the @ref pixmap(), provided for convenience.
173 */ 176 */
174 static OPixmap& toGray(OPixmap& pixmap, bool fast=false); 177 static OPixmap& toGray(OPixmap& pixmap, bool fast=false);
175 178
176 /** 179 /**
177 * Desaturates a pixmap. 180 * Desaturates a pixmap.
178 * 181 *
179 * @param pixmap The pixmap to process. 182 * @param pixmap The pixmap to process.
180 * @param desat A value between 0 and 1 setting the degree of desaturation 183 * @param desat A value between 0 and 1 setting the degree of desaturation
181 * @return Returns The @ref pixmap(), provided for convenience. 184 * @return Returns The @ref pixmap(), provided for convenience.
182 */ 185 */
183 static OPixmap& desaturate(OPixmap& pixmap, float desat = 0.3); 186 static OPixmap& desaturate(OPixmap& pixmap, float desat = 0.3);
184 187
185 /** 188 /**
186 * Modifies the contrast of a pixmap. 189 * Modifies the contrast of a pixmap.
187 * 190 *
188 * @param pixmap The pixmap to process. 191 * @param pixmap The pixmap to process.
189 * @param c A contrast value between -255 and 255. 192 * @param c A contrast value between -255 and 255.
190 * @return Returns the @ref pixmap(), provided for convenience. 193 * @return Returns the @ref pixmap(), provided for convenience.
191 */ 194 */
192 static OPixmap& contrast(OPixmap& pixmap, int c); 195 static OPixmap& contrast(OPixmap& pixmap, int c);
193 196
194 /** 197 /**
195 * Dithers a pixmap using Floyd-Steinberg dithering for low-color 198 * Dithers a pixmap using Floyd-Steinberg dithering for low-color
196 * situations. 199 * situations.
197 * 200 *
198 * @param pixmap The pixmap to process. 201 * @param pixmap The pixmap to process.
199 * @param palette The color palette to use. 202 * @param palette The color palette to use.
200 * @param size The size of the palette. 203 * @param size The size of the palette.
201 * @return Returns the @ref pixmap(), provided for convenience. 204 * @return Returns the @ref pixmap(), provided for convenience.
202 */ 205 */
203 static OPixmap& dither(OPixmap &pixmap, const QColor *palette, int size); 206 static OPixmap& dither(OPixmap &pixmap, const QColor *palette, int size);
204 207
205 /** 208 /**
206 * Calculate a 'selected' pixmap, for instance a selected icon 209 * Calculate a 'selected' pixmap, for instance a selected icon
207 * on the desktop. 210 * on the desktop.
208 * @param pixmap the pixmap to select 211 * @param pixmap the pixmap to select
209 * @param col the selected color, usually from QColorGroup::highlight(). 212 * @param col the selected color, usually from QColorGroup::highlight().
210 */ 213 */
211 static OPixmap selectedPixmap( const OPixmap &pixmap, const QColor &col ); 214 static OPixmap selectedPixmap( const OPixmap &pixmap, const QColor &col );
212}; 215};
213 216}
217}
214 218
215#endif 219#endif
diff --git a/libopie2/opieui/opixmapprovider.cpp b/libopie2/opieui/opixmapprovider.cpp
index 7be9e3b..7eb67a2 100644
--- a/libopie2/opieui/opixmapprovider.cpp
+++ b/libopie2/opieui/opixmapprovider.cpp
@@ -1,27 +1,29 @@
1/* This file is part of the KDE libraries 1/* This file is part of the KDE libraries
2 2
3 Copyright (c) 2000 Carsten Pfeiffer <pfeiffer@kde.org> 3 Copyright (c) 2000 Carsten Pfeiffer <pfeiffer@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License (LGPL) as published by the Free Software Foundation; either 7 License (LGPL) as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21#include <opie2/opixmapprovider.h> 21#include <opie2/opixmapprovider.h>
22 22
23using namespace Opie::Ui;
24
23OPixmapProvider::~OPixmapProvider() {} 25OPixmapProvider::~OPixmapProvider() {}
24 26
25void OPixmapProvider::virtual_hook( int , void* ) 27void OPixmapProvider::virtual_hook( int , void* )
26{ /*BASE::virtual_hook( id, data );*/ } 28{ /*BASE::virtual_hook( id, data );*/ }
27 29
diff --git a/libopie2/opieui/opixmapprovider.h b/libopie2/opieui/opixmapprovider.h
index 5b76647..9d9bd69 100644
--- a/libopie2/opieui/opixmapprovider.h
+++ b/libopie2/opieui/opixmapprovider.h
@@ -1,54 +1,62 @@
1/* This file is part of the KDE libraries 1/* This file is part of the KDE libraries
2 2
3 Copyright (c) 2000 Carsten Pfeiffer <pfeiffer@kde.org> 3 Copyright (c) 2000 Carsten Pfeiffer <pfeiffer@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License (LGPL) as published by the Free Software Foundation; either 7 License (LGPL) as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21#ifndef OPIXMAPPROVIDER_H 21#ifndef OPIXMAPPROVIDER_H
22#define OPIXMAPPROVIDER_H 22#define OPIXMAPPROVIDER_H
23 23
24#include <qpixmap.h> 24#include <qpixmap.h>
25 25
26namespace Opie {
27namespace Ui {
26/** 28/**
29 * \todo make usefull
27 * A tiny abstract class with just one method: 30 * A tiny abstract class with just one method:
28 * @ref pixmapFor() 31 * @ref pixmapFor()
29 * 32 *
30 * It will be called whenever an icon is searched for @p text. 33 * It will be called whenever an icon is searched for @p text.
31 * 34 *
32 * Used e.g. by @ref KHistoryCombo 35 * Used e.g. by @ref KHistoryCombo
33 * 36 *
34 * @author Carsten Pfeiffer <pfeiffer@kde.org> 37 * @author Carsten Pfeiffer <pfeiffer@kde.org>
35 * @short an abstract interface for looking up icons 38 * @short an abstract interface for looking up icons
36 */ 39 */
37class OPixmapProvider 40class OPixmapProvider
38{ 41{
39public: 42public:
40 virtual ~OPixmapProvider(); 43 virtual ~OPixmapProvider();
41 /** 44 /**
42 * You may subclass this and return a pixmap of size @p size for @p text. 45 * You may subclass this and return a pixmap of size @p size for @p text.
43 * @param text the text that is associated with the pixmap 46 * @param text the text that is associated with the pixmap
44 * @param size the size of the icon in pixels, 0 for defaylt size. 47 * @param size the size of the icon in pixels, 0 for defaylt size.
45 * See @ref KIcon::StdSize. 48 * See @ref KIcon::StdSize.
46 * @return the pixmap for the arguments, or null if there is none 49 * @return the pixmap for the arguments, or null if there is none
47 */ 50 */
48 virtual QPixmap pixmapFor( const QString& text, int size = 0 ) = 0; 51 virtual QPixmap pixmapFor( const QString& text, int size = 0 ) = 0;
49protected: 52protected:
50 virtual void virtual_hook( int id, void* data ); 53 virtual void virtual_hook( int id, void* data );
54private:
55 class Private;
56 Private *d;
51}; 57};
52 58
59}
60}
53 61
54#endif // OPIXMAPPROVIDER_H 62#endif // OPIXMAPPROVIDER_H
diff --git a/libopie2/opieui/opopupmenu.cpp b/libopie2/opieui/opopupmenu.cpp
index d5cc575..3ab8490 100644
--- a/libopie2/opieui/opopupmenu.cpp
+++ b/libopie2/opieui/opopupmenu.cpp
@@ -1,77 +1,80 @@
1/* This file is part of the KDE libraries 1/* This file is part of the KDE libraries
2 Copyright (C) 2000 Daniel M. Duley <mosfet@kde.org> 2 Copyright (C) 2000 Daniel M. Duley <mosfet@kde.org>
3 Copyright (C) 2002 Hamish Rodda <meddie@yoyo.its.monash.edu.au> 3 Copyright (C) 2002 Hamish Rodda <meddie@yoyo.its.monash.edu.au>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License version 2 as published by the Free Software Foundation. 7 License version 2 as published by the Free Software Foundation.
8 8
9 This library is distributed in the hope that it will be useful, 9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details. 12 Library General Public License for more details.
13 13
14 You should have received a copy of the GNU Library General Public License 14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to 15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA. 17 Boston, MA 02111-1307, USA.
18*/ 18*/
19 19
20/* QT */ 20/* QT */
21 21
22#include <qdrawutil.h> 22#include <qdrawutil.h>
23#include <qtimer.h> 23#include <qtimer.h>
24 24
25/* OPIE */ 25/* OPIE */
26 26
27#include <opie2/opopupmenu.h> 27#include <opie2/opopupmenu.h>
28#include <opie2/oconfig.h> 28#include <opie2/oconfig.h>
29 29
30using namespace Opie::Core;
31using namespace Opie::Ui;
32
30OPopupTitle::OPopupTitle(QWidget *parent, const char *name) 33OPopupTitle::OPopupTitle(QWidget *parent, const char *name)
31 : QWidget(parent, name) 34 : QWidget(parent, name)
32{ 35{
33 setMinimumSize(16, fontMetrics().height()+8); 36 setMinimumSize(16, fontMetrics().height()+8);
34} 37}
35 38
36OPopupTitle::OPopupTitle(OPixmapEffect::GradientType /* gradient */, 39OPopupTitle::OPopupTitle(OPixmapEffect::GradientType /* gradient */,
37 const QColor &/* color */, const QColor &/* textColor */, 40 const QColor &/* color */, const QColor &/* textColor */,
38 QWidget *parent, const char *name) 41 QWidget *parent, const char *name)
39 : QWidget(parent, name) 42 : QWidget(parent, name)
40{ 43{
41 setMinimumSize(16, fontMetrics().height()+8); 44 setMinimumSize(16, fontMetrics().height()+8);
42} 45}
43 46
44OPopupTitle::OPopupTitle(const OPixmap & /* background */, const QColor &/* color */, 47OPopupTitle::OPopupTitle(const OPixmap & /* background */, const QColor &/* color */,
45 const QColor &/* textColor */, QWidget *parent, 48 const QColor &/* textColor */, QWidget *parent,
46 const char *name) 49 const char *name)
47 : QWidget(parent, name) 50 : QWidget(parent, name)
48{ 51{
49 setMinimumSize(16, fontMetrics().height()+8); 52 setMinimumSize(16, fontMetrics().height()+8);
50} 53}
51 54
52void OPopupTitle::setTitle(const QString &text, const QPixmap *icon) 55void OPopupTitle::setTitle(const QString &text, const QPixmap *icon)
53{ 56{
54 titleStr = text; 57 titleStr = text;
55 if (icon) 58 if (icon)
56 miniicon = *icon; 59 miniicon = *icon;
57 else 60 else
58 miniicon.resize(0, 0); 61 miniicon.resize(0, 0);
59 62
60 int w = miniicon.width()+fontMetrics().width(titleStr); 63 int w = miniicon.width()+fontMetrics().width(titleStr);
61 int h = QMAX( fontMetrics().height(), miniicon.height() ); 64 int h = QMAX( fontMetrics().height(), miniicon.height() );
62 setMinimumSize( w+16, h+8 ); 65 setMinimumSize( w+16, h+8 );
63} 66}
64 67
65void OPopupTitle::setText( const QString &text ) 68void OPopupTitle::setText( const QString &text )
66{ 69{
67 titleStr = text; 70 titleStr = text;
68 int w = miniicon.width()+fontMetrics().width(titleStr); 71 int w = miniicon.width()+fontMetrics().width(titleStr);
69 int h = QMAX( fontMetrics().height(), miniicon.height() ); 72 int h = QMAX( fontMetrics().height(), miniicon.height() );
70 setMinimumSize( w+16, h+8 ); 73 setMinimumSize( w+16, h+8 );
71} 74}
72 75
73void OPopupTitle::setIcon( const QPixmap &pix ) 76void OPopupTitle::setIcon( const QPixmap &pix )
74{ 77{
75 miniicon = pix; 78 miniicon = pix;
76 int w = miniicon.width()+fontMetrics().width(titleStr); 79 int w = miniicon.width()+fontMetrics().width(titleStr);
77 int h = QMAX( fontMetrics().height(), miniicon.height() ); 80 int h = QMAX( fontMetrics().height(), miniicon.height() );
diff --git a/libopie2/opieui/opopupmenu.h b/libopie2/opieui/opopupmenu.h
index 54e4301..419a954 100644
--- a/libopie2/opieui/opopupmenu.h
+++ b/libopie2/opieui/opopupmenu.h
@@ -1,81 +1,83 @@
1//FIXME what is ODE? ODE Desktop Environemt? -zecke 1//FIXME what is ODE? ODE Desktop Environemt? -zecke
2//FIXME do we need titles? space is limited that is only eyecandy? -zecke 2//FIXME do we need titles? space is limited that is only eyecandy? -zecke
3//FIXME keyboard navigation is also not that popular on a PDA might be with a keyboard (tuxphone) -zecke 3//FIXME keyboard navigation is also not that popular on a PDA might be with a keyboard (tuxphone) -zecke
4/* This file is part of the ODE libraries 4/* This file is part of the ODE libraries
5 Copyright (C) 2000 Daniel M. Duley <mosfet@kde.org> 5 Copyright (C) 2000 Daniel M. Duley <mosfet@kde.org>
6 6
7 This library is free software; you can redistribute it and/or 7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public 8 modify it under the terms of the GNU Library General Public
9 License version 2 as published by the Free Software Foundation. 9 License version 2 as published by the Free Software Foundation.
10 10
11 This library is distributed in the hope that it will be useful, 11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details. 14 Library General Public License for more details.
15 15
16 You should have received a copy of the GNU Library General Public License 16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to 17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. 19 Boston, MA 02111-1307, USA.
20*/ 20*/
21#ifndef _OPOPUP_H 21#ifndef _OPOPUP_H
22#define _OPOPUP_H 22#define _OPOPUP_H
23 23
24#define INCLUDE_MENUITEM_DEF 24#define INCLUDE_MENUITEM_DEF
25 25
26/* QT */ 26/* QT */
27 27
28#include <qpopupmenu.h> 28#include <qpopupmenu.h>
29 29
30/* OPIE */ 30/* OPIE */
31 31
32#include <opie2/opixmapeffect.h> 32#include <opie2/opixmapeffect.h>
33 33
34namespace Opie {
35namespace Ui {
34/** 36/**
35 * Title widget for use in @ref OPopupMenu. 37 * Title widget for use in @ref OPopupMenu.
36 * 38 *
37 * You usually don't have to create this manually since 39 * You usually don't have to create this manually since
38 * @ref OPopupMenu::insertTitle will do it for you, but it is allowed if 40 * @ref OPopupMenu::insertTitle will do it for you, but it is allowed if
39 * you wish to customize it's look. 41 * you wish to customize it's look.
40 * 42 *
41 * @author Daniel M. Duley <mosfet@kde.org> 43 * @author Daniel M. Duley <mosfet@kde.org>
42 * @short OPopupMenu title widget. 44 * @short OPopupMenu title widget.
43 */ 45 */
44class OPopupTitle : public QWidget 46class OPopupTitle : public QWidget
45{ 47{
46 Q_OBJECT 48 Q_OBJECT
47 49
48public: 50public:
49 /** 51 /**
50 * Constructs a title widget with the user specified gradient, pixmap, 52 * Constructs a title widget with the user specified gradient, pixmap,
51 * and colors. 53 * and colors.
52 */ 54 */
53 OPopupTitle(QWidget *parent=0, const char *name=0); 55 OPopupTitle(QWidget *parent=0, const char *name=0);
54 /** 56 /**
55 * @deprecated 57 * @deprecated
56 * Constructs a title widget with the specified gradient and colors. 58 * Constructs a title widget with the specified gradient and colors.
57 */ 59 */
58 OPopupTitle(OPixmapEffect::GradientType gradient, const QColor &color, 60 OPopupTitle(OPixmapEffect::GradientType gradient, const QColor &color,
59 const QColor &textColor, QWidget *parent=0, 61 const QColor &textColor, QWidget *parent=0,
60 const char *name=0); 62 const char *name=0);
61 /** 63 /**
62 * @deprecated 64 * @deprecated
63 * Constructs a title widget with the specified pixmap and colors. 65 * Constructs a title widget with the specified pixmap and colors.
64 */ 66 */
65 OPopupTitle(const OPixmap &background, const QColor &color, 67 OPopupTitle(const OPixmap &background, const QColor &color,
66 const QColor &textColor, QWidget *parent=0, 68 const QColor &textColor, QWidget *parent=0,
67 const char *name=0); 69 const char *name=0);
68 /** 70 /**
69 * Sets the title string and optional icon for the title widget. 71 * Sets the title string and optional icon for the title widget.
70 * 72 *
71 * You will want to call this before inserting into a menu. 73 * You will want to call this before inserting into a menu.
72 */ 74 */
73 void setTitle(const QString &text, const QPixmap *icon=NULL); 75 void setTitle(const QString &text, const QPixmap *icon=NULL);
74 /** 76 /**
75 * Returns the current title. 77 * Returns the current title.
76 */ 78 */
77 QString title() const { return(titleStr); } 79 QString title() const { return(titleStr); }
78 /** 80 /**
79 * Returns the current icon. 81 * Returns the current icon.
80 */ 82 */
81 QPixmap icon() const { return(miniicon); } 83 QPixmap icon() const { return(miniicon); }
@@ -211,49 +213,52 @@ public:
211 * @since 3.2 213 * @since 3.2
212 */ 214 */
213 void cancelContextMenuShow(); 215 void cancelContextMenuShow();
214 216
215 /** 217 /**
216 * Returns the OPopupMenu associated with the current context menu 218 * Returns the OPopupMenu associated with the current context menu
217 * @since 3.2 219 * @since 3.2
218 */ 220 */
219 static OPopupMenu* contextMenuFocus(); 221 static OPopupMenu* contextMenuFocus();
220 222
221 /** 223 /**
222 * returns the ID of the menuitem associated with the current context menu 224 * returns the ID of the menuitem associated with the current context menu
223 * @since 3.2 225 * @since 3.2
224 */ 226 */
225 static int contextMenuFocusItem(); 227 static int contextMenuFocusItem();
226 228
227signals: 229signals:
228 /** 230 /**
229 * connect to this signal to be notified when a context menu is about to be shown 231 * connect to this signal to be notified when a context menu is about to be shown
230 * @param menu The menu that the context menu is about to be shown for 232 * @param menu The menu that the context menu is about to be shown for
231 * @param menuItem The menu item that the context menu is currently on 233 * @param menuItem The menu item that the context menu is currently on
232 * @param ctxMenu The context menu itself 234 * @param ctxMenu The context menu itself
233 * @since 3.2 235 * @since 3.2
234 */ 236 */
235 void aboutToShowContextMenu(OPopupMenu* menu, int menuItem, QPopupMenu* ctxMenu); 237 void aboutToShowContextMenu(OPopupMenu* menu, int menuItem, QPopupMenu* ctxMenu);
236 238
237protected: 239protected:
238 virtual void closeEvent(QCloseEvent *); 240 virtual void closeEvent(QCloseEvent *);
239 virtual void keyPressEvent(QKeyEvent* e); 241 virtual void keyPressEvent(QKeyEvent* e);
240 virtual bool eventFilter(QObject* obj, QEvent* event); 242 virtual bool eventFilter(QObject* obj, QEvent* event);
241 virtual void hideEvent(QHideEvent*); 243 virtual void hideEvent(QHideEvent*);
242 244
243 virtual void virtual_hook( int id, void* data ); 245 virtual void virtual_hook( int id, void* data );
244 246
245protected slots: 247protected slots:
246 /// @since 3.1 248 /// @since 3.1
247 QString underlineText(const QString& text, uint length); 249 QString underlineText(const QString& text, uint length);
248 /// @since 3.1 250 /// @since 3.1
249 void resetKeyboardVars(bool noMatches = false); 251 void resetKeyboardVars(bool noMatches = false);
250 void itemHighlighted(int whichItem); 252 void itemHighlighted(int whichItem);
251 void showCtxMenu(QPoint pos); 253 void showCtxMenu(QPoint pos);
252 void ctxMenuHiding(); 254 void ctxMenuHiding();
253 255
254private: 256private:
255 class OPopupMenuPrivate; 257 class OPopupMenuPrivate;
256 OPopupMenuPrivate *d; 258 OPopupMenuPrivate *d;
257}; 259};
258 260
261}
262}
263
259#endif 264#endif
diff --git a/libopie2/opieui/oselector.cpp b/libopie2/opieui/oselector.cpp
index 23b3ce3..5f6f10f 100644
--- a/libopie2/opieui/oselector.cpp
+++ b/libopie2/opieui/oselector.cpp
@@ -1,124 +1,126 @@
1/* This file is part of the KDE libraries 1/* This file is part of the KDE libraries
2 Copyright (C) 1997 Martin Jones (mjones@kde.org) 2 Copyright (C) 1997 Martin Jones (mjones@kde.org)
3 3
4 This library is free software; you can redistribute it and/or 4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public 5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either 6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version. 7 version 2 of the License, or (at your option) any later version.
8 8
9 This library is distributed in the hope that it will be useful, 9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details. 12 Library General Public License for more details.
13 13
14 You should have received a copy of the GNU Library General Public License 14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to 15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA. 17 Boston, MA 02111-1307, USA.
18*/ 18*/
19 19
20/* QT */ 20/* QT */
21 21
22#include <qimage.h> 22#include <qimage.h>
23#include <qdrawutil.h> 23#include <qdrawutil.h>
24 24
25/* OPIE */ 25/* OPIE */
26 26
27#include <opie2/oimageeffect.h> 27#include <opie2/oimageeffect.h>
28#include <opie2/oselector.h> 28#include <opie2/oselector.h>
29 29
30#define STORE_W 8 30#define STORE_W 8
31#define STORE_W2 STORE_W * 2 31#define STORE_W2 STORE_W * 2
32 32
33//----------------------------------------------------------------------------- 33//-----------------------------------------------------------------------------
34/* 34/*
35 * 2D value selector. 35 * 2D value selector.
36 * The contents of the selector are drawn by derived class. 36 * The contents of the selector are drawn by derived class.
37 */ 37 */
38 38
39using namespace Opie::Ui;
40
39OXYSelector::OXYSelector( QWidget *parent, const char *name ) 41OXYSelector::OXYSelector( QWidget *parent, const char *name )
40 : QWidget( parent, name ) 42 : QWidget( parent, name )
41{ 43{
42 xPos = 0; 44 xPos = 0;
43 yPos = 0; 45 yPos = 0;
44 minX = 0; 46 minX = 0;
45 minY = 0; 47 minY = 0;
46 maxX = 100; 48 maxX = 100;
47 maxY = 100; 49 maxY = 100;
48 store.setOptimization( QPixmap::BestOptim ); 50 store.setOptimization( QPixmap::BestOptim );
49 store.resize( STORE_W2, STORE_W2 ); 51 store.resize( STORE_W2, STORE_W2 );
50} 52}
51 53
52 54
53OXYSelector::~OXYSelector() 55OXYSelector::~OXYSelector()
54{} 56{}
55 57
56 58
57void OXYSelector::setRange( int _minX, int _minY, int _maxX, int _maxY ) 59void OXYSelector::setRange( int _minX, int _minY, int _maxX, int _maxY )
58{ 60{
59 px = 2; 61 px = 2;
60 py = 2; 62 py = 2;
61 minX = _minX; 63 minX = _minX;
62 minY = _minY; 64 minY = _minY;
63 maxX = _maxX; 65 maxX = _maxX;
64 maxY = _maxY; 66 maxY = _maxY;
65} 67}
66 68
67void OXYSelector::setValues( int _xPos, int _yPos ) 69void OXYSelector::setValues( int _xPos, int _yPos )
68{ 70{
69 xPos = _xPos; 71 xPos = _xPos;
70 yPos = _yPos; 72 yPos = _yPos;
71 73
72 if ( xPos > maxX ) 74 if ( xPos > maxX )
73 xPos = maxX; 75 xPos = maxX;
74 else if ( xPos < minX ) 76 else if ( xPos < minX )
75 xPos = minX; 77 xPos = minX;
76 78
77 if ( yPos > maxY ) 79 if ( yPos > maxY )
78 yPos = maxY; 80 yPos = maxY;
79 else if ( yPos < minY ) 81 else if ( yPos < minY )
80 yPos = minY; 82 yPos = minY;
81 83
82 int xp = 2 + (width() - 4) * xPos / (maxX - minX); 84 int xp = 2 + (width() - 4) * xPos / (maxX - minX);
83 int yp = height() - 2 - (height() - 4) * yPos / (maxY - minY); 85 int yp = height() - 2 - (height() - 4) * yPos / (maxY - minY);
84 86
85 setPosition( xp, yp ); 87 setPosition( xp, yp );
86} 88}
87 89
88QRect OXYSelector::contentsRect() const 90QRect OXYSelector::contentsRect() const
89{ 91{
90 return QRect( 2, 2, width()-4, height()-4 ); 92 return QRect( 2, 2, width()-4, height()-4 );
91} 93}
92 94
93void OXYSelector::paintEvent( QPaintEvent *ev ) 95void OXYSelector::paintEvent( QPaintEvent *ev )
94{ 96{
95 QRect cursorRect( px - STORE_W, py - STORE_W, STORE_W2, STORE_W2); 97 QRect cursorRect( px - STORE_W, py - STORE_W, STORE_W2, STORE_W2);
96 QRect paintRect = ev->rect(); 98 QRect paintRect = ev->rect();
97 99
98 QPainter painter; 100 QPainter painter;
99 painter.begin( this ); 101 painter.begin( this );
100 102
101 QBrush brush; 103 QBrush brush;
102 qDrawShadePanel( &painter, 0, 0, width(), height(), colorGroup(), 104 qDrawShadePanel( &painter, 0, 0, width(), height(), colorGroup(),
103 TRUE, 2, &brush ); 105 TRUE, 2, &brush );
104 106
105 drawContents( &painter ); 107 drawContents( &painter );
106 if (paintRect.contains(cursorRect)) 108 if (paintRect.contains(cursorRect))
107 { 109 {
108 bitBlt( &store, 0, 0, this, px - STORE_W, py - STORE_W, 110 bitBlt( &store, 0, 0, this, px - STORE_W, py - STORE_W,
109 STORE_W2, STORE_W2, CopyROP ); 111 STORE_W2, STORE_W2, CopyROP );
110 drawCursor( &painter, px, py ); 112 drawCursor( &painter, px, py );
111 } 113 }
112 else if (paintRect.intersects(cursorRect)) 114 else if (paintRect.intersects(cursorRect))
113 { 115 {
114 repaint( cursorRect, false); 116 repaint( cursorRect, false);
115 } 117 }
116 118
117 painter.end(); 119 painter.end();
118} 120}
119 121
120void OXYSelector::mousePressEvent( QMouseEvent *e ) 122void OXYSelector::mousePressEvent( QMouseEvent *e )
121{ 123{
122 int xVal, yVal; 124 int xVal, yVal;
123 valuesFromPosition( e->pos().x() - 2, e->pos().y() - 2, xVal, yVal ); 125 valuesFromPosition( e->pos().x() - 2, e->pos().y() - 2, xVal, yVal );
124 setValues( xVal, yVal ); 126 setValues( xVal, yVal );
@@ -213,311 +215,311 @@ void OXYSelector::drawCursor( QPainter *p, int xp, int yp )
213OSelector::OSelector( QWidget *parent, const char *name ) 215OSelector::OSelector( QWidget *parent, const char *name )
214 : QWidget( parent, name ), QRangeControl() 216 : QWidget( parent, name ), QRangeControl()
215{ 217{
216 _orientation = Horizontal; 218 _orientation = Horizontal;
217 _indent = TRUE; 219 _indent = TRUE;
218} 220}
219 221
220OSelector::OSelector( Orientation o, QWidget *parent, const char *name ) 222OSelector::OSelector( Orientation o, QWidget *parent, const char *name )
221 : QWidget( parent, name ), QRangeControl() 223 : QWidget( parent, name ), QRangeControl()
222{ 224{
223 _orientation = o; 225 _orientation = o;
224 _indent = TRUE; 226 _indent = TRUE;
225} 227}
226 228
227 229
228OSelector::~OSelector() 230OSelector::~OSelector()
229{} 231{}
230 232
231 233
232QRect OSelector::contentsRect() const 234QRect OSelector::contentsRect() const
233{ 235{
234 if ( orientation() == Vertical ) 236 if ( orientation() == Vertical )
235 return QRect( 2, 5, width()-9, height()-10 ); 237 return QRect( 2, 5, width()-9, height()-10 );
236 else 238 else
237 return QRect( 5, 2, width()-10, height()-9 ); 239 return QRect( 5, 2, width()-10, height()-9 );
238} 240}
239 241
240void OSelector::paintEvent( QPaintEvent * ) 242void OSelector::paintEvent( QPaintEvent * )
241{ 243{
242 QPainter painter; 244 QPainter painter;
243 245
244 painter.begin( this ); 246 painter.begin( this );
245 247
246 drawContents( &painter ); 248 drawContents( &painter );
247 249
248 QBrush brush; 250 QBrush brush;
249 251
250 if ( indent() ) 252 if ( indent() )
251 { 253 {
252 if ( orientation() == Vertical ) 254 if ( orientation() == Vertical )
253 qDrawShadePanel( &painter, 0, 3, width()-5, height()-6, 255 qDrawShadePanel( &painter, 0, 3, width()-5, height()-6,
254 colorGroup(), TRUE, 2, &brush ); 256 colorGroup(), TRUE, 2, &brush );
255 else 257 else
256 qDrawShadePanel( &painter, 3, 0, width()-6, height()-5, 258 qDrawShadePanel( &painter, 3, 0, width()-6, height()-5,
257 colorGroup(), TRUE, 2, &brush ); 259 colorGroup(), TRUE, 2, &brush );
258 } 260 }
259 261
260 QPoint pos = calcArrowPos( value() ); 262 QPoint pos = calcArrowPos( value() );
261 drawArrow( &painter, TRUE, pos ); 263 drawArrow( &painter, TRUE, pos );
262 264
263 painter.end(); 265 painter.end();
264} 266}
265 267
266void OSelector::mousePressEvent( QMouseEvent *e ) 268void OSelector::mousePressEvent( QMouseEvent *e )
267{ 269{
268 moveArrow( e->pos() ); 270 moveArrow( e->pos() );
269} 271}
270 272
271void OSelector::mouseMoveEvent( QMouseEvent *e ) 273void OSelector::mouseMoveEvent( QMouseEvent *e )
272{ 274{
273 moveArrow( e->pos() ); 275 moveArrow( e->pos() );
274} 276}
275 277
276void OSelector::wheelEvent( QWheelEvent *e ) 278void OSelector::wheelEvent( QWheelEvent *e )
277{ 279{
278 int val = value() + e->delta()/120; 280 int val = value() + e->delta()/120;
279 emit valueChanged( val ); 281 emit valueChanged( val );
280 setValue( val ); 282 setValue( val );
281} 283}
282 284
283void OSelector::valueChange() 285void OSelector::valueChange()
284{ 286{
285 QPainter painter; 287 QPainter painter;
286 QPoint pos; 288 QPoint pos;
287 289
288 painter.begin( this ); 290 painter.begin( this );
289 291
290 pos = calcArrowPos( prevValue() ); 292 pos = calcArrowPos( prevValue() );
291 drawArrow( &painter, FALSE, pos ); 293 drawArrow( &painter, FALSE, pos );
292 294
293 pos = calcArrowPos( value() ); 295 pos = calcArrowPos( value() );
294 drawArrow( &painter, TRUE, pos ); 296 drawArrow( &painter, TRUE, pos );
295 297
296 painter.end(); 298 painter.end();
297} 299}
298 300
299void OSelector::moveArrow( const QPoint &pos ) 301void OSelector::moveArrow( const QPoint &pos )
300{ 302{
301 int val; 303 int val;
302 304
303 if ( orientation() == Vertical ) 305 if ( orientation() == Vertical )
304 val = ( maxValue() - minValue() ) * (height()-pos.y()-3) 306 val = ( maxValue() - minValue() ) * (height()-pos.y()-3)
305 / (height()-10) + minValue(); 307 / (height()-10) + minValue();
306 else 308 else
307 val = ( maxValue() - minValue() ) * (width()-pos.x()-3) 309 val = ( maxValue() - minValue() ) * (width()-pos.x()-3)
308 / (width()-10) + minValue(); 310 / (width()-10) + minValue();
309 311
310 if ( val > maxValue() ) 312 if ( val > maxValue() )
311 val = maxValue(); 313 val = maxValue();
312 if ( val < minValue() ) 314 if ( val < minValue() )
313 val = minValue(); 315 val = minValue();
314 316
315 emit valueChanged( val ); 317 emit valueChanged( val );
316 setValue( val ); 318 setValue( val );
317} 319}
318 320
319QPoint OSelector::calcArrowPos( int val ) 321QPoint OSelector::calcArrowPos( int val )
320{ 322{
321 QPoint p; 323 QPoint p;
322 324
323 if ( orientation() == Vertical ) 325 if ( orientation() == Vertical )
324 { 326 {
325 p.setY( height() - ( (height()-10) * val 327 p.setY( height() - ( (height()-10) * val
326 / ( maxValue() - minValue() ) + 5 ) ); 328 / ( maxValue() - minValue() ) + 5 ) );
327 p.setX( width() - 5 ); 329 p.setX( width() - 5 );
328 } 330 }
329 else 331 else
330 { 332 {
331 p.setX( width() - ( (width()-10) * val 333 p.setX( width() - ( (width()-10) * val
332 / ( maxValue() - minValue() ) + 5 ) ); 334 / ( maxValue() - minValue() ) + 5 ) );
333 p.setY( height() - 5 ); 335 p.setY( height() - 5 );
334 } 336 }
335 337
336 return p; 338 return p;
337} 339}
338 340
339void OSelector::drawContents( QPainter * ) 341void OSelector::drawContents( QPainter * )
340{} 342{}
341 343
342void OSelector::drawArrow( QPainter *painter, bool show, const QPoint &pos ) 344void OSelector::drawArrow( QPainter *painter, bool show, const QPoint &pos )
343{ 345{
344 if ( show ) 346 if ( show )
345 { 347 {
346 QPointArray array(3); 348 QPointArray array(3);
347 349
348 painter->setPen( QPen() ); 350 painter->setPen( QPen() );
349 painter->setBrush( QBrush( colorGroup().buttonText() ) ); 351 painter->setBrush( QBrush( colorGroup().buttonText() ) );
350 if ( orientation() == Vertical ) 352 if ( orientation() == Vertical )
351 { 353 {
352 array.setPoint( 0, pos.x()+0, pos.y()+0 ); 354 array.setPoint( 0, pos.x()+0, pos.y()+0 );
353 array.setPoint( 1, pos.x()+5, pos.y()+5 ); 355 array.setPoint( 1, pos.x()+5, pos.y()+5 );
354 array.setPoint( 2, pos.x()+5, pos.y()-5 ); 356 array.setPoint( 2, pos.x()+5, pos.y()-5 );
355 } 357 }
356 else 358 else
357 { 359 {
358 array.setPoint( 0, pos.x()+0, pos.y()+0 ); 360 array.setPoint( 0, pos.x()+0, pos.y()+0 );
359 array.setPoint( 1, pos.x()+5, pos.y()+5 ); 361 array.setPoint( 1, pos.x()+5, pos.y()+5 );
360 array.setPoint( 2, pos.x()-5, pos.y()+5 ); 362 array.setPoint( 2, pos.x()-5, pos.y()+5 );
361 } 363 }
362 364
363 painter->drawPolygon( array ); 365 painter->drawPolygon( array );
364 } 366 }
365 else 367 else
366 { 368 {
367 if ( orientation() == Vertical ) 369 if ( orientation() == Vertical )
368 { 370 {
369 repaint(pos.x(), pos.y()-5, 6, 11, true); 371 repaint(pos.x(), pos.y()-5, 6, 11, true);
370 } 372 }
371 else 373 else
372 { 374 {
373 repaint(pos.x()-5, pos.y(), 11, 6, true); 375 repaint(pos.x()-5, pos.y(), 11, 6, true);
374 } 376 }
375 } 377 }
376} 378}
377 379
378//---------------------------------------------------------------------------- 380//----------------------------------------------------------------------------
379 381
380OGradientSelector::OGradientSelector( QWidget *parent, const char *name ) 382OGradientSelector::OGradientSelector( QWidget *parent, const char *name )
381 : OSelector( parent, name ) 383 : OSelector( parent, name )
382{ 384{
383 init(); 385 init();
384} 386}
385 387
386 388
387OGradientSelector::OGradientSelector( Orientation o, QWidget *parent, 389OGradientSelector::OGradientSelector( Orientation o, QWidget *parent,
388 const char *name ) 390 const char *name )
389 : OSelector( o, parent, name ) 391 : OSelector( o, parent, name )
390{ 392{
391 init(); 393 init();
392} 394}
393 395
394 396
395OGradientSelector::~OGradientSelector() 397OGradientSelector::~OGradientSelector()
396{} 398{}
397 399
398 400
399void OGradientSelector::init() 401void OGradientSelector::init()
400{ 402{
401 color1.setRgb( 0, 0, 0 ); 403 color1.setRgb( 0, 0, 0 );
402 color2.setRgb( 255, 255, 255 ); 404 color2.setRgb( 255, 255, 255 );
403 405
404 text1 = text2 = ""; 406 text1 = text2 = "";
405} 407}
406 408
407 409
408void OGradientSelector::drawContents( QPainter *painter ) 410void OGradientSelector::drawContents( QPainter *painter )
409{ 411{
410 QImage image( contentsRect().width(), contentsRect().height(), 32 ); 412 QImage image( contentsRect().width(), contentsRect().height(), 32 );
411 413
412 QColor col; 414 QColor col;
413 float scale; 415 float scale;
414 416
415 int redDiff = color2.red() - color1.red(); 417 int redDiff = color2.red() - color1.red();
416 int greenDiff = color2.green() - color1.green(); 418 int greenDiff = color2.green() - color1.green();
417 int blueDiff = color2.blue() - color1.blue(); 419 int blueDiff = color2.blue() - color1.blue();
418 420
419 if ( orientation() == Vertical ) 421 if ( orientation() == Vertical )
420 { 422 {
421 for ( int y = 0; y < image.height(); y++ ) 423 for ( int y = 0; y < image.height(); y++ )
422 { 424 {
423 scale = 1.0 * y / image.height(); 425 scale = 1.0 * y / image.height();
424 col.setRgb( color1.red() + int(redDiff*scale), 426 col.setRgb( color1.red() + int(redDiff*scale),
425 color1.green() + int(greenDiff*scale), 427 color1.green() + int(greenDiff*scale),
426 color1.blue() + int(blueDiff*scale) ); 428 color1.blue() + int(blueDiff*scale) );
427 429
428 unsigned int *p = (uint *) image.scanLine( y ); 430 unsigned int *p = (uint *) image.scanLine( y );
429 for ( int x = 0; x < image.width(); x++ ) 431 for ( int x = 0; x < image.width(); x++ )
430 *p++ = col.rgb(); 432 *p++ = col.rgb();
431 } 433 }
432 } 434 }
433 else 435 else
434 { 436 {
435 unsigned int *p = (uint *) image.scanLine( 0 ); 437 unsigned int *p = (uint *) image.scanLine( 0 );
436 438
437 for ( int x = 0; x < image.width(); x++ ) 439 for ( int x = 0; x < image.width(); x++ )
438 { 440 {
439 scale = 1.0 * x / image.width(); 441 scale = 1.0 * x / image.width();
440 col.setRgb( color1.red() + int(redDiff*scale), 442 col.setRgb( color1.red() + int(redDiff*scale),
441 color1.green() + int(greenDiff*scale), 443 color1.green() + int(greenDiff*scale),
442 color1.blue() + int(blueDiff*scale) ); 444 color1.blue() + int(blueDiff*scale) );
443 *p++ = col.rgb(); 445 *p++ = col.rgb();
444 } 446 }
445 447
446 for ( int y = 1; y < image.height(); y++ ) 448 for ( int y = 1; y < image.height(); y++ )
447 memcpy( image.scanLine( y ), image.scanLine( y - 1), 449 memcpy( image.scanLine( y ), image.scanLine( y - 1),
448 sizeof( unsigned int ) * image.width() ); 450 sizeof( unsigned int ) * image.width() );
449 } 451 }
450 452
451 QColor ditherPalette[8]; 453 QColor ditherPalette[8];
452 454
453 for ( int s = 0; s < 8; s++ ) 455 for ( int s = 0; s < 8; s++ )
454 ditherPalette[s].setRgb( color1.red() + redDiff * s / 8, 456 ditherPalette[s].setRgb( color1.red() + redDiff * s / 8,
455 color1.green() + greenDiff * s / 8, 457 color1.green() + greenDiff * s / 8,
456 color1.blue() + blueDiff * s / 8 ); 458 color1.blue() + blueDiff * s / 8 );
457 459
458 OImageEffect::dither( image, ditherPalette, 8 ); 460 OImageEffect::dither( image, ditherPalette, 8 );
459 461
460 QPixmap p; 462 QPixmap p;
461 p.convertFromImage( image ); 463 p.convertFromImage( image );
462 464
463 painter->drawPixmap( contentsRect().x(), contentsRect().y(), p ); 465 painter->drawPixmap( contentsRect().x(), contentsRect().y(), p );
464 466
465 if ( orientation() == Vertical ) 467 if ( orientation() == Vertical )
466 { 468 {
467 int yPos = contentsRect().top() + painter->fontMetrics().ascent() + 2; 469 int yPos = contentsRect().top() + painter->fontMetrics().ascent() + 2;
468 int xPos = contentsRect().left() + (contentsRect().width() - 470 int xPos = contentsRect().left() + (contentsRect().width() -
469 painter->fontMetrics().width( text2 )) / 2; 471 painter->fontMetrics().width( text2 )) / 2;
470 QPen pen( color2 ); 472 QPen pen( color2 );
471 painter->setPen( pen ); 473 painter->setPen( pen );
472 painter->drawText( xPos, yPos, text2 ); 474 painter->drawText( xPos, yPos, text2 );
473 475
474 yPos = contentsRect().bottom() - painter->fontMetrics().descent() - 2; 476 yPos = contentsRect().bottom() - painter->fontMetrics().descent() - 2;
475 xPos = contentsRect().left() + (contentsRect().width() - 477 xPos = contentsRect().left() + (contentsRect().width() -
476 painter->fontMetrics().width( text1 )) / 2; 478 painter->fontMetrics().width( text1 )) / 2;
477 pen.setColor( color1 ); 479 pen.setColor( color1 );
478 painter->setPen( pen ); 480 painter->setPen( pen );
479 painter->drawText( xPos, yPos, text1 ); 481 painter->drawText( xPos, yPos, text1 );
480 } 482 }
481 else 483 else
482 { 484 {
483 int yPos = contentsRect().bottom()-painter->fontMetrics().descent()-2; 485 int yPos = contentsRect().bottom()-painter->fontMetrics().descent()-2;
484 486
485 QPen pen( color2 ); 487 QPen pen( color2 );
486 painter->setPen( pen ); 488 painter->setPen( pen );
487 painter->drawText( contentsRect().left() + 2, yPos, text1 ); 489 painter->drawText( contentsRect().left() + 2, yPos, text1 );
488 490
489 pen.setColor( color1 ); 491 pen.setColor( color1 );
490 painter->setPen( pen ); 492 painter->setPen( pen );
491 painter->drawText( contentsRect().right() - 493 painter->drawText( contentsRect().right() -
492 painter->fontMetrics().width( text2 ) - 2, yPos, text2 ); 494 painter->fontMetrics().width( text2 ) - 2, yPos, text2 );
493 } 495 }
494} 496}
495 497
496//----------------------------------------------------------------------------- 498//-----------------------------------------------------------------------------
497 499
498static QColor *standardPalette = 0; 500static QColor *standardPalette = 0;
499 501
500#define STANDARD_PAL_SIZE 17 502#define STANDARD_PAL_SIZE 17
501 503
502OColor::OColor() 504OColor::OColor()
503: QColor() 505: QColor()
504{ 506{
505 r = 0; g = 0; b = 0; h = 0; s = 0; v = 0; 507 r = 0; g = 0; b = 0; h = 0; s = 0; v = 0;
506}; 508};
507 509
508OColor::OColor( const OColor &col) 510OColor::OColor( const OColor &col)
509: QColor( col ) 511: QColor( col )
510{ 512{
511 h = col.h; s = col.s; v = col.v; 513 h = col.h; s = col.s; v = col.v;
512 r = col.r; g = col.g; b = col.b; 514 r = col.r; g = col.g; b = col.b;
513}; 515};
514 516
515OColor::OColor( const QColor &col) 517OColor::OColor( const QColor &col)
516: QColor( col ) 518: QColor( col )
517{ 519{
518 QColor::rgb(&r, &g, &b); 520 QColor::rgb(&r, &g, &b);
519 QColor::hsv(&h, &s, &v); 521 QColor::hsv(&h, &s, &v);
520}; 522};
521 523
522bool OColor::operator==(const OColor& col) const 524bool OColor::operator==(const OColor& col) const
523{ 525{
diff --git a/libopie2/opieui/oselector.h b/libopie2/opieui/oselector.h
index f832239..fe75a46 100644
--- a/libopie2/opieui/oselector.h
+++ b/libopie2/opieui/oselector.h
@@ -1,77 +1,80 @@
1/* This file is part of the KDE libraries 1/* This file is part of the KDE libraries
2 Copyright (C) 1997 Martin Jones (mjones@kde.org) 2 Copyright (C) 1997 Martin Jones (mjones@kde.org)
3 3
4 This library is free software; you can redistribute it and/or 4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public 5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either 6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version. 7 version 2 of the License, or (at your option) any later version.
8 8
9 This library is distributed in the hope that it will be useful, 9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details. 12 Library General Public License for more details.
13 13
14 You should have received a copy of the GNU Library General Public License 14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to 15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA. 17 Boston, MA 02111-1307, USA.
18*/ 18*/
19//----------------------------------------------------------------------------- 19//-----------------------------------------------------------------------------
20// Selector widgets for KDE Color Selector, but probably useful for other 20// Selector widgets for KDE Color Selector, but probably useful for other
21// stuff also. 21// stuff also.
22 22
23#ifndef __OSELECT_H__ 23#ifndef __OSELECT_H__
24#define __OSELECT_H__ 24#define __OSELECT_H__
25 25
26#include <qwidget.h> 26#include <qwidget.h>
27#include <qrangecontrol.h> 27#include <qrangecontrol.h>
28#include <qpixmap.h> 28#include <qpixmap.h>
29 29
30
31namespace Opie {
32namespace Ui {
30/** 33/**
31 * OXYSelector is the base class for other widgets which 34 * OXYSelector is the base class for other widgets which
32 * provides the ability to choose from a two-dimensional 35 * provides the ability to choose from a two-dimensional
33 * range of values. The currently chosen value is indicated 36 * range of values. The currently chosen value is indicated
34 * by a cross. An example is the @ref OHSSelector which 37 * by a cross. An example is the @ref OHSSelector which
35 * allows to choose from a range of colors, and which is 38 * allows to choose from a range of colors, and which is
36 * used in OColorDialog. 39 * used in OColorDialog.
37 * 40 *
38 * A custom drawing routine for the widget surface has 41 * A custom drawing routine for the widget surface has
39 * to be provided by the subclass. 42 * to be provided by the subclass.
40 */ 43 */
41class OXYSelector : public QWidget 44class OXYSelector : public QWidget
42{ 45{
43 Q_OBJECT 46 Q_OBJECT
44 47
45public: 48public:
46 /** 49 /**
47 * Constructs a two-dimensional selector widget which 50 * Constructs a two-dimensional selector widget which
48 * has a value range of [0..100] in both directions. 51 * has a value range of [0..100] in both directions.
49 */ 52 */
50 OXYSelector( QWidget *parent=0, const char *name=0 ); 53 OXYSelector( QWidget *parent=0, const char *name=0 );
51 /** 54 /**
52 * Destructs the widget. 55 * Destructs the widget.
53 */ 56 */
54 ~OXYSelector(); 57 ~OXYSelector();
55 58
56 /** 59 /**
57 * Sets the current values in horizontal and 60 * Sets the current values in horizontal and
58 * vertical direction. 61 * vertical direction.
59 */ 62 */
60 void setValues( int xPos, int yPos ); 63 void setValues( int xPos, int yPos );
61 /** 64 /**
62 * Sets the range of possible values. 65 * Sets the range of possible values.
63 */ 66 */
64 void setRange( int minX, int minY, int maxX, int maxY ); 67 void setRange( int minX, int minY, int maxX, int maxY );
65 68
66 /** 69 /**
67 * @return the current value in horizontal direction. 70 * @return the current value in horizontal direction.
68 */ 71 */
69 int xValue() const {return xPos; } 72 int xValue() const {return xPos; }
70 /** 73 /**
71 * @return the current value in vertical direction. 74 * @return the current value in vertical direction.
72 */ 75 */
73 int yValue() const {return yPos; } 76 int yValue() const {return yPos; }
74 77
75 /** 78 /**
76 * @return the rectangle on which subclasses should draw. 79 * @return the rectangle on which subclasses should draw.
77 */ 80 */
@@ -467,52 +470,54 @@ protected:
467 virtual void resizeEvent( QResizeEvent * ); 470 virtual void resizeEvent( QResizeEvent * );
468 /** 471 /**
469 * Reimplemented from OSelector. The drawing is 472 * Reimplemented from OSelector. The drawing is
470 * buffered in a pixmap here. As real drawing 473 * buffered in a pixmap here. As real drawing
471 * routine, drawPalette() is used. 474 * routine, drawPalette() is used.
472 */ 475 */
473 virtual void drawContents( QPainter *painter ); 476 virtual void drawContents( QPainter *painter );
474 477
475private: 478private:
476 int _hue; 479 int _hue;
477 int _sat; 480 int _sat;
478 QPixmap pixmap; 481 QPixmap pixmap;
479 482
480private: 483private:
481 class OValueSelectorPrivate; 484 class OValueSelectorPrivate;
482 OValueSelectorPrivate *d; 485 OValueSelectorPrivate *d;
483}; 486};
484 487
485 488
486class OColor : public QColor 489class OColor : public QColor
487{ 490{
488public: 491public:
489 OColor(); 492 OColor();
490 OColor( const OColor &col); 493 OColor( const OColor &col);
491 OColor( const QColor &col); 494 OColor( const QColor &col);
492 495
493 OColor& operator=( const OColor& col); 496 OColor& operator=( const OColor& col);
494 497
495 bool operator==( const OColor& col) const; 498 bool operator==( const OColor& col) const;
496 499
497 void setHsv(int _h, int _s, int _v); 500 void setHsv(int _h, int _s, int _v);
498 void setRgb(int _r, int _g, int _b); 501 void setRgb(int _r, int _g, int _b);
499 502
500 void rgb(int *_r, int *_g, int *_b) const; 503 void rgb(int *_r, int *_g, int *_b) const;
501 void hsv(int *_h, int *_s, int *_v) const; 504 void hsv(int *_h, int *_s, int *_v) const;
502protected: 505protected:
503 int h; 506 int h;
504 int s; 507 int s;
505 int v; 508 int v;
506 int r; 509 int r;
507 int g; 510 int g;
508 int b; 511 int b;
509 512
510private: 513private:
511 class OColorPrivate; 514 class OColorPrivate;
512 OColorPrivate *d; 515 OColorPrivate *d;
513}; 516};
514 517
518}
519}
515 520
516 521
517 #endif // __OSELECT_H__ 522 #endif // __OSELECT_H__
518 523
diff --git a/libopie2/opieui/oseparator.cpp b/libopie2/opieui/oseparator.cpp
index b93c225..bbc4381 100644
--- a/libopie2/opieui/oseparator.cpp
+++ b/libopie2/opieui/oseparator.cpp
@@ -1,86 +1,88 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3              Copyright (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> 3              Copyright (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
4 Copyright (C) 1997 Michael Roth <mroth@wirlweb.de> 4 Copyright (C) 1997 Michael Roth <mroth@wirlweb.de>
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/* OPIE */ 32/* OPIE */
33 33
34#include <opie2/odebug.h> 34#include <opie2/odebug.h>
35#include <opie2/oseparator.h> 35#include <opie2/oseparator.h>
36 36
37/* QT */ 37/* QT */
38 38
39using namespace Opie::Core;
40using namespace Opie::Ui;
39 41
40OSeparator::OSeparator(QWidget* parent, const char* name, WFlags f) 42OSeparator::OSeparator(QWidget* parent, const char* name, WFlags f)
41 : QFrame(parent, name, f) 43 : QFrame(parent, name, f)
42{ 44{
43 setLineWidth(1); 45 setLineWidth(1);
44 setMidLineWidth(0); 46 setMidLineWidth(0);
45 setOrientation( HLine ); 47 setOrientation( HLine );
46} 48}
47 49
48 50
49 51
50OSeparator::OSeparator(int orientation, QWidget* parent, const char* name, WFlags f) 52OSeparator::OSeparator(int orientation, QWidget* parent, const char* name, WFlags f)
51 : QFrame(parent, name, f) 53 : QFrame(parent, name, f)
52{ 54{
53 setLineWidth(1); 55 setLineWidth(1);
54 setMidLineWidth(0); 56 setMidLineWidth(0);
55 setOrientation( orientation ); 57 setOrientation( orientation );
56} 58}
57 59
58 60
59 61
60void OSeparator::setOrientation(int orientation) 62void OSeparator::setOrientation(int orientation)
61{ 63{
62 switch(orientation) 64 switch(orientation)
63 { 65 {
64 case Vertical: 66 case Vertical:
65 case VLine: 67 case VLine:
66 setFrameStyle( QFrame::VLine | QFrame::Sunken ); 68 setFrameStyle( QFrame::VLine | QFrame::Sunken );
67 setMinimumSize(2, 0); 69 setMinimumSize(2, 0);
68 break; 70 break;
69 71
70 default: 72 default:
71 owarn << "OSeparator::setOrientation(): invalid orientation, using default orientation HLine" << oendl; 73 owarn << "OSeparator::setOrientation(): invalid orientation, using default orientation HLine" << oendl;
72 74
73 case Horizontal: 75 case Horizontal:
74 case HLine: 76 case HLine:
75 setFrameStyle( QFrame::HLine | QFrame::Sunken ); 77 setFrameStyle( QFrame::HLine | QFrame::Sunken );
76 setMinimumSize(0, 2); 78 setMinimumSize(0, 2);
77 break; 79 break;
78 } 80 }
79} 81}
80 82
81 83
82 84
83int OSeparator::orientation() const 85int OSeparator::orientation() const
84{ 86{
85 if ( frameStyle() & VLine ) 87 if ( frameStyle() & VLine )
86 return VLine; 88 return VLine;
diff --git a/libopie2/opieui/oseparator.h b/libopie2/opieui/oseparator.h
index e59b3f4..6fc4344 100644
--- a/libopie2/opieui/oseparator.h
+++ b/libopie2/opieui/oseparator.h
@@ -1,90 +1,95 @@
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 <mickey@tm.informatik.uni-frankfurt.de> 4              Copyright (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
5 Copyright (C) 1997 Michael Roth <mroth@wirlweb.de> 5 Copyright (C) 1997 Michael Roth <mroth@wirlweb.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#ifndef OSEPARATOR_H 33#ifndef OSEPARATOR_H
34#define OSEPARATOR_H 34#define OSEPARATOR_H
35 35
36#include <qframe.h> 36#include <qframe.h>
37 37
38namespace Opie {
39namespace Ui {
40
38/** 41/**
39 * Standard horizontal or vertical separator. 42 * Standard horizontal or vertical separator.
40 * 43 *
41 * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> 44 * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
42 * @author Michael Roth <mroth@wirlweb.de> 45 * @author Michael Roth <mroth@wirlweb.de>
43 * @version $Id$ 46 * @version $Id$
44*/ 47*/
45class OSeparator : public QFrame 48class OSeparator : public QFrame
46{ 49{
47 Q_OBJECT 50 Q_OBJECT
48 Q_PROPERTY( int orientation READ orientation WRITE setOrientation ) 51 Q_PROPERTY( int orientation READ orientation WRITE setOrientation )
49 public: 52 public:
50 /** 53 /**
51 * Constructor. 54 * Constructor.
52 **/ 55 **/
53 OSeparator(QWidget* parent=0, const char* name=0, WFlags f=0); 56 OSeparator(QWidget* parent=0, const char* name=0, WFlags f=0);
54 /** 57 /**
55 * Constructor. 58 * Constructor.
56 * 59 *
57 * @param orientation Set the orientation of the separator. 60 * @param orientation Set the orientation of the separator.
58 * Possible values are HLine or Horizontal and VLine or Vertical. 61 * Possible values are HLine or Horizontal and VLine or Vertical.
59 **/ 62 **/
60 OSeparator(int orientation, QWidget* parent=0, const char* name=0, 63 OSeparator(int orientation, QWidget* parent=0, const char* name=0,
61 WFlags f=0); 64 WFlags f=0);
62 65
63 /** 66 /**
64 * Returns the orientation of the separator. 67 * Returns the orientation of the separator.
65 * 68 *
66 * Possible values are VLine and HLine. 69 * Possible values are VLine and HLine.
67 **/ 70 **/
68 int orientation() const; 71 int orientation() const;
69 72
70 /** 73 /**
71 * Set the orientation of the separator to @p orient 74 * Set the orientation of the separator to @p orient
72 * 75 *
73 * Possible values are VLine and HLine. 76 * Possible values are VLine and HLine.
74 */ 77 */
75 void setOrientation(int orient); 78 void setOrientation(int orient);
76 79
77 /** 80 /**
78 * The recommended height (width) for a horizontal (vertical) separator. 81 * The recommended height (width) for a horizontal (vertical) separator.
79 **/ 82 **/
80 virtual QSize sizeHint() const; 83 virtual QSize sizeHint() const;
81 84
82protected: 85protected:
83 virtual void drawFrame( QPainter * ); 86 virtual void drawFrame( QPainter * );
84 87
85private: 88private:
86 class OSeparatorPrivate* d; 89 class OSeparatorPrivate* d;
87}; 90};
88 91
92}
93}
89 94
90#endif // OSEPARATOR_H 95#endif // OSEPARATOR_H
diff --git a/libopie2/opieui/otabbar.cpp b/libopie2/opieui/otabbar.cpp
index cd3a34b..a62e18b 100644
--- a/libopie2/opieui/otabbar.cpp
+++ b/libopie2/opieui/otabbar.cpp
@@ -1,82 +1,82 @@
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/otabbar.h> 32#include <opie2/otabbar.h>
33 33
34using namespace Opie; 34using namespace Opie::Ui;
35 35
36OTabBar::OTabBar( QWidget *parent , const char *name ) 36OTabBar::OTabBar( QWidget *parent , const char *name )
37 :QTabBar( parent, name ) 37 :QTabBar( parent, name )
38{} 38{}
39 39
40void OTabBar::paintLabel( QPainter* p, const QRect& br, QTab* t, bool has_focus ) const 40void OTabBar::paintLabel( QPainter* p, const QRect& br, QTab* t, bool has_focus ) const
41{ 41{
42 42
43 QRect r = br; 43 QRect r = br;
44 if ( t->iconset) 44 if ( t->iconset)
45 { 45 {
46 QIconSet::Mode mode = (t->enabled && isEnabled()) ? QIconSet::Normal : QIconSet::Disabled; 46 QIconSet::Mode mode = (t->enabled && isEnabled()) ? QIconSet::Normal : QIconSet::Disabled;
47 if ( mode == QIconSet::Normal && has_focus ) 47 if ( mode == QIconSet::Normal && has_focus )
48 { 48 {
49 mode = QIconSet::Active; 49 mode = QIconSet::Active;
50 } 50 }
51 QPixmap pixmap = t->iconset->pixmap( QIconSet::Small, mode ); 51 QPixmap pixmap = t->iconset->pixmap( QIconSet::Small, mode );
52 int pixw = pixmap.width(); 52 int pixw = pixmap.width();
53 int pixh = pixmap.height(); 53 int pixh = pixmap.height();
54 r.setLeft( r.left() + pixw + 2 ); 54 r.setLeft( r.left() + pixw + 2 );
55 p->drawPixmap( br.left()+2, br.center().y()-pixh/2, pixmap ); 55 p->drawPixmap( br.left()+2, br.center().y()-pixh/2, pixmap );
56 } 56 }
57 57
58 QRect tr = r; 58 QRect tr = r;
59 if ( t->id == currentTab() ) 59 if ( t->id == currentTab() )
60 { 60 {
61 tr.setBottom( tr.bottom() - style().defaultFrameWidth() ); 61 tr.setBottom( tr.bottom() - style().defaultFrameWidth() );
62 } 62 }
63 63
64 if ( t->enabled && isEnabled() ) 64 if ( t->enabled && isEnabled() )
65 { 65 {
66 p->setPen( colorGroup().foreground() ); 66 p->setPen( colorGroup().foreground() );
67 p->drawText( tr, AlignCenter | ShowPrefix, t->label ); 67 p->drawText( tr, AlignCenter | ShowPrefix, t->label );
68 } 68 }
69 else if ( style() == MotifStyle ) 69 else if ( style() == MotifStyle )
70 { 70 {
71 p->setPen( palette().disabled().foreground() ); 71 p->setPen( palette().disabled().foreground() );
72 p->drawText( tr, AlignCenter | ShowPrefix, t->label ); 72 p->drawText( tr, AlignCenter | ShowPrefix, t->label );
73 } 73 }
74 else 74 else
75 { 75 {
76 p->setPen( colorGroup().light() ); 76 p->setPen( colorGroup().light() );
77 QRect wr = tr; 77 QRect wr = tr;
78 wr.moveBy( 1, 1 ); 78 wr.moveBy( 1, 1 );
79 p->drawText( wr, AlignCenter | ShowPrefix, t->label ); 79 p->drawText( wr, AlignCenter | ShowPrefix, t->label );
80 p->setPen( palette().disabled().foreground() ); 80 p->setPen( palette().disabled().foreground() );
81 p->drawText( tr, AlignCenter | ShowPrefix, t->label ); 81 p->drawText( tr, AlignCenter | ShowPrefix, t->label );
82 } 82 }
diff --git a/libopie2/opieui/otabbar.h b/libopie2/opieui/otabbar.h
index 2f35c85..925ae96 100644
--- a/libopie2/opieui/otabbar.h
+++ b/libopie2/opieui/otabbar.h
@@ -1,85 +1,86 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3 3
4              Copyright (c) 2002 Dan Williams <williamsdr@acm.org> 4              Copyright (c) 2002 Dan Williams <williamsdr@acm.org>
5 =. 5 =.
6 .=l. 6 .=l.
7           .>+-= 7           .>+-=
8 _;:,     .>    :=|. This program is free software; you can 8 _;:,     .>    :=|. This program is free software; you can
9.> <`_,   >  .   <= redistribute it and/or modify it under 9.> <`_,   >  .   <= redistribute it and/or modify it under
10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
11.="- .-=="i,     .._ License as published by the Free Software 11.="- .-=="i,     .._ License as published by the Free Software
12 - .   .-<_>     .<> Foundation; either version 2 of the License, 12 - .   .-<_>     .<> Foundation; either version 2 of the License,
13     ._= =}       : or (at your option) any later version. 13     ._= =}       : or (at your option) any later version.
14    .%`+i>       _;_. 14    .%`+i>       _;_.
15    .i_,=:_.      -<s. This program is distributed in the hope that 15    .i_,=:_.      -<s. This program is distributed in the hope that
16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
17    : ..    .:,     . . . without even the implied warranty of 17    : ..    .:,     . . . without even the implied warranty of
18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.=       =       ; Library General Public License for more 20..}^=.=       =       ; Library General Public License for more
21++=   -.     .`     .: details. 21++=   -.     .`     .: details.
22 :     =  ...= . :.=- 22 :     =  ...= . :.=-
23 -.   .:....=;==+<; You should have received a copy of the GNU 23 -.   .:....=;==+<; You should have received a copy of the GNU
24  -_. . .   )=.  = Library General Public License along with 24  -_. . .   )=.  = Library General Public License along with
25    --        :-=` this library; see the file COPYING.LIB. 25    --        :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation, 26 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330, 27 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA. 28 Boston, MA 02111-1307, USA.
29 29
30*/ 30*/
31 31
32#ifndef OTABBAR_H 32#ifndef OTABBAR_H
33#define OTABBAR_H 33#define OTABBAR_H
34 34
35/* QT */ 35/* QT */
36#include <qtabbar.h> 36#include <qtabbar.h>
37 37
38namespace Opie 38namespace Opie {
39{ 39namespace Ui {
40 40
41/** 41/**
42 * @class OTabBar 42 * @class OTabBar
43 * @brief The OTabBar class is a derivative of QTabBar. 43 * @brief The OTabBar class is a derivative of QTabBar.
44 * 44 *
45 * OTabBar is a derivation of TrollTech's QTabBar which provides 45 * OTabBar is a derivation of TrollTech's QTabBar which provides
46 * a row of tabs for selection. The only difference between this 46 * a row of tabs for selection. The only difference between this
47 * class and QTabBar is that there is no dotted line box around 47 * class and QTabBar is that there is no dotted line box around
48 * the label of the tab with the current focus. 48 * the label of the tab with the current focus.
49 */ 49 */
50class OTabBar : public QTabBar 50class OTabBar : public QTabBar
51{ 51{
52 Q_OBJECT 52 Q_OBJECT
53 53
54public: 54public:
55 /** 55 /**
56 * @fn OTabBar( QWidget *parent = 0, const char *name = 0 ) 56 * @fn OTabBar( QWidget *parent = 0, const char *name = 0 )
57 * @brief Object constructor. 57 * @brief Object constructor.
58 * 58 *
59 * @param parent Pointer to parent of this control. 59 * @param parent Pointer to parent of this control.
60 * @param name Name of control. 60 * @param name Name of control.
61 * 61 *
62 * Constructs a new OTabBar control with parent and name. 62 * Constructs a new OTabBar control with parent and name.
63 */ 63 */
64 OTabBar( QWidget * = 0, const char * = 0 ); 64 OTabBar( QWidget * = 0, const char * = 0 );
65 65
66protected: 66protected:
67 /** 67 /**
68 * @fn paintLabel( QPainter* p, const QRect& br , QTab* t, bool has_focus)const 68 * @fn paintLabel( QPainter* p, const QRect& br , QTab* t, bool has_focus)const
69 * @brief Internal function to draw a tab's label. 69 * @brief Internal function to draw a tab's label.
70 * 70 *
71 * @param p Pointer to QPainter used for drawing. 71 * @param p Pointer to QPainter used for drawing.
72 * @param br QRect providing region to draw label in. 72 * @param br QRect providing region to draw label in.
73 * @param t Tab to draw label for. 73 * @param t Tab to draw label for.
74 * @param has_focus Boolean value not used, retained for compatibility reasons. 74 * @param has_focus Boolean value not used, retained for compatibility reasons.
75 */ 75 */
76 void paintLabel( QPainter *, const QRect &, QTab *, bool ) const; 76 void paintLabel( QPainter *, const QRect &, QTab *, bool ) const;
77 77
78private: 78private:
79 class Private; 79 class Private;
80 Private *d; 80 Private *d;
81}; 81};
82 82
83}; 83}
84}
84 85
85#endif 86#endif
diff --git a/libopie2/opieui/otabinfo.h b/libopie2/opieui/otabinfo.h
index 4a6ce14..426c45a 100644
--- a/libopie2/opieui/otabinfo.h
+++ b/libopie2/opieui/otabinfo.h
@@ -1,140 +1,141 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3 3
4              Copyright (c) 2002 Dan Williams <williamsdr@acm.org> 4              Copyright (c) 2002 Dan Williams <williamsdr@acm.org>
5 =. 5 =.
6 .=l. 6 .=l.
7           .>+-= 7           .>+-=
8 _;:,     .>    :=|. This program is free software; you can 8 _;:,     .>    :=|. This program is free software; you can
9.> <`_,   >  .   <= redistribute it and/or modify it under 9.> <`_,   >  .   <= redistribute it and/or modify it under
10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
11.="- .-=="i,     .._ License as published by the Free Software 11.="- .-=="i,     .._ License as published by the Free Software
12 - .   .-<_>     .<> Foundation; either version 2 of the License, 12 - .   .-<_>     .<> Foundation; either version 2 of the License,
13     ._= =}       : or (at your option) any later version. 13     ._= =}       : or (at your option) any later version.
14    .%`+i>       _;_. 14    .%`+i>       _;_.
15    .i_,=:_.      -<s. This program is distributed in the hope that 15    .i_,=:_.      -<s. This program is distributed in the hope that
16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
17    : ..    .:,     . . . without even the implied warranty of 17    : ..    .:,     . . . without even the implied warranty of
18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.=       =       ; Library General Public License for more 20..}^=.=       =       ; Library General Public License for more
21++=   -.     .`     .: details. 21++=   -.     .`     .: details.
22 :     =  ...= . :.=- 22 :     =  ...= . :.=-
23 -.   .:....=;==+<; You should have received a copy of the GNU 23 -.   .:....=;==+<; You should have received a copy of the GNU
24  -_. . .   )=.  = Library General Public License along with 24  -_. . .   )=.  = Library General Public License along with
25    --        :-=` this library; see the file COPYING.LIB. 25    --        :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation, 26 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330, 27 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA. 28 Boston, MA 02111-1307, USA.
29 29
30*/ 30*/
31 31
32#ifndef OTABINFO_H 32#ifndef OTABINFO_H
33#define OTABINFO_H 33#define OTABINFO_H
34 34
35/* QT */ 35/* QT */
36#include <qlist.h> 36#include <qlist.h>
37#include <qstring.h> 37#include <qstring.h>
38 38
39class QWidget; 39class QWidget;
40 40
41namespace Opie 41namespace Opie{
42{ 42namespace Ui {
43 43
44/** 44/**
45 * @class OTabInfo 45 * @class OTabInfo
46 * @brief The OTabInfo class is used internally by OTabWidget to keep track 46 * @brief The OTabInfo class is used internally by OTabWidget to keep track
47 * of widgets added to the control. 47 * of widgets added to the control.
48 * 48 *
49 * OTabInfo provides the following information about a widget added to an 49 * OTabInfo provides the following information about a widget added to an
50 * OTabWidget control: 50 * OTabWidget control:
51 * 51 *
52 * ID - integer tab bar ID 52 * ID - integer tab bar ID
53 * Control - QWidget pointer to child widget 53 * Control - QWidget pointer to child widget
54 * Label - QString text label for OTabWidget selection control 54 * Label - QString text label for OTabWidget selection control
55 * Icon - QString name of icon file 55 * Icon - QString name of icon file
56 */ 56 */
57class OTabInfo 57class OTabInfo
58{ 58{
59public: 59public:
60 /** 60 /**
61 * @fn OTabInfo() 61 * @fn OTabInfo()
62 * @brief Object constructor. 62 * @brief Object constructor.
63 * 63 *
64 * @param parent Pointer to parent of this control. 64 * @param parent Pointer to parent of this control.
65 * @param name Name of control. 65 * @param name Name of control.
66 * @param s Style of widget selection control. 66 * @param s Style of widget selection control.
67 * @param p Position of the widget selection control. 67 * @param p Position of the widget selection control.
68 */ 68 */
69 OTabInfo() : i( -1 ), c( 0 ), p( 0 ), l( QString::null ) {} 69 OTabInfo() : i( -1 ), c( 0 ), p( 0 ), l( QString::null ) {}
70 70
71 /** 71 /**
72 * @fn OTabInfo( int id, QWidget *control, const QString &icon, const QString &label ) 72 * @fn OTabInfo( int id, QWidget *control, const QString &icon, const QString &label )
73 * @brief Object constructor. 73 * @brief Object constructor.
74 * 74 *
75 * @param id TabBar identifier for widget. 75 * @param id TabBar identifier for widget.
76 * @param control QWidget pointer to widget. 76 * @param control QWidget pointer to widget.
77 * @param icon QString name of icon file. 77 * @param icon QString name of icon file.
78 * @param label QString text label for OTabWidget selection control. 78 * @param label QString text label for OTabWidget selection control.
79 */ 79 */
80 OTabInfo( int id, QWidget *control, const QString &icon, const QString &label ) 80 OTabInfo( int id, QWidget *control, const QString &icon, const QString &label )
81 : i( id ), c( control ), p( icon ), l( label ) {} 81 : i( id ), c( control ), p( icon ), l( label ) {}
82 82
83 /** 83 /**
84 * @fn id()const 84 * @fn id()const
85 * @brief Returns TabBar ID. 85 * @brief Returns TabBar ID.
86 */ 86 */
87 int id() const { return i; } 87 int id() const { return i; }
88 88
89 /** 89 /**
90 * @fn label()const 90 * @fn label()const
91 * @brief Returns text label for widget. 91 * @brief Returns text label for widget.
92 */ 92 */
93 const QString &label() const { return l; } 93 const QString &label() const { return l; }
94 94
95 /** 95 /**
96 * @fn setLabel( const QString &label ) 96 * @fn setLabel( const QString &label )
97 * @brief Set label for tab. 97 * @brief Set label for tab.
98 * 98 *
99 * @param label QString text label for OTabWidget selection control. 99 * @param label QString text label for OTabWidget selection control.
100 */ 100 */
101 void setLabel( const QString &label ) { l = label; } 101 void setLabel( const QString &label ) { l = label; }
102 102
103 /** 103 /**
104 * @fn control()const 104 * @fn control()const
105 * @brief Returns pointer to widget. 105 * @brief Returns pointer to widget.
106 */ 106 */
107 QWidget *control() const { return c; } 107 QWidget *control() const { return c; }
108 108
109 /** 109 /**
110 * @fn icon()const 110 * @fn icon()const
111 * @brief Returns name of icon file. 111 * @brief Returns name of icon file.
112 */ 112 */
113 const QString &icon() const { return p; } 113 const QString &icon() const { return p; }
114 114
115 /** 115 /**
116 * @fn setIcon( const QString &icon ) 116 * @fn setIcon( const QString &icon )
117 * @brief Set icon for tab. 117 * @brief Set icon for tab.
118 * 118 *
119 * @param icon QString name of icon file. 119 * @param icon QString name of icon file.
120 */ 120 */
121 void setIcon( const QString &icon ) { p = icon; } 121 void setIcon( const QString &icon ) { p = icon; }
122 122
123private: 123private:
124 int i; 124 int i;
125 QWidget *c; 125 QWidget *c;
126 QString p; 126 QString p;
127 QString l; 127 QString l;
128 class Private; 128 class Private;
129 Private *d; 129 Private *d;
130}; 130};
131 131
132/** 132/**
133 * @class OTabInfoList 133 * @class OTabInfoList
134 * @brief A list of OTabInfo objects used by OTabWidget. 134 * @brief A list of OTabInfo objects used by OTabWidget.
135 */ 135 */
136typedef QList<OTabInfo> OTabInfoList; 136typedef QList<OTabInfo> OTabInfoList;
137 137
138}; 138}
139}
139 140
140#endif 141#endif
diff --git a/libopie2/opieui/otabwidget.cpp b/libopie2/opieui/otabwidget.cpp
index f47c90b..a9f7da9 100644
--- a/libopie2/opieui/otabwidget.cpp
+++ b/libopie2/opieui/otabwidget.cpp
@@ -1,92 +1,92 @@
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::Ui;
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
diff --git a/libopie2/opieui/otabwidget.h b/libopie2/opieui/otabwidget.h
index 092f22c..6a64b7d 100644
--- a/libopie2/opieui/otabwidget.h
+++ b/libopie2/opieui/otabwidget.h
@@ -1,97 +1,96 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3              Copyright (C) 2002 Dan Williams <williamsdr@acm.org> 3              Copyright (C) 2002 Dan Williams <williamsdr@acm.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 30
31#ifndef OTABWIDGET_H 31#ifndef OTABWIDGET_H
32#define OTABWIDGET_H 32#define OTABWIDGET_H
33 33
34/* OPIE */ 34/* OPIE */
35#include <opie2/otabinfo.h> 35#include <opie2/otabinfo.h>
36 36
37/* QT */ 37/* QT */
38#include <qwidget.h> 38#include <qwidget.h>
39#include <qlist.h> 39#include <qlist.h>
40 40
41using namespace Opie;
42 41
43class QComboBox; 42class QComboBox;
44class QPixmap; 43class QPixmap;
45class QTabBar; 44class QTabBar;
46class QWidgetStack; 45class QWidgetStack;
47 46
48namespace Opie 47namespace Opie {
49{ 48namespace Ui {
50 49
51class OTabBar; 50class OTabBar;
52 51
53/** 52/**
54 * @class OTabWidget 53 * @class OTabWidget
55 * @brief The OTabWidget class provides a stack of widgets. 54 * @brief The OTabWidget class provides a stack of widgets.
56 * 55 *
57 * OTabWidget is a derivation of TrollTech's QTabWidget which provides 56 * OTabWidget is a derivation of TrollTech's QTabWidget which provides
58 * a stack of widgets. Widgets can be selected using either a tab bar or 57 * a stack of widgets. Widgets can be selected using either a tab bar or
59 * drop down list box. 58 * drop down list box.
60 * 59 *
61 * The normal way to use OTabWidget is to do the following in the 60 * The normal way to use OTabWidget is to do the following in the
62 * constructor: 61 * constructor:
63 * - Create a OTabWidget. 62 * - Create a OTabWidget.
64 * - Create a QWidget for each of the pages in the control, insert 63 * - Create a QWidget for each of the pages in the control, insert
65 * children into it, set up geometry management for it, and use addTab() 64 * children into it, set up geometry management for it, and use addTab()
66 * to add the widget. 65 * to add the widget.
67 */ 66 */
68class OTabWidget : public QWidget 67class OTabWidget : public QWidget
69{ 68{
70 Q_OBJECT 69 Q_OBJECT
71 70
72 public: 71 public:
73/** 72/**
74 * @enum TabStyle 73 * @enum TabStyle
75 * @brief Defines how the widget selection control is displayed. 74 * @brief Defines how the widget selection control is displayed.
76 * 75 *
77 * Valid values: 76 * Valid values:
78 * - Global: use globally selected options (qpe.conf - TabStyle & TabPosition) 77 * - Global: use globally selected options (qpe.conf - TabStyle & TabPosition)
79 * - TextTab: Tabbed widget selection with text labels 78 * - TextTab: Tabbed widget selection with text labels
80 * - IconTab: Tabbed widget selection with icon labels, text label for active widget 79 * - IconTab: Tabbed widget selection with icon labels, text label for active widget
81 * (similar to Opie launcher) 80 * (similar to Opie launcher)
82 * - TextList: Drop down list widget selection with text labels 81 * - TextList: Drop down list widget selection with text labels
83 * - IconList: Drop down list widget selection with icon & text labels 82 * - IconList: Drop down list widget selection with icon & text labels
84 */ 83 */
85 enum TabStyle { Global, TextTab, IconTab, TextList, IconList }; 84 enum TabStyle { Global, TextTab, IconTab, TextList, IconList };
86 85
87/** 86/**
88 * @enum TabPosition 87 * @enum TabPosition
89 * @brief Defines where the widget selection control is drawn. 88 * @brief Defines where the widget selection control is drawn.
90 * 89 *
91 * Valid values: 90 * Valid values:
92 * - Top: Widget selection control is drawn above widgets 91 * - Top: Widget selection control is drawn above widgets
93 * - Bottom: Widget selection control is drawn below widgets 92 * - Bottom: Widget selection control is drawn below widgets
94 */ 93 */
95 enum TabPosition { Top, Bottom }; 94 enum TabPosition { Top, Bottom };
96 95
97/** 96/**
@@ -242,51 +241,52 @@ private:
242 * 241 *
243 * @param name Name of icon image file. 242 * @param name Name of icon image file.
244 */ 243 */
245 QPixmap loadSmooth( const QString & ); 244 QPixmap loadSmooth( const QString & );
246 245
247/** 246/**
248 * @fn selectTab( OTabInfo *tab ) 247 * @fn selectTab( OTabInfo *tab )
249 * @brief Internal function to select desired widget. 248 * @brief Internal function to select desired widget.
250 * 249 *
251 * @param tab Pointer to data for widget. 250 * @param tab Pointer to data for widget.
252 */ 251 */
253 void selectTab( OTabInfo * ); 252 void selectTab( OTabInfo * );
254 253
255/** 254/**
256 * @fn setUpLayout() 255 * @fn setUpLayout()
257 * @brief Internal function to adjust layout. 256 * @brief Internal function to adjust layout.
258 */ 257 */
259 void setUpLayout(); 258 void setUpLayout();
260 259
261 260
262 signals: 261 signals:
263/** 262/**
264 * @fn currentChanegd( QWidget *widget ) 263 * @fn currentChanegd( QWidget *widget )
265 * @brief This signal is emitted whenever the widget has changed. 264 * @brief This signal is emitted whenever the widget has changed.
266 * 265 *
267 * @param widget Pointer to new current widget. 266 * @param widget Pointer to new current widget.
268 */ 267 */
269 void currentChanged( QWidget * ); 268 void currentChanged( QWidget * );
270 269
271 private slots: 270 private slots:
272 271
273/** 272/**
274 * @fn slotTabBarSelected( int id ) 273 * @fn slotTabBarSelected( int id )
275 * @brief Slot which is called when a tab is selected. 274 * @brief Slot which is called when a tab is selected.
276 * 275 *
277 * @param id ID of widget selected. 276 * @param id ID of widget selected.
278 */ 277 */
279 void slotTabBarSelected( int ); 278 void slotTabBarSelected( int );
280 279
281/** 280/**
282 * @fn slotTabListSelected( int index ) 281 * @fn slotTabListSelected( int index )
283 * @brief Slot which is called when a drop down selection is made. 282 * @brief Slot which is called when a drop down selection is made.
284 * 283 *
285 * @param id Index of widget selected. 284 * @param id Index of widget selected.
286 */ 285 */
287 void slotTabListSelected( int ); 286 void slotTabListSelected( int );
288}; 287};
289 288
290}; 289}
290}
291 291
292#endif 292#endif
diff --git a/libopie2/opieui/otaskbarapplet.cpp b/libopie2/opieui/otaskbarapplet.cpp
index a67356d..b5268f0 100644
--- a/libopie2/opieui/otaskbarapplet.cpp
+++ b/libopie2/opieui/otaskbarapplet.cpp
@@ -1,32 +1,82 @@
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 <mickey@tm.informatik.uni-frankfurt.de> 4              Copyright (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
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#include <opie2/otaskbarapplet.h>
32
33#include <qpe/qpeapplication.h>
34#include <qframe.h>
35
36using namespace Opie::Ui;
37
38
39/**
40 * \todo no example yet!!!
41 * If you want to implement an Applet for the Opie Taskbar
42 * use this interface.
43 * The only specail thing about applets is that you need to build
44 * it as plugin/library and do EXPORT_OPIE_APPLET_v1( YourApplet )
45 * at the bottom of your application. This takes care of
46 * the activation and implementing the TaskbarAppletInterface.
47 * You also need to add a static int position() functions to your
48 * application.
49 * \code
50 * class MyApplet : public OTaskBarApplet {
51 * public:
52 * static int position() { return 3: }
53 * void doStuff() {
54 * popup( myWidget );
55 * }
56 * };
57 * EXPORT_OPIE_APPLET_v1( MyApplet )
58 * \endcode
59 *
60 * @author Michael Lauer
61 * @version 0.5
62 * @see TaskbarAppletInterface
63 */
64OTaskbarApplet::OTaskbarApplet( QWidget* parent, const char* name )
65 :QWidget( parent, name ){
66 setFixedHeight( 18 );
67 setFixedWidth( 14 );
68}
69
70OTaskbarApplet::~OTaskbarApplet(){
71}
72
73void OTaskbarApplet::popup( QWidget* widget ){
74 QPoint curPos = mapToGlobal( QPoint( 0, 0 ) );
75 int w = widget->sizeHint().width();
76 int x = curPos.x() - (w/2 );
77 if ( (x+w) > QPEApplication::desktop()->width() )
78 x = QPEApplication::desktop()->width()-w;
79 widget->move( x, curPos.y()-widget->sizeHint().height() );
80 widget->show();
81}
31 82
32// Empty on purpose until we shipped Opie 1.0 (see otaskbarapplet.h for explanation)
diff --git a/libopie2/opieui/otaskbarapplet.h b/libopie2/opieui/otaskbarapplet.h
index 074367f..0c85ee7 100644
--- a/libopie2/opieui/otaskbarapplet.h
+++ b/libopie2/opieui/otaskbarapplet.h
@@ -1,130 +1,129 @@
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 <mickey@tm.informatik.uni-frankfurt.de> 4              Copyright (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
5 =. 5 =.
6 .=l. 6 .=l.
7           .>+-= 7           .>+-=
8 _;:,     .>    :=|. This program is free software; you can 8 _;:,     .>    :=|. This program is free software; you can
9.> <`_,   >  .   <= redistribute it and/or modify it under 9.> <`_,   >  .   <= redistribute it and/or modify it under
10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
11.="- .-=="i,     .._ License as published by the Free Software 11.="- .-=="i,     .._ License as published by the Free Software
12 - .   .-<_>     .<> Foundation; either version 2 of the License, 12 - .   .-<_>     .<> Foundation; either version 2 of the License,
13     ._= =}       : or (at your option) any later version. 13     ._= =}       : or (at your option) any later version.
14    .%`+i>       _;_. 14    .%`+i>       _;_.
15    .i_,=:_.      -<s. This program is distributed in the hope that 15    .i_,=:_.      -<s. This program is distributed in the hope that
16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
17    : ..    .:,     . . . without even the implied warranty of 17    : ..    .:,     . . . without even the implied warranty of
18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.=       =       ; Library General Public License for more 20..}^=.=       =       ; Library General Public License for more
21++=   -.     .`     .: details. 21++=   -.     .`     .: details.
22 :     =  ...= . :.=- 22 :     =  ...= . :.=-
23 -.   .:....=;==+<; You should have received a copy of the GNU 23 -.   .:....=;==+<; You should have received a copy of the GNU
24  -_. . .   )=.  = Library General Public License along with 24  -_. . .   )=.  = Library General Public License along with
25    --        :-=` this library; see the file COPYING.LIB. 25    --        :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation, 26 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330, 27 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA. 28 Boston, MA 02111-1307, USA.
29 29
30*/ 30*/
31 31
32#ifndef OTASKBARAPPLET_H 32#ifndef OTASKBARAPPLET_H
33#define OTASKBARAPPLET_H 33#define OTASKBARAPPLET_H
34 34
35#include <qpe/taskbarappletinterface.h> 35#include <qpe/taskbarappletinterface.h>
36#include <qpe/qcom.h>
36 37
38#include <qwidget.h>
39
40class QMouseEvent;
41
42namespace Opie {
43namespace Ui {
44namespace Private {
37/*====================================================================================== 45/*======================================================================================
38 * OTaskbarAppletWrapper 46 * OTaskbarAppletWrapper
39 *======================================================================================*/ 47 *======================================================================================*/
40 48
49class OTaskbarAppletWrapperPrivate;
41template<class T> class OTaskbarAppletWrapper : public TaskbarAppletInterface 50template<class T> class OTaskbarAppletWrapper : public TaskbarAppletInterface
42{ 51{
43 public: 52 public:
44 OTaskbarAppletWrapper():_applet( 0 ) 53 OTaskbarAppletWrapper():_applet( 0 )
45 { 54 {
46 } 55 }
47 56
48 virtual ~OTaskbarAppletWrapper() 57 virtual ~OTaskbarAppletWrapper()
49 { 58 {
50 delete _applet; 59 delete _applet;
51 } 60 }
52 61
53 QRESULT queryInterface( const QUuid& uuid, QUnknownInterface** iface ) 62 QRESULT queryInterface( const QUuid& uuid, QUnknownInterface** iface )
54 { 63 {
55 qDebug( "OTaskbarAppletWrapper::queryInterface()" ); 64 qDebug( "OTaskbarAppletWrapper::queryInterface()" );
56 *iface = 0; 65 *iface = 0;
57 if ( uuid == IID_QUnknown ) 66 if ( uuid == IID_QUnknown )
58 *iface = this; 67 *iface = this;
59 else if ( uuid == IID_TaskbarApplet ) 68 else if ( uuid == IID_TaskbarApplet )
60 *iface = this; 69 *iface = this;
61 else 70 else
62 return QS_FALSE; 71 return QS_FALSE;
63 72
64 if ( *iface ) (*iface)->addRef(); 73 if ( *iface ) (*iface)->addRef();
65 return QS_OK; 74 return QS_OK;
66 } 75 }
67 76
68 Q_REFCOUNT 77 Q_REFCOUNT
69 78
70 virtual T* applet( QWidget* parent ) 79 virtual T* applet( QWidget* parent )
71 { 80 {
72 if ( !_applet ) _applet = new T( parent ); 81 if ( !_applet ) _applet = new T( parent );
73 return _applet; 82 return _applet;
74 } 83 }
75 84
76 virtual int position() const 85 virtual int position() const
77 { 86 {
78 return T::position(); 87 return T::position();
79 } 88 }
80 89
81 private: 90 private:
82 T* _applet; 91 T* _applet;
92 OTaskbarAppletWrapperPrivate *d;
83}; 93};
84 94
85#include <qframe.h> 95}
86#include <qwidget.h>
87#include <qpe/qpeapplication.h>
88
89class QMouseEvent;
90
91/*====================================================================================== 96/*======================================================================================
92 * OTaskbarApplet 97 * OTaskbarApplet
93 *======================================================================================*/ 98 *======================================================================================*/
94 99
95// Must be inline until after we shipped Opie 1.0 100// Must be inline until after we shipped Opie 1.0
96 101
97// Having OTaskBarApplet reside in libopieui2 is not possible 102// Having OTaskBarApplet reside in libopieui2 is not possible
98// until we link the launcher binary against libopieui2 - 103// until we link the launcher binary against libopieui2 -
99// otherwise the necessary symbols are not present, when 104// otherwise the necessary symbols are not present, when
100// the dynamic loader [dlopen] tries to resolve an applet which 105// the dynamic loader [dlopen] tries to resolve an applet which
101// inherits OTaskbarApplet 106// inherits OTaskbarApplet
102 107
103class OTaskbarApplet : public QWidget 108class OTaskbarApplet : public QWidget
104{ 109{
105 public: 110 public:
106 OTaskbarApplet( QWidget* parent, const char* name = 0 ):QWidget( parent, name ) 111 OTaskbarApplet( QWidget* parent, const char* name = 0 );
107 { 112 virtual ~OTaskbarApplet();
108 setFixedHeight( 18 );
109 setFixedWidth( 14 );
110 }
111
112 virtual ~OTaskbarApplet()
113 {
114 }
115 113
116 protected: 114 protected:
117 virtual void popup( QWidget* widget ) 115 virtual void popup( QWidget* widget );
118 { 116private:
119 QPoint curPos = mapToGlobal( QPoint( 0, 0 ) ); 117 class Private;
120 int w = widget->sizeHint().width(); 118 Private *d;
121 int x = curPos.x() - (w/2 );
122 if ( (x+w) > QPEApplication::desktop()->width() )
123 x = QPEApplication::desktop()->width()-w;
124 widget->move( x, curPos.y()-widget->sizeHint().height() );
125 widget->show();
126 }
127}; 119};
120}
121}
122
123#define EXPORT_OPIE_APPLET_v1( AppLet ) \
124 Q_EXPORT_INTERFACE() { \
125 Q_CREATE_INSTANCE( Opie::Ui::Private::OTaskbarAppletWrapper<AppLet> ) \
126 }
128 127
129#endif 128#endif
130 129
diff --git a/libopie2/opieui/otimepicker.cpp b/libopie2/opieui/otimepicker.cpp
index 66f9ce0..7de0fd3 100644
--- a/libopie2/opieui/otimepicker.cpp
+++ b/libopie2/opieui/otimepicker.cpp
@@ -1,85 +1,89 @@
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 29
30/* OPIE */
31#include <opie2/otimepicker.h>
32
30/* QT */ 33/* QT */
34#include <qgroupbox.h>
31#include <qlayout.h> 35#include <qlayout.h>
32#include <qlineedit.h> 36#include <qlineedit.h>
33 37
34/* OPIE */
35#include <opie2/otimepicker.h>
36 38
37using namespace Opie; 39
40namespace Opie {
41namespace Ui {
38 42
39/** 43/**
40 * Constructs the widget 44 * Constructs the widget
41 * @param parent The parent of the OTimePicker 45 * @param parent The parent of the OTimePicker
42 * @param name The name of the object 46 * @param name The name of the object
43 * @param fl Window Flags 47 * @param fl Window Flags
44 */ 48 */
45OTimePicker::OTimePicker(QWidget* parent, const char* name, Qt::WFlags fl) 49OTimePicker::OTimePicker(QWidget* parent, const char* name, Qt::WFlags fl)
46 :QWidget(parent,name,fl) 50 :QWidget(parent,name,fl)
47{ 51{
48 QVBoxLayout *vbox=new QVBoxLayout(this); 52 QVBoxLayout *vbox=new QVBoxLayout(this);
49 53
50 OClickableLabel *r; 54 OClickableLabel *r;
51 QString s; 55 QString s;
52 56
53 // Hour Row 57 // Hour Row
54 QWidget *row=new QWidget(this); 58 QWidget *row=new QWidget(this);
55 QHBoxLayout *l=new QHBoxLayout(row); 59 QHBoxLayout *l=new QHBoxLayout(row);
56 vbox->addWidget(row); 60 vbox->addWidget(row);
57 61
58 for (int i=0; i<24; i++) 62 for (int i=0; i<24; i++)
59 { 63 {
60 r=new OClickableLabel(row); 64 r=new OClickableLabel(row);
61 hourLst.append(r); 65 hourLst.append(r);
62 s.sprintf("%.2d",i); 66 s.sprintf("%.2d",i);
63 r->setText(s); 67 r->setText(s);
64 r->setToggleButton(true); 68 r->setToggleButton(true);
65 r->setAlignment(AlignHCenter | AlignVCenter); 69 r->setAlignment(AlignHCenter | AlignVCenter);
66 l->addWidget(r); 70 l->addWidget(r);
67 connect(r, SIGNAL(toggled(bool)), 71 connect(r, SIGNAL(toggled(bool)),
68 this, SLOT(slotHour(bool))); 72 this, SLOT(slotHour(bool)));
69 73
70 if (i==11) 74 if (i==11)
71 { // Second row 75 { // Second row
72 row=new QWidget(this); 76 row=new QWidget(this);
73 l=new QHBoxLayout(row); 77 l=new QHBoxLayout(row);
74 vbox->addWidget(row); 78 vbox->addWidget(row);
75 } 79 }
76 } 80 }
77 81
78 // Minute Row 82 // Minute Row
79 row=new QWidget(this); 83 row=new QWidget(this);
80 l=new QHBoxLayout(row); 84 l=new QHBoxLayout(row);
81 vbox->addWidget(row); 85 vbox->addWidget(row);
82 86
83 for (int i=0; i<60; i+=5) 87 for (int i=0; i<60; i+=5)
84 { 88 {
85 r=new OClickableLabel(row); 89 r=new OClickableLabel(row);
@@ -175,118 +179,123 @@ void OTimePicker::setTime( int h, int m )
175 * Method to set the minutes 179 * Method to set the minutes
176 * @param m minutes 180 * @param m minutes
177 */ 181 */
178void OTimePicker::setMinute(int m) 182void OTimePicker::setMinute(int m)
179{ 183{
180 184
181 QString minute; 185 QString minute;
182 minute.sprintf("%.2d",m); 186 minute.sprintf("%.2d",m);
183 187
184 QValueListIterator<OClickableLabel *> it; 188 QValueListIterator<OClickableLabel *> it;
185 for (it=minuteLst.begin(); it!=minuteLst.end(); it++) 189 for (it=minuteLst.begin(); it!=minuteLst.end(); it++)
186 { 190 {
187 if ((*it)->text() == minute) (*it)->setOn(true); 191 if ((*it)->text() == minute) (*it)->setOn(true);
188 else (*it)->setOn(false); 192 else (*it)->setOn(false);
189 } 193 }
190 194
191 tm.setHMS(tm.hour(),m,0); 195 tm.setHMS(tm.hour(),m,0);
192} 196}
193 197
194/** 198/**
195 * Method to set the hour 199 * Method to set the hour
196 */ 200 */
197void OTimePicker::setHour(int h) 201void OTimePicker::setHour(int h)
198{ 202{
199 203
200 QString hour; 204 QString hour;
201 hour.sprintf("%.2d",h); 205 hour.sprintf("%.2d",h);
202 206
203 QValueListIterator<OClickableLabel *> it; 207 QValueListIterator<OClickableLabel *> it;
204 for (it=hourLst.begin(); it!=hourLst.end(); it++) 208 for (it=hourLst.begin(); it!=hourLst.end(); it++)
205 { 209 {
206 if ((*it)->text() == hour) (*it)->setOn(true); 210 if ((*it)->text() == hour) (*it)->setOn(true);
207 else (*it)->setOn(false); 211 else (*it)->setOn(false);
208 } 212 }
209 tm.setHMS(h,tm.minute(),0); 213 tm.setHMS(h,tm.minute(),0);
210} 214}
211 215
212 216
213/** 217/**
214 * This is a modal Dialog. 218 * This is a modal Dialog.
215 * 219 *
216 * @param parent The parent widget 220 * @param parent The parent widget
217 * @param name The name of the object 221 * @param name The name of the object
218 * @param fl Possible window flags 222 * @param fl Possible window flags
219 */ 223 */
220OTimePickerDialog::OTimePickerDialog ( QWidget* parent, const char* name, WFlags fl ) 224OTimePickerDialog::OTimePickerDialog ( QWidget* parent, const char* name, WFlags fl )
221 : OTimePickerDialogBase (parent , name, true , fl) 225 : OTimePickerDialogBase (parent , name, true , fl)
222{ 226{
227 m_timePicker = new OTimePicker( GroupBox1, "m_timePicker" );
228 GroupBox1Layout->addWidget( m_timePicker, 0, 0 );
223 229
224 connect ( m_timePicker, SIGNAL( timeChanged(const QTime&) ), 230 connect ( m_timePicker, SIGNAL( timeChanged(const QTime&) ),
225 this, SLOT( setTime(const QTime&) ) ); 231 this, SLOT( setTime(const QTime&) ) );
226 connect ( minuteField, SIGNAL( textChanged(const QString&) ), 232 connect ( minuteField, SIGNAL( textChanged(const QString&) ),
227 this, SLOT ( setMinute(const QString&) ) ); 233 this, SLOT ( setMinute(const QString&) ) );
228 connect ( hourField, SIGNAL( textChanged(const QString&) ), 234 connect ( hourField, SIGNAL( textChanged(const QString&) ),
229 this, SLOT ( setHour(const QString&) ) ); 235 this, SLOT ( setHour(const QString&) ) );
230 236
231} 237}
232 238
233/** 239/**
234 * @return the time 240 * @return the time
235 */ 241 */
236QTime OTimePickerDialog::time()const 242QTime OTimePickerDialog::time()const
237{ 243{
238 return m_time; 244 return m_time;
239} 245}
240 246
241/** 247/**
242 * Set the time to time 248 * Set the time to time
243 * @param time The time to be set 249 * @param time The time to be set
244 */ 250 */
245void OTimePickerDialog::setTime( const QTime& time ) 251void OTimePickerDialog::setTime( const QTime& time )
246{ 252{
247 m_time = time; 253 m_time = time;
248 254
249 m_timePicker->setHour ( time.hour() ); 255 m_timePicker->setHour ( time.hour() );
250 m_timePicker->setMinute( time.minute() ); 256 m_timePicker->setMinute( time.minute() );
251 257
252 // Set Textfields 258 // Set Textfields
253 if ( time.hour() < 10 ) 259 if ( time.hour() < 10 )
254 hourField->setText( "0" + QString::number( time.hour() ) ); 260 hourField->setText( "0" + QString::number( time.hour() ) );
255 else 261 else
256 hourField->setText( QString::number( time.hour() ) ); 262 hourField->setText( QString::number( time.hour() ) );
257 263
258 if ( time.minute() < 10 ) 264 if ( time.minute() < 10 )
259 minuteField->setText( "0" + QString::number( time.minute() ) ); 265 minuteField->setText( "0" + QString::number( time.minute() ) );
260 else 266 else
261 minuteField->setText( QString::number( time.minute() ) ); 267 minuteField->setText( QString::number( time.minute() ) );
262 268
263} 269}
264 270
265/** 271/**
266 * This method takes the current minute and tries to set hour 272 * This method takes the current minute and tries to set hour
267 * to hour. This succeeds if the resulting date is valid 273 * to hour. This succeeds if the resulting date is valid
268 * @param hour The hour as a string 274 * @param hour The hour as a string
269 */ 275 */
270void OTimePickerDialog::setHour ( const QString& hour ) 276void OTimePickerDialog::setHour ( const QString& hour )
271{ 277{
272 if ( QTime::isValid ( hour.toInt(), m_time.minute() , 00 ) ) 278 if ( QTime::isValid ( hour.toInt(), m_time.minute() , 00 ) )
273 { 279 {
274 m_time.setHMS ( hour.toInt(), m_time.minute() , 00 ); 280 m_time.setHMS ( hour.toInt(), m_time.minute() , 00 );
275 setTime ( m_time ); 281 setTime ( m_time );
276 } 282 }
277 283
278} 284}
279 285
280/** 286/**
281 * Method to set a new minute. It tries to convert the string to int and 287 * 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. 288 * if the resulting date is valid a new date is set.
283 * @see setHour 289 * @see setHour
284 */ 290 */
285void OTimePickerDialog::setMinute ( const QString& minute ) 291void OTimePickerDialog::setMinute ( const QString& minute )
286{ 292{
287 if ( QTime::isValid ( m_time.hour(), minute.toInt(), 00 ) ) 293 if ( QTime::isValid ( m_time.hour(), minute.toInt(), 00 ) )
288 { 294 {
289 m_time.setHMS ( m_time.hour(), minute.toInt(), 00 ); 295 m_time.setHMS ( m_time.hour(), minute.toInt(), 00 );
290 setTime ( m_time ); 296 setTime ( m_time );
291 } 297 }
292} 298}
299
300}
301}
diff --git a/libopie2/opieui/otimepicker.h b/libopie2/opieui/otimepicker.h
index 2da7773..01bb557 100644
--- a/libopie2/opieui/otimepicker.h
+++ b/libopie2/opieui/otimepicker.h
@@ -1,125 +1,132 @@
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 29
30#ifndef OTIMEPICKER_H 30#ifndef OTIMEPICKER_H
31#define OTIMEPICKER_H 31#define OTIMEPICKER_H
32 32
33/* OPIE */ 33/* OPIE */
34#include <opie2/oclickablelabel.h> 34#include <opie2/oclickablelabel.h>
35#include "otimepickerbase.h" 35#include <opie2/otimepickerbase.h>
36 36
37/* QT */ 37/* QT */
38#include <qwidget.h> 38#include <qwidget.h>
39#include <qvaluelist.h> 39#include <qvaluelist.h>
40#include <qdatetime.h> 40#include <qdatetime.h>
41#include <qdialog.h> 41#include <qdialog.h>
42 42
43using namespace Opie;
44 43
45// namespace Opie 44namespace Opie {
46// { 45namespace Ui {
47 46
48/** 47/**
49 * A class to pick time. It uses clickable labels 48 * A class to pick time. It uses clickable labels
50 * internally to allow a quick selection of a time. 49 * internally to allow a quick selection of a time.
51 * A time can be selected by two clicks of a user 50 * A time can be selected by two clicks of a user
52 * 51 *
53 * @short A widget to quickly pick a QTime 52 * @short A widget to quickly pick a QTime
54 * @version 1.0 53 * @version 1.0
55 * @see QWidget 54 * @see QWidget
56 * @see QTime 55 * @see QTime
57 * @author Hakan Ardo, Stefan Eilers 56 * @author Hakan Ardo, Stefan Eilers
58 */ 57 */
59class OTimePicker: public QWidget 58class OTimePicker : public QWidget
60{ 59{
61 Q_OBJECT 60 Q_OBJECT
62 61
63public: 62public:
64 OTimePicker(QWidget* parent = 0, const char* name = 0, WFlags fl = 0); 63 OTimePicker(QWidget* parent = 0, const char* name = 0, WFlags fl = 0);
65 64
66public slots: 65public slots:
67 void setHour(int h); 66 void setHour(int h);
68 void setMinute(int m); 67 void setMinute(int m);
69 void setTime( const QTime& ); 68 void setTime( const QTime& );
70 void setTime( int h, int m ); 69 void setTime( int h, int m );
71 70
72public: 71public:
73 QTime time()const; 72 QTime time()const;
74 73
75private: 74private:
76 QValueList<OClickableLabel *> hourLst; 75 QValueList<OClickableLabel *> hourLst;
77 QValueList<OClickableLabel *> minuteLst; 76 QValueList<OClickableLabel *> minuteLst;
78 QTime tm; 77 QTime tm;
79 struct Private; 78 struct Private;
80 Private *d; 79 Private *d;
81 80
82private slots: 81private slots:
83 void slotHour(bool b); 82 void slotHour(bool b);
84 void slotMinute(bool b); 83 void slotMinute(bool b);
85 84
86signals: 85signals:
87 /** 86 /**
88 * gets emitted when the time got changed by the user 87 * gets emitted when the time got changed by the user
89 */ 88 */
90 void timeChanged(const QTime &); 89 void timeChanged(const QTime &);
91}; 90};
92 91
93/** 92/**
94 * 93 *
95 * @short A small dialog to pick a time 94 * @short A small dialog to pick a time
96 * @version 1.0 95 * @version 1.0
97 * @author Stefan Eilers 96 * @author Stefan Eilers
98 * 97 *
99 **/ 98 **/
100 99
101class OTimePickerDialog: public OTimePickerDialogBase 100class OTimePickerDialog: public OTimePickerDialogBase
102{ 101{
103 Q_OBJECT 102 Q_OBJECT
104 103
105public: 104public:
106 OTimePickerDialog ( QWidget* parent = 0, const char* name = NULL, WFlags fl = 0 ); 105 OTimePickerDialog ( QWidget* parent = 0, const char* name = NULL, WFlags fl = 0 );
107 ~OTimePickerDialog() { }; 106 ~OTimePickerDialog() { };
108 107
109 QTime time()const; 108 QTime time()const;
110 109
111public slots: 110public slots:
112 void setTime( const QTime& time ); 111 void setTime( const QTime& time );
113 void setHour( const QString& hour ); 112 void setHour( const QString& hour );
114 void setMinute( const QString& minute ); 113 void setMinute( const QString& minute );
115 114
116private: 115private:
116 OTimePicker *m_timePicker;
117 QTime m_time; 117 QTime m_time;
118 class Private; 118 class Private;
119 Private* d; 119 Private* d;
120}; 120};
121 121
122// }; 122}
123}
123 124
125/* for Qt2 */
126#if ( QT_VERSION-0 >= 0x030000 )
127#error "Fix the UI File to use namespaces"
128#else
129typedef Opie::Ui::OTimePicker OUIOTimePicker;
130#endif
124#endif 131#endif
125 132
diff --git a/libopie2/opieui/otimepickerbase.ui b/libopie2/opieui/otimepickerbase.ui
index 3e7f2fb..c2eb7c5 100644
--- a/libopie2/opieui/otimepickerbase.ui
+++ b/libopie2/opieui/otimepickerbase.ui
@@ -1,62 +1,62 @@
1<!DOCTYPE UI><UI> 1<!DOCTYPE UI><UI>
2<class>OTimePickerDialogBase</class> 2<class>OTimePickerDialogBase</class>
3<widget> 3<widget>
4 <class>QDialog</class> 4 <class>QDialog</class>
5 <property stdset="1"> 5 <property stdset="1">
6 <name>name</name> 6 <name>name</name>
7 <cstring>OTimePickerDialogBase</cstring> 7 <cstring>OTimePickerDialogBase</cstring>
8 </property> 8 </property>
9 <property stdset="1"> 9 <property stdset="1">
10 <name>geometry</name> 10 <name>geometry</name>
11 <rect> 11 <rect>
12 <x>0</x> 12 <x>0</x>
13 <y>0</y> 13 <y>0</y>
14 <width>210</width> 14 <width>182</width>
15 <height>137</height> 15 <height>137</height>
16 </rect> 16 </rect>
17 </property> 17 </property>
18 <property stdset="1"> 18 <property stdset="1">
19 <name>sizePolicy</name> 19 <name>sizePolicy</name>
20 <sizepolicy> 20 <sizepolicy>
21 <hsizetype>3</hsizetype> 21 <hsizetype>3</hsizetype>
22 <vsizetype>1</vsizetype> 22 <vsizetype>1</vsizetype>
23 </sizepolicy> 23 </sizepolicy>
24 </property> 24 </property>
25 <property stdset="1"> 25 <property stdset="1">
26 <name>caption</name> 26 <name>caption</name>
27 <string>OTimePickerDialogBase</string> 27 <string>OTimePickerDialogBase</string>
28 </property> 28 </property>
29 <property> 29 <property>
30 <name>layoutMargin</name> 30 <name>layoutMargin</name>
31 </property> 31 </property>
32 <property> 32 <property>
33 <name>layoutSpacing</name> 33 <name>layoutSpacing</name>
34 </property> 34 </property>
35 <vbox> 35 <vbox>
36 <property stdset="1"> 36 <property stdset="1">
37 <name>margin</name> 37 <name>margin</name>
38 <number>5</number> 38 <number>5</number>
39 </property> 39 </property>
40 <property stdset="1"> 40 <property stdset="1">
41 <name>spacing</name> 41 <name>spacing</name>
42 <number>4</number> 42 <number>4</number>
43 </property> 43 </property>
44 <widget> 44 <widget>
45 <class>QFrame</class> 45 <class>QFrame</class>
46 <property stdset="1"> 46 <property stdset="1">
47 <name>name</name> 47 <name>name</name>
48 <cstring>Frame10</cstring> 48 <cstring>Frame10</cstring>
49 </property> 49 </property>
50 <property stdset="1"> 50 <property stdset="1">
51 <name>sizePolicy</name> 51 <name>sizePolicy</name>
52 <sizepolicy> 52 <sizepolicy>
53 <hsizetype>1</hsizetype> 53 <hsizetype>1</hsizetype>
54 <vsizetype>7</vsizetype> 54 <vsizetype>7</vsizetype>
55 </sizepolicy> 55 </sizepolicy>
56 </property> 56 </property>
57 <property stdset="1"> 57 <property stdset="1">
58 <name>frameShape</name> 58 <name>frameShape</name>
59 <enum>NoFrame</enum> 59 <enum>NoFrame</enum>
60 </property> 60 </property>
61 <property stdset="1"> 61 <property stdset="1">
62 <name>frameShadow</name> 62 <name>frameShadow</name>
@@ -204,89 +204,53 @@
204 <property stdset="1"> 204 <property stdset="1">
205 <name>orientation</name> 205 <name>orientation</name>
206 <enum>Horizontal</enum> 206 <enum>Horizontal</enum>
207 </property> 207 </property>
208 <property stdset="1"> 208 <property stdset="1">
209 <name>sizeType</name> 209 <name>sizeType</name>
210 <enum>MinimumExpanding</enum> 210 <enum>MinimumExpanding</enum>
211 </property> 211 </property>
212 <property> 212 <property>
213 <name>sizeHint</name> 213 <name>sizeHint</name>
214 <size> 214 <size>
215 <width>20</width> 215 <width>20</width>
216 <height>20</height> 216 <height>20</height>
217 </size> 217 </size>
218 </property> 218 </property>
219 </spacer> 219 </spacer>
220 </hbox> 220 </hbox>
221 </widget> 221 </widget>
222 <widget> 222 <widget>
223 <class>QGroupBox</class> 223 <class>QGroupBox</class>
224 <property stdset="1"> 224 <property stdset="1">
225 <name>name</name> 225 <name>name</name>
226 <cstring>GroupBox1</cstring> 226 <cstring>GroupBox1</cstring>
227 </property> 227 </property>
228 <property stdset="1"> 228 <property stdset="1">
229 <name>sizePolicy</name> 229 <name>sizePolicy</name>
230 <sizepolicy> 230 <sizepolicy>
231 <hsizetype>3</hsizetype> 231 <hsizetype>3</hsizetype>
232 <vsizetype>3</vsizetype> 232 <vsizetype>3</vsizetype>
233 </sizepolicy> 233 </sizepolicy>
234 </property> 234 </property>
235 <property stdset="1"> 235 <property stdset="1">
236 <name>margin</name> 236 <name>margin</name>
237 <number>0</number> 237 <number>0</number>
238 </property> 238 </property>
239 <property stdset="1"> 239 <property stdset="1">
240 <name>title</name> 240 <name>title</name>
241 <string>Pick Time:</string> 241 <string>Pick Time:</string>
242 </property> 242 </property>
243 <grid> 243 <grid>
244 <property stdset="1"> 244 <property stdset="1">
245 <name>margin</name> 245 <name>margin</name>
246 <number>11</number> 246 <number>11</number>
247 </property> 247 </property>
248 <property stdset="1"> 248 <property stdset="1">
249 <name>spacing</name> 249 <name>spacing</name>
250 <number>6</number> 250 <number>6</number>
251 </property> 251 </property>
252 <widget row="0" column="0" >
253 <class>OTimePicker</class>
254 <property stdset="1">
255 <name>name</name>
256 <cstring>m_timePicker</cstring>
257 </property>
258 <property stdset="1">
259 <name>sizePolicy</name>
260 <sizepolicy>
261 <hsizetype>3</hsizetype>
262 <vsizetype>3</vsizetype>
263 </sizepolicy>
264 </property>
265 </widget>
266 </grid> 252 </grid>
267 </widget> 253 </widget>
268 </vbox> 254 </vbox>
269</widget> 255</widget>
270<customwidgets>
271 <customwidget>
272 <class>OTimePicker</class>
273 <header location="local">otimepicker.h</header>
274 <sizehint>
275 <width>-1</width>
276 <height>-1</height>
277 </sizehint>
278 <container>0</container>
279 <sizepolicy>
280 <hordata>7</hordata>
281 <verdata>1</verdata>
282 </sizepolicy>
283 <pixmap>image0</pixmap>
284 </customwidget>
285</customwidgets>
286<images>
287 <image>
288 <name>image0</name>
289 <data format="XPM.GZ" length="646">789c6dd2c10ac2300c00d07bbf2234b7229d1ddec44f503c0ae2a154410f53d0ed20e2bf6bdb656dd6861dd23d9a66591b0587fd1654235ebded6f0edcd53e419d87ae7b1f4f9b8f906d0bfe012317426a70b07bdc2f3ec77f8ed6b89559061a0343d06a124cc105596482585094bc0ae599b04646c9018926491b2205e140c485cace25755c175d0a967b622ff900b8cc9c7d29af594ea722d589167f813aa852ba07d94b9dce296e883fe7bb163f23896753</data>
290 </image>
291</images>
292</UI> 256</UI>
diff --git a/libopie2/opieui/oversatileview.cpp b/libopie2/opieui/oversatileview.cpp
index 78154b7..f6c6410 100644
--- a/libopie2/opieui/oversatileview.cpp
+++ b/libopie2/opieui/oversatileview.cpp
@@ -1,269 +1,272 @@
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
43using namespace Opie::Core;
44using namespace Opie::Ui;
45
43/* XPM */ 46/* XPM */
44static const char * view_icon_xpm[] = { 47static const char * view_icon_xpm[] = {
45"16 16 16 1", 48"16 16 16 1",
46 " c None", 49 " c None",
47 ".c #87BD88", 50 ".c #87BD88",
48 "+c #8BBE8B", 51 "+c #8BBE8B",
49 "@c #81BA81", 52 "@c #81BA81",
50 "#c #6DAF6D", 53 "#c #6DAF6D",
51 "$c #87BD87", 54 "$c #87BD87",
52 "%c #FCFDFC", 55 "%c #FCFDFC",
53 "&c #AED0AE", 56 "&c #AED0AE",
54 "*c #4E9C4C", 57 "*c #4E9C4C",
55 "=c #91BD91", 58 "=c #91BD91",
56 "-c #72B172", 59 "-c #72B172",
57 ";c #448643", 60 ";c #448643",
58 ">c #519F50", 61 ">c #519F50",
59 ",c #499247", 62 ",c #499247",
60 "'c #356A35", 63 "'c #356A35",
61 ")c #686868", 64 ")c #686868",
62" ", 65" ",
63" .+@# .+@# ", 66" .+@# .+@# ",
64" $%&* $%&* ", 67" $%&* $%&* ",
65" @=-; @=-; ", 68" @=-; @=-; ",
66" #>,' #>,' ", 69" #>,' #>,' ",
67" ", 70" ",
68" )))))) )))))) ", 71" )))))) )))))) ",
69" ", 72" ",
70" ", 73" ",
71" .+@# .+@# ", 74" .+@# .+@# ",
72" $%&* $%&* ", 75" $%&* $%&* ",
73" @=-; @=-; ", 76" @=-; @=-; ",
74" #>,' #>,' ", 77" #>,' #>,' ",
75" ", 78" ",
76" )))))) )))))) ", 79" )))))) )))))) ",
77" "}; 80" "};
78 81
79/* XPM */ 82/* XPM */
80static const char * view_tree_xpm[] = { 83static const char * view_tree_xpm[] = {
81"16 16 17 1", 84"16 16 17 1",
82 " c None", 85 " c None",
83 ".c #3A3A3A", 86 ".c #3A3A3A",
84 "+c #87BD88", 87 "+c #87BD88",
85 "@c #8BBE8B", 88 "@c #8BBE8B",
86 "#c #81BA81", 89 "#c #81BA81",
87 "$c #6DAF6D", 90 "$c #6DAF6D",
88 "%c #87BD87", 91 "%c #87BD87",
89 "&c #FCFDFC", 92 "&c #FCFDFC",
90 "*c #AED0AE", 93 "*c #AED0AE",
91 "=c #4E9C4C", 94 "=c #4E9C4C",
92 "-c #91BD91", 95 "-c #91BD91",
93 ";c #72B172", 96 ";c #72B172",
94 ">c #448643", 97 ">c #448643",
95 ",c #686868", 98 ",c #686868",
96 "'c #519F50", 99 "'c #519F50",
97 ")c #499247", 100 ")c #499247",
98 "!c #356A35", 101 "!c #356A35",
99" . ", 102" . ",
100" . ", 103" . ",
101" . +@#$ ", 104" . +@#$ ",
102" . %&*= ", 105" . %&*= ",
103" .. #-;> ,, ,,,", 106" .. #-;> ,, ,,,",
104" . $')! ", 107" . $')! ",
105" . ", 108" . ",
106" . ", 109" . ",
107" . ", 110" . ",
108" . +@#$ ", 111" . +@#$ ",
109" . %&*= ", 112" . %&*= ",
110" .. #-;> ,, ,,,", 113" .. #-;> ,, ,,,",
111" $')! ", 114" $')! ",
112" ", 115" ",
113" ", 116" ",
114" "}; 117" "};
115 118
116OVersatileView::OVersatileView( QWidget* parent, const char* name, int mode ) 119OVersatileView::OVersatileView( QWidget* parent, const char* name, int mode )
117 :QWidgetStack( parent, name ), 120 :QWidgetStack( parent, name ),
118 _viewmode( mode ), _warningpolicy( None ), 121 _viewmode( mode ), _warningpolicy( None ),
119 _treeleaf(), _treeopened(), _treeclosed(), 122 _treeleaf(), _treeopened(), _treeclosed(),
120 _iconleaf(), _iconopened(), _iconclosed() 123 _iconleaf(), _iconopened(), _iconclosed()
121{ 124{
122 // 125 //
123 // Create child widgets and set some reasonable default styles 126 // Create child widgets and set some reasonable default styles
124 // 127 //
125 128
126 _listview = new OListView( this, "oversatileview embedded listview" ); 129 _listview = new OListView( this, "oversatileview embedded listview" );
127 _iconview = new QIconView( this, "oversatileview embedded iconview" ); 130 _iconview = new QIconView( this, "oversatileview embedded iconview" );
128 131
129 _listview->setAllColumnsShowFocus( true ); 132 _listview->setAllColumnsShowFocus( true );
130 _listview->setRootIsDecorated( true ); 133 _listview->setRootIsDecorated( true );
131 _listview->setShowSortIndicator( true ); 134 _listview->setShowSortIndicator( true );
132 _iconview->setGridX( 90 ); 135 _iconview->setGridX( 90 );
133 _iconview->setGridY( 42 ); 136 _iconview->setGridY( 42 );
134 _iconview->setAutoArrange( true ); 137 _iconview->setAutoArrange( true );
135 138
136 #ifdef QWS // TODO: Let this depend on current geometry (rotation) 139 #ifdef QWS // TODO: Let this depend on current geometry (rotation)
137 _iconview->setArrangement( QIconView::TopToBottom ); 140 _iconview->setArrangement( QIconView::TopToBottom );
138 #else 141 #else
139 _iconview->setArrangement( QIconView::LeftToRight ); 142 _iconview->setArrangement( QIconView::LeftToRight );
140 #endif 143 #endif
141 144
142 _iconview->setResizeMode( QIconView::Adjust ); 145 _iconview->setResizeMode( QIconView::Adjust );
143 146
144 // qt-embedded: map stylus right on hold to right button press 147 // qt-embedded: map stylus right on hold to right button press
145 148
146 #ifdef QWS 149 #ifdef QWS
147 ( (QPEApplication*) qApp)->setStylusOperation( _iconview->viewport(), QPEApplication::RightOnHold ); 150 ( (QPEApplication*) qApp)->setStylusOperation( _iconview->viewport(), QPEApplication::RightOnHold );
148 ( (QPEApplication*) qApp)->setStylusOperation( _listview->viewport(), QPEApplication::RightOnHold ); 151 ( (QPEApplication*) qApp)->setStylusOperation( _listview->viewport(), QPEApplication::RightOnHold );
149 #endif 152 #endif
150 153
151 setViewMode( mode ); // TODO: Read last style from config 154 setViewMode( mode ); // TODO: Read last style from config
152 // setSynchronization( true ); // TODO: Implement this 155 // setSynchronization( true ); // TODO: Implement this
153 156
154 // create context menu allowing to switch between the views 157 // create context menu allowing to switch between the views
155 158
156 _contextmenu = new QPopupMenu( 0, "oversatileview contextmenu" ); 159 _contextmenu = new QPopupMenu( 0, "oversatileview contextmenu" );
157 _contextmenu->setCaption( "Style" ); 160 _contextmenu->setCaption( "Style" );
158 _contextmenu->setCheckable( true ); 161 _contextmenu->setCheckable( true );
159 QActionGroup* ag = new QActionGroup( _contextmenu, "style option group" ); 162 QActionGroup* ag = new QActionGroup( _contextmenu, "style option group" );
160 QAction* a1 = new QAction( "View Items in Icon Style", QIconSet( QPixmap( view_icon_xpm ) ), 163 QAction* a1 = new QAction( "View Items in Icon Style", QIconSet( QPixmap( view_icon_xpm ) ),
161 "View Icons", 0, ag, "viewicon action", true ); 164 "View Icons", 0, ag, "viewicon action", true );
162 QAction* a2 = new QAction( "View Items in Tree Style", QIconSet( QPixmap( view_tree_xpm ) ), 165 QAction* a2 = new QAction( "View Items in Tree Style", QIconSet( QPixmap( view_tree_xpm ) ),
163 "View Tree", 0, ag, "viewtree action", true ); 166 "View Tree", 0, ag, "viewtree action", true );
164 ag->addTo( _contextmenu ); 167 ag->addTo( _contextmenu );
165 if ( mode == Icons ) 168 if ( mode == Icons )
166 a1->setOn( true ); 169 a1->setOn( true );
167 else if ( mode == Tree ) 170 else if ( mode == Tree )
168 a2->setOn( true ); 171 a2->setOn( true );
169 connect( a1, SIGNAL( activated() ), this, SLOT( setIconViewMode() ) ); 172 connect( a1, SIGNAL( activated() ), this, SLOT( setIconViewMode() ) );
170 connect( a2, SIGNAL( activated() ), this, SLOT( setTreeViewMode() ) ); 173 connect( a2, SIGNAL( activated() ), this, SLOT( setTreeViewMode() ) );
171 174
172 #if (QT_VERSION >= 0x030000) 175 #if (QT_VERSION >= 0x030000)
173 connect( _listview, SIGNAL( contextMenuRequested(QListViewItem*,const QPoint&,int) ), this, SLOT( contextMenuRequested(QListViewItem*,const QPoint&,int) ) ); 176 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&) ) ); 177 connect( _iconview, SIGNAL( contextMenuRequested(QIconViewItem*,const QPoint&) ), this, SLOT( contextMenuRequested(QIconViewItem*,const QPoint&) ) );
175 #else 178 #else
176 connect( _listview, SIGNAL( rightButtonPressed(QListViewItem*,const QPoint&,int) ), this, SLOT( contextMenuRequested(QListViewItem*,const QPoint&,int) ) ); 179 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&) ) ); 180 connect( _iconview, SIGNAL( rightButtonPressed(QIconViewItem*,const QPoint&) ), this, SLOT( contextMenuRequested(QIconViewItem*,const QPoint&) ) );
178 #endif 181 #endif
179 182
180 // 183 //
181 // signal forwarders 184 // signal forwarders
182 // 185 //
183 // unfortunately we can't short-circuit all the QListView and QIconView signals 186 // unfortunately we can't short-circuit all the QListView and QIconView signals
184 // to OVersatileView signals, because the signal/slot mechanism doesn't allow 187 // to OVersatileView signals, because the signal/slot mechanism doesn't allow
185 // type-conversion :-( 188 // type-conversion :-(
186 189
187 // common signals for listview 190 // common signals for listview
188 191
189 connect( _listview, SIGNAL( selectionChanged() ), this, SIGNAL( selectionChanged() ) ); 192 connect( _listview, SIGNAL( selectionChanged() ), this, SIGNAL( selectionChanged() ) );
190 connect( _listview, SIGNAL( selectionChanged(QListViewItem*) ), this, SLOT( selectionChanged(QListViewItem*) ) ); 193 connect( _listview, SIGNAL( selectionChanged(QListViewItem*) ), this, SLOT( selectionChanged(QListViewItem*) ) );
191 connect( _listview, SIGNAL( currentChanged(QListViewItem*) ), this, SLOT( currentChanged(QListViewItem*) ) ); 194 connect( _listview, SIGNAL( currentChanged(QListViewItem*) ), this, SLOT( currentChanged(QListViewItem*) ) );
192 connect( _listview, SIGNAL( clicked(QListViewItem*) ), this, SLOT( clicked(QListViewItem*) ) ); 195 connect( _listview, SIGNAL( clicked(QListViewItem*) ), this, SLOT( clicked(QListViewItem*) ) );
193 connect( _listview, SIGNAL( pressed(QListViewItem*) ), this, SLOT( pressed(QListViewItem*) ) ); 196 connect( _listview, SIGNAL( pressed(QListViewItem*) ), this, SLOT( pressed(QListViewItem*) ) );
194 197
195 connect( _listview, SIGNAL( doubleClicked(QListViewItem*) ), this, SLOT( doubleClicked(QListViewItem*) ) ); 198 connect( _listview, SIGNAL( doubleClicked(QListViewItem*) ), this, SLOT( doubleClicked(QListViewItem*) ) );
196 connect( _listview, SIGNAL( returnPressed(QListViewItem*) ), this, SLOT( returnPressed(QListViewItem*) ) ); 199 connect( _listview, SIGNAL( returnPressed(QListViewItem*) ), this, SLOT( returnPressed(QListViewItem*) ) );
197 200
198 connect( _listview, SIGNAL( onItem(QListViewItem*) ), this, SLOT( onItem(QListViewItem*) ) ); 201 connect( _listview, SIGNAL( onItem(QListViewItem*) ), this, SLOT( onItem(QListViewItem*) ) );
199 connect( _listview, SIGNAL( onViewport() ), this, SIGNAL( onViewport() ) ); 202 connect( _listview, SIGNAL( onViewport() ), this, SIGNAL( onViewport() ) );
200 203
201 // common signals for iconview 204 // common signals for iconview
202 205
203 connect( _iconview, SIGNAL( selectionChanged() ), this, SIGNAL( selectionChanged() ) ); 206 connect( _iconview, SIGNAL( selectionChanged() ), this, SIGNAL( selectionChanged() ) );
204 connect( _iconview, SIGNAL( selectionChanged(QIconViewItem*) ), this, SLOT( selectionChanged(QIconViewItem*) ) ); 207 connect( _iconview, SIGNAL( selectionChanged(QIconViewItem*) ), this, SLOT( selectionChanged(QIconViewItem*) ) );
205 connect( _iconview, SIGNAL( currentChanged(QIconViewItem*) ), this, SLOT( currentChanged(QIconViewItem*) ) ); 208 connect( _iconview, SIGNAL( currentChanged(QIconViewItem*) ), this, SLOT( currentChanged(QIconViewItem*) ) );
206 connect( _iconview, SIGNAL( clicked(QIconViewItem*) ), this, SLOT( clicked(QIconViewItem*) ) ); 209 connect( _iconview, SIGNAL( clicked(QIconViewItem*) ), this, SLOT( clicked(QIconViewItem*) ) );
207 connect( _iconview, SIGNAL( pressed(QIconViewItem*) ), this, SLOT( pressed(QIconViewItem*) ) ); 210 connect( _iconview, SIGNAL( pressed(QIconViewItem*) ), this, SLOT( pressed(QIconViewItem*) ) );
208 211
209 connect( _iconview, SIGNAL( doubleClicked(QIconViewItem*) ), this, SLOT( doubleClicked(QIconViewItem*) ) ); 212 connect( _iconview, SIGNAL( doubleClicked(QIconViewItem*) ), this, SLOT( doubleClicked(QIconViewItem*) ) );
210 connect( _iconview, SIGNAL( returnPressed(QIconViewItem*) ), this, SLOT( returnPressed(QIconViewItem*) ) ); 213 connect( _iconview, SIGNAL( returnPressed(QIconViewItem*) ), this, SLOT( returnPressed(QIconViewItem*) ) );
211 214
212 connect( _iconview, SIGNAL( onItem(QIconViewItem*) ), this, SLOT( onItem(QIconViewItem*) ) ); 215 connect( _iconview, SIGNAL( onItem(QIconViewItem*) ), this, SLOT( onItem(QIconViewItem*) ) );
213 connect( _iconview, SIGNAL( onViewport() ), this, SIGNAL( onViewport() ) ); 216 connect( _iconview, SIGNAL( onViewport() ), this, SIGNAL( onViewport() ) );
214 217
215 // listview only signals 218 // listview only signals
216 219
217 connect( _listview, SIGNAL( expanded(QListViewItem*) ), this, SLOT( expanded(QListViewItem*) ) ); 220 connect( _listview, SIGNAL( expanded(QListViewItem*) ), this, SLOT( expanded(QListViewItem*) ) );
218 connect( _listview, SIGNAL( collapsed(QListViewItem*) ), this, SLOT( collapsed(QListViewItem*) ) ); 221 connect( _listview, SIGNAL( collapsed(QListViewItem*) ), this, SLOT( collapsed(QListViewItem*) ) );
219 222
220 // iconview only signals 223 // iconview only signals
221 224
222 connect( _iconview, SIGNAL( moved() ), this, SIGNAL( moved() ) ); 225 connect( _iconview, SIGNAL( moved() ), this, SIGNAL( moved() ) );
223} 226}
224 227
225OVersatileView::~OVersatileView() 228OVersatileView::~OVersatileView()
226{ 229{
227} 230}
228 231
229QPopupMenu* OVersatileView::contextMenu() const 232QPopupMenu* OVersatileView::contextMenu() const
230{ 233{
231 return _contextmenu; 234 return _contextmenu;
232} 235}
233 236
234void OVersatileView::contextMenuRequested( QListViewItem* item, const QPoint& pos, int col ) 237void OVersatileView::contextMenuRequested( QListViewItem* item, const QPoint& pos, int col )
235{ 238{
236 // can't use QObject::inherits here, because ListViewItems, beit Q, O or K, 239 // can't use QObject::inherits here, because ListViewItems, beit Q, O or K,
237 // do not inherit from QObject - assuming here the programmer is 240 // do not inherit from QObject - assuming here the programmer is
238 // disciplined enough to only add OVersatileViewItems to an OVersatileView 241 // disciplined enough to only add OVersatileViewItems to an OVersatileView
239 popupContextMenu( static_cast<OVersatileViewItem*>( item ), pos, col ); 242 popupContextMenu( static_cast<OVersatileViewItem*>( item ), pos, col );
240} 243}
241 244
242void OVersatileView::contextMenuRequested( QIconViewItem* item, const QPoint& pos ) 245void OVersatileView::contextMenuRequested( QIconViewItem* item, const QPoint& pos )
243{ 246{
244 // see above 247 // see above
245 popupContextMenu( static_cast<OVersatileViewItem*>( item ), pos, -1 ); 248 popupContextMenu( static_cast<OVersatileViewItem*>( item ), pos, -1 );
246} 249}
247 250
248void OVersatileView::popupContextMenu( OVersatileViewItem* item, const QPoint& pos, int col ) 251void OVersatileView::popupContextMenu( OVersatileViewItem* item, const QPoint& pos, int col )
249{ 252{
250 if ( !item ) 253 if ( !item )
251 _contextmenu->exec( pos ); 254 _contextmenu->exec( pos );
252 else 255 else
253 emit( contextMenuRequested( item, pos, col ) ); 256 emit( contextMenuRequested( item, pos, col ) );
254} 257}
255 258
256void OVersatileView::setSynchronization( bool sync ) 259void OVersatileView::setSynchronization( bool sync )
257{ 260{
258 _synchronization = sync; 261 _synchronization = sync;
259} 262}
260 263
261bool OVersatileView::synchronization() 264bool OVersatileView::synchronization()
262{ 265{
263 return _synchronization; 266 return _synchronization;
264} 267}
265 268
266void OVersatileView::setDefaultPixmaps( int mode, QPixmap& leaf, QPixmap& opened, QPixmap& closed ) 269void OVersatileView::setDefaultPixmaps( int mode, QPixmap& leaf, QPixmap& opened, QPixmap& closed )
267{ 270{
268 if ( mode == Tree ) 271 if ( mode == Tree )
269 { 272 {
@@ -375,130 +378,130 @@ void OVersatileView::selectionChanged( QIconViewItem * item )
375{ 378{
376 emit( selectionChanged( static_cast<OVersatileViewItem*>( item ) ) ); 379 emit( selectionChanged( static_cast<OVersatileViewItem*>( item ) ) );
377} 380}
378 381
379void OVersatileView::currentChanged( QListViewItem * item ) 382void OVersatileView::currentChanged( QListViewItem * item )
380{ 383{
381 emit( currentChanged( static_cast<OVersatileViewItem*>( item ) ) ); 384 emit( currentChanged( static_cast<OVersatileViewItem*>( item ) ) );
382} 385}
383 386
384void OVersatileView::currentChanged( QIconViewItem * item ) 387void OVersatileView::currentChanged( QIconViewItem * item )
385{ 388{
386 emit( currentChanged( static_cast<OVersatileViewItem*>( item ) ) ); 389 emit( currentChanged( static_cast<OVersatileViewItem*>( item ) ) );
387} 390}
388 391
389void OVersatileView::clicked( QListViewItem * item ) 392void OVersatileView::clicked( QListViewItem * item )
390{ 393{
391 emit( clicked( static_cast<OVersatileViewItem*>( item ) ) ); 394 emit( clicked( static_cast<OVersatileViewItem*>( item ) ) );
392} 395}
393 396
394void OVersatileView::clicked( QIconViewItem * item ) 397void OVersatileView::clicked( QIconViewItem * item )
395{ 398{
396 emit( clicked( static_cast<OVersatileViewItem*>( item ) ) ); 399 emit( clicked( static_cast<OVersatileViewItem*>( item ) ) );
397} 400}
398 401
399void OVersatileView::pressed( QListViewItem * item ) 402void OVersatileView::pressed( QListViewItem * item )
400{ 403{
401 emit( pressed( static_cast<OVersatileViewItem*>( item ) ) ); 404 emit( pressed( static_cast<OVersatileViewItem*>( item ) ) );
402} 405}
403 406
404void OVersatileView::pressed( QIconViewItem * item ) 407void OVersatileView::pressed( QIconViewItem * item )
405{ 408{
406 emit( pressed( static_cast<OVersatileViewItem*>( item ) ) ); 409 emit( pressed( static_cast<OVersatileViewItem*>( item ) ) );
407} 410}
408 411
409void OVersatileView::doubleClicked( QListViewItem * item ) 412void OVersatileView::doubleClicked( QListViewItem * item )
410{ 413{
411 emit( doubleClicked( static_cast<OVersatileViewItem*>( item ) ) ); 414 emit( doubleClicked( static_cast<OVersatileViewItem*>( item ) ) );
412} 415}
413 416
414void OVersatileView::doubleClicked( QIconViewItem * item ) 417void OVersatileView::doubleClicked( QIconViewItem * item )
415{ 418{
416 emit( doubleClicked( static_cast<OVersatileViewItem*>( item ) ) ); 419 emit( doubleClicked( static_cast<OVersatileViewItem*>( item ) ) );
417} 420}
418 421
419void OVersatileView::returnPressed( QListViewItem * item ) 422void OVersatileView::returnPressed( QListViewItem * item )
420{ 423{
421 emit( returnPressed( static_cast<OVersatileViewItem*>( item ) ) ); 424 emit( returnPressed( static_cast<OVersatileViewItem*>( item ) ) );
422} 425}
423 426
424void OVersatileView::returnPressed( QIconViewItem * item ) 427void OVersatileView::returnPressed( QIconViewItem * item )
425{ 428{
426 emit( returnPressed( static_cast<OVersatileViewItem*>( item ) ) ); 429 emit( returnPressed( static_cast<OVersatileViewItem*>( item ) ) );
427} 430}
428 431
429void OVersatileView::onItem( QListViewItem * item ) 432void OVersatileView::onItem( QListViewItem * item )
430{ 433{
431 emit( onItem( static_cast<OVersatileViewItem*>( item ) ) ); 434 emit( onItem( static_cast<OVersatileViewItem*>( item ) ) );
432} 435}
433 436
434void OVersatileView::onItem( QIconViewItem * item ) 437void OVersatileView::onItem( QIconViewItem * item )
435{ 438{
436 emit( onItem( static_cast<OVersatileViewItem*>( item ) ) ); 439 emit( onItem( static_cast<OVersatileViewItem*>( item ) ) );
437} 440}
438 441
439void OVersatileView::expanded( QListViewItem *item ) // QListView 442void OVersatileView::expanded( QListViewItem *item ) // QListView
440{ 443{
441 //odebug << "OVersatileView::expanded(): opening tree..." << oendl; 444 //odebug << "OVersatileView::expanded(): opening tree..." << oendl;
442 if ( !_treeopened.isNull() ) 445 if ( !_treeopened.isNull() )
443 item->setPixmap( 0, _treeopened ); 446 item->setPixmap( 0, _treeopened );
444 emit( expanded( static_cast<OVersatileViewItem*>( item ) ) ); 447 emit( expanded( static_cast<OVersatileViewItem*>( item ) ) );
445} 448}
446void OVersatileView::collapsed( QListViewItem *item ) // QListView 449void OVersatileView::collapsed( QListViewItem *item ) // QListView
447{ 450{
448 if ( !_treeclosed.isNull() ) 451 if ( !_treeclosed.isNull() )
449 item->setPixmap( 0, _treeclosed ); 452 item->setPixmap( 0, _treeclosed );
450 emit( collapsed( static_cast<OVersatileViewItem*>( item ) ) ); 453 emit( collapsed( static_cast<OVersatileViewItem*>( item ) ) );
451} 454}
452 455
453//=============================================================================================// 456//=============================================================================================//
454// OVersatileView Case I - API only existing in QListView or QIconView but not in both! 457// OVersatileView Case I - API only existing in QListView or QIconView but not in both!
455//==============================================================================================// 458//==============================================================================================//
456 459
457int OVersatileView::treeStepSize() const // QListView 460int OVersatileView::treeStepSize() const // QListView
458{ 461{
459 if ( !isValidViewMode( Tree ) ) 462 if ( !isValidViewMode( Tree ) )
460 { 463 {
461 return -1; 464 return -1;
462 } 465 }
463 return _listview->treeStepSize(); 466 return _listview->treeStepSize();
464} 467}
465 void OVersatileView::setTreeStepSize( int size ) // QListView 468 void OVersatileView::setTreeStepSize( int size ) // QListView
466{ 469{
467 if ( !isValidViewMode( Tree ) ) 470 if ( !isValidViewMode( Tree ) )
468 { 471 {
469 return; 472 return;
470 } 473 }
471 _listview->setTreeStepSize( size ); 474 _listview->setTreeStepSize( size );
472} 475}
473 476
474QHeader * OVersatileView::header() const // QListView 477QHeader * OVersatileView::header() const // QListView
475{ 478{
476 if ( !isValidViewMode( Tree ) ) 479 if ( !isValidViewMode( Tree ) )
477 { 480 {
478 return 0; 481 return 0;
479 } 482 }
480 return _listview->header(); 483 return _listview->header();
481} 484}
482 485
483 int OVersatileView::addColumn( const QString &label, int size ) // QListView 486 int OVersatileView::addColumn( const QString &label, int size ) // QListView
484{ 487{
485 if ( !isValidViewMode( Tree ) ) 488 if ( !isValidViewMode( Tree ) )
486 { 489 {
487 return -1; 490 return -1;
488 } 491 }
489 return _listview->addColumn( label, size ); 492 return _listview->addColumn( label, size );
490} 493}
491 494
492 int OVersatileView::addColumn( const QIconSet& iconset, const QString &label, int size ) // QListView 495 int OVersatileView::addColumn( const QIconSet& iconset, const QString &label, int size ) // QListView
493{ 496{
494 if ( !isValidViewMode( Tree ) ) 497 if ( !isValidViewMode( Tree ) )
495 { 498 {
496 return -1; 499 return -1;
497 } 500 }
498 return _listview->addColumn( iconset, label, size ); 501 return _listview->addColumn( iconset, label, size );
499} 502}
500 503
501void OVersatileView::removeColumn( int index ) // QListView 504void OVersatileView::removeColumn( int index ) // QListView
502{ 505{
503 if ( !isValidViewMode( Tree ) ) 506 if ( !isValidViewMode( Tree ) )
504 { 507 {
@@ -700,97 +703,97 @@ int OVersatileView::itemMargin() const // QListView
700} 703}
701 704
702 void OVersatileView::setRootIsDecorated( bool decorate ) // QListView 705 void OVersatileView::setRootIsDecorated( bool decorate ) // QListView
703{ 706{
704 if ( !isValidViewMode( Tree ) ) 707 if ( !isValidViewMode( Tree ) )
705 { 708 {
706 return; 709 return;
707 } 710 }
708 _listview->setRootIsDecorated( decorate ); 711 _listview->setRootIsDecorated( decorate );
709} 712}
710bool OVersatileView::rootIsDecorated() const // QListView 713bool OVersatileView::rootIsDecorated() const // QListView
711{ 714{
712 if ( !isValidViewMode( Tree ) ) 715 if ( !isValidViewMode( Tree ) )
713 { 716 {
714 return false; 717 return false;
715 } 718 }
716 return _listview->rootIsDecorated(); 719 return _listview->rootIsDecorated();
717} 720}
718 721
719void OVersatileView::setShowSortIndicator( bool show ) // QListView 722void OVersatileView::setShowSortIndicator( bool show ) // QListView
720{ 723{
721 if ( !isValidViewMode( Tree ) ) 724 if ( !isValidViewMode( Tree ) )
722 { 725 {
723 return; 726 return;
724 } 727 }
725 _listview->setShowSortIndicator( show ); 728 _listview->setShowSortIndicator( show );
726} 729}
727bool OVersatileView::showSortIndicator() const // QListView 730bool OVersatileView::showSortIndicator() const // QListView
728{ 731{
729 if ( !isValidViewMode( Tree ) ) 732 if ( !isValidViewMode( Tree ) )
730 { 733 {
731 return false; 734 return false;
732 } 735 }
733 return _listview->showSortIndicator(); 736 return _listview->showSortIndicator();
734} 737}
735 738
736void OVersatileView::triggerUpdate() // QListView 739void OVersatileView::triggerUpdate() // QListView
737{ 740{
738 if ( !isValidViewMode( Tree ) ) 741 if ( !isValidViewMode( Tree ) )
739 { 742 {
740 return; 743 return;
741 } 744 }
742 _listview->triggerUpdate(); 745 _listview->triggerUpdate();
743} 746}
744 747
745// 748//
746// only in QIconView 749// only in QIconView
747// 750//
748 751
749uint OVersatileView::count() const // QIconView 752uint OVersatileView::count() const // QIconView
750{ 753{
751 if ( !isValidViewMode( Icons ) ) 754 if ( !isValidViewMode( Icons ) )
752 { 755 {
753 return 0; 756 return 0;
754 } 757 }
755 return _iconview->count(); 758 return _iconview->count();
756} 759}
757 760
758int OVersatileView::index( const OVersatileViewItem *item ) const // QIconView 761int OVersatileView::index( const OVersatileViewItem *item ) const // QIconView
759{ 762{
760 if ( !isValidViewMode( Icons ) ) 763 if ( !isValidViewMode( Icons ) )
761 { 764 {
762 return -1; 765 return -1;
763 } 766 }
764 return _iconview->index( item ); 767 return _iconview->index( item );
765} 768}
766 769
767OVersatileViewItem* OVersatileView::firstItem() const // QIconView 770OVersatileViewItem* OVersatileView::firstItem() const // QIconView
768{ 771{
769 if ( !isValidViewMode( Icons ) ) 772 if ( !isValidViewMode( Icons ) )
770 { 773 {
771 return 0; 774 return 0;
772 } 775 }
773 return static_cast<OVersatileViewItem*>( _iconview->firstItem() ); 776 return static_cast<OVersatileViewItem*>( _iconview->firstItem() );
774} 777}
775OVersatileViewItem* OVersatileView::lastItem() const // QIconView 778OVersatileViewItem* OVersatileView::lastItem() const // QIconView
776{ 779{
777 if ( !isValidViewMode( Icons ) ) 780 if ( !isValidViewMode( Icons ) )
778 { 781 {
779 return 0; 782 return 0;
780 } 783 }
781 return static_cast<OVersatileViewItem*>( _iconview->lastItem() ); 784 return static_cast<OVersatileViewItem*>( _iconview->lastItem() );
782} 785}
783 786
784OVersatileViewItem* OVersatileView::findItem( const QPoint &pos ) const // QIconView 787OVersatileViewItem* OVersatileView::findItem( const QPoint &pos ) const // QIconView
785{ 788{
786 if ( !isValidViewMode( Icons ) ) 789 if ( !isValidViewMode( Icons ) )
787 { 790 {
788 return 0; 791 return 0;
789 } 792 }
790 return static_cast<OVersatileViewItem*>( _iconview->findItem( pos ) ); 793 return static_cast<OVersatileViewItem*>( _iconview->findItem( pos ) );
791} 794}
792OVersatileViewItem* OVersatileView::findItem( const QString &text ) const // QIconView 795OVersatileViewItem* OVersatileView::findItem( const QString &text ) const // QIconView
793{ 796{
794 if ( !isValidViewMode( Icons ) ) 797 if ( !isValidViewMode( Icons ) )
795 { 798 {
796 return 0; 799 return 0;
diff --git a/libopie2/opieui/oversatileview.h b/libopie2/opieui/oversatileview.h
index 8af21dc..61b61db 100644
--- a/libopie2/opieui/oversatileview.h
+++ b/libopie2/opieui/oversatileview.h
@@ -1,394 +1,399 @@
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#ifndef OVERSATILEVIEW_H 31#ifndef OVERSATILEVIEW_H
32#define OVERSATILEVIEW_H 32#define OVERSATILEVIEW_H
33 33
34/* QT */ 34/* QT */
35 35
36#include <qwidgetstack.h> 36#include <qwidgetstack.h>
37#include <qiconview.h> 37#include <qiconview.h>
38 38
39/* OPIE */ 39/* OPIE */
40 40
41#include <opie2/oapplication.h> 41#include <opie2/oapplication.h>
42 42
43/* FORWARDS */ 43/* FORWARDS */
44 44
45class QHeader; 45class QHeader;
46class QIconSet; 46class QIconSet;
47class QIconViewItem; 47class QIconViewItem;
48class OListView;
49class QListViewItem; 48class QListViewItem;
50class QPopupMenu; 49class QPopupMenu;
51class QString; 50class QString;
52 51
53#ifndef QT_NO_DRAGANDDROP 52#ifndef QT_NO_DRAGANDDROP
54class QIconDragItem; 53class QIconDragItem;
55#endif 54#endif
56 55
56namespace Opie {
57namespace Ui {
58class OListView;
59
57class OVersatileView : public QWidgetStack 60class OVersatileView : public QWidgetStack
58{ 61{
59 Q_OBJECT 62 Q_OBJECT
60 63
61 friend class OVersatileViewItem; 64 friend class OVersatileViewItem;
62 65
63 //==============================================================================================// 66 //==============================================================================================//
64 // OVersatileView High Level API 67 // OVersatileView High Level API
65 //==============================================================================================// 68 //==============================================================================================//
66 69
67 public: 70 public:
68 OVersatileView( QWidget* parent = 0, const char* name = 0, int mode = 0 ); 71 OVersatileView( QWidget* parent = 0, const char* name = 0, int mode = 0 );
69 ~OVersatileView(); 72 ~OVersatileView();
70 73
71 QPopupMenu* contextMenu() const; 74 QPopupMenu* contextMenu() const;
72 75
73 void setSynchronization( bool sync ); 76 void setSynchronization( bool sync );
74 bool synchronization(); 77 bool synchronization();
75 78
76 enum ViewMode { Tree = 0, Icons }; 79 enum ViewMode { Tree = 0, Icons };
77 int viewMode(); 80 int viewMode();
78 81
79 QIconView* iconView() const; 82 QIconView* iconView() const;
80 OListView* listView() const; 83 OListView* listView() const;
81 84
82 enum WarningPolicy { None = 0, Warn, WarnReturn }; 85 enum WarningPolicy { None = 0, Warn, WarnReturn };
83 86
84 void setWarningPolicy( int ) const; // warn, if calling a method which doesn't apply to the current viewmode 87 void setWarningPolicy( int ) const; // warn, if calling a method which doesn't apply to the current viewmode
85 bool warningPolicy() const; 88 bool warningPolicy() const;
86 89
87 void setDefaultPixmaps( int mode, QPixmap& leaf, QPixmap& opened, QPixmap& closed ); 90 void setDefaultPixmaps( int mode, QPixmap& leaf, QPixmap& opened, QPixmap& closed );
88 91
89 public slots: 92 public slots:
90 void setViewMode( int mode ); 93 void setViewMode( int mode );
91 void setIconViewMode(); 94 void setIconViewMode();
92 void setTreeViewMode(); 95 void setTreeViewMode();
93 96
94 protected: 97 protected:
95 virtual bool isValidViewMode( int mode ) const; 98 virtual bool isValidViewMode( int mode ) const;
96 virtual void popupContextMenu( OVersatileViewItem* item, const QPoint& pos, int col = 0 ); 99 virtual void popupContextMenu( OVersatileViewItem* item, const QPoint& pos, int col = 0 );
97 100
98 private: 101 private:
99 int _viewmode; 102 int _viewmode;
100 bool _synchronization; 103 bool _synchronization;
101 mutable int _warningpolicy; 104 mutable int _warningpolicy;
102 105
103 OListView* _listview; 106 OListView* _listview;
104 QIconView* _iconview; 107 QIconView* _iconview;
105 108
106 QPixmap _treeleaf; 109 QPixmap _treeleaf;
107 QPixmap _treeopened; 110 QPixmap _treeopened;
108 QPixmap _treeclosed; 111 QPixmap _treeclosed;
109 112
110 QPixmap _iconleaf; 113 QPixmap _iconleaf;
111 QPixmap _iconopened; 114 QPixmap _iconopened;
112 QPixmap _iconclosed; 115 QPixmap _iconclosed;
113 116
114 QPopupMenu* _contextmenu; 117 QPopupMenu* _contextmenu;
115 118
116 int _iconstyle; 119 int _iconstyle;
117 int _treestyle; 120 int _treestyle;
118 121
119 private slots: 122 private slots:
120 123
121 void contextMenuRequested( QListViewItem*, const QPoint&, int ); 124 void contextMenuRequested( QListViewItem*, const QPoint&, int );
122 void contextMenuRequested( QIconViewItem*, const QPoint& ); 125 void contextMenuRequested( QIconViewItem*, const QPoint& );
123 126
124 // type converting signal forwarders 127 // type converting signal forwarders
125 128
126 void selectionChanged( QListViewItem * ); 129 void selectionChanged( QListViewItem * );
127 void currentChanged( QListViewItem * ); 130 void currentChanged( QListViewItem * );
128 void clicked( QListViewItem * ); 131 void clicked( QListViewItem * );
129 void pressed( QListViewItem * ); 132 void pressed( QListViewItem * );
130 void doubleClicked( QListViewItem * ); 133 void doubleClicked( QListViewItem * );
131 void returnPressed( QListViewItem * ); 134 void returnPressed( QListViewItem * );
132 void onItem( QListViewItem * ); 135 void onItem( QListViewItem * );
133 136
134 void selectionChanged( QIconViewItem * ); 137 void selectionChanged( QIconViewItem * );
135 void currentChanged( QIconViewItem * ); 138 void currentChanged( QIconViewItem * );
136 void clicked( QIconViewItem * ); 139 void clicked( QIconViewItem * );
137 void pressed( QIconViewItem * ); 140 void pressed( QIconViewItem * );
138 void doubleClicked( QIconViewItem * ); 141 void doubleClicked( QIconViewItem * );
139 void returnPressed( QIconViewItem * ); 142 void returnPressed( QIconViewItem * );
140 void onItem( QIconViewItem * ); 143 void onItem( QIconViewItem * );
141 144
142 void expanded( QListViewItem * item ); // QListView 145 void expanded( QListViewItem * item ); // QListView
143 void collapsed( QListViewItem * item ); // QListView 146 void collapsed( QListViewItem * item ); // QListView
144 147
145 signals: 148 signals:
146 149
147 void contextMenuRequested( OVersatileViewItem * item, const QPoint& pos, int col ); 150 void contextMenuRequested( OVersatileViewItem * item, const QPoint& pos, int col );
148 151
149 /*#ifndef QT_NO_DRAGANDDROP 152 /*#ifndef QT_NO_DRAGANDDROP
150 void dropped( QDropEvent *e, const QValueList<QIconDragItem> &lst ); // QIconView 153 void dropped( QDropEvent *e, const QValueList<QIconDragItem> &lst ); // QIconView
151 #endif 154 #endif
152 void itemRenamed( OVersatileViewItem *item, const QString & ); // QIconView 155 void itemRenamed( OVersatileViewItem *item, const QString & ); // QIconView
153 void itemRenamed( OVersatileViewItem *item ); // QIconView 156 void itemRenamed( OVersatileViewItem *item ); // QIconView
154 */ 157 */
155 158
156 //==============================================================================================// 159 //==============================================================================================//
157 // "Derived" API - Case 1: Methods existing either only in QListView or only in QIconView 160 // "Derived" API - Case 1: Methods existing either only in QListView or only in QIconView
158 //==============================================================================================// 161 //==============================================================================================//
159 162
160public: 163public:
161 164
162 /* 165 /*
163 enum Arrangement { // QIconView 166 enum Arrangement { // QIconView
164 LeftToRight = 0, 167 LeftToRight = 0,
165 TopToBottom 168 TopToBottom
166 }; 169 };
167 enum ResizeMode { // QIconView 170 enum ResizeMode { // QIconView
168 Fixed = 0, 171 Fixed = 0,
169 Adjust 172 Adjust
170 }; 173 };
171 enum ItemTextPos { // QIconView 174 enum ItemTextPos { // QIconView
172 Bottom = 0, 175 Bottom = 0,
173 Right 176 Right
174 }; 177 };
175 */ 178 */
176 179
177 // 180 //
178 // only in QListView 181 // only in QListView
179 // 182 //
180 183
181 int treeStepSize() const; // QListView 184 int treeStepSize() const; // QListView
182 virtual void setTreeStepSize( int ); // QListView 185 virtual void setTreeStepSize( int ); // QListView
183 186
184 QHeader * header() const; // QListView 187 QHeader * header() const; // QListView
185 188
186 virtual int addColumn( const QString &label, int size = -1); // QListView 189 virtual int addColumn( const QString &label, int size = -1); // QListView
187 virtual int addColumn( const QIconSet& iconset, const QString &label, int size = -1); // QListView 190 virtual int addColumn( const QIconSet& iconset, const QString &label, int size = -1); // QListView
188 void removeColumn( int index ); // #### make virtual in next major release! // QListView 191 void removeColumn( int index ); // #### make virtual in next major release! // QListView
189 virtual void setColumnText( int column, const QString &label ); // QListView 192 virtual void setColumnText( int column, const QString &label ); // QListView
190 virtual void setColumnText( int column, const QIconSet& iconset, const QString &label ); // QListView 193 virtual void setColumnText( int column, const QIconSet& iconset, const QString &label ); // QListView
191 QString columnText( int column ) const; // QListView 194 QString columnText( int column ) const; // QListView
192 virtual void setColumnWidth( int column, int width ); // QListView 195 virtual void setColumnWidth( int column, int width ); // QListView
193 int columnWidth( int column ) const; // QListView 196 int columnWidth( int column ) const; // QListView
194 enum WidthMode { Manual, Maximum }; // QListView 197 enum WidthMode { Manual, Maximum }; // QListView
195 virtual void setColumnWidthMode( int column, WidthMode ); // QListView 198 virtual void setColumnWidthMode( int column, WidthMode ); // QListView
196 WidthMode columnWidthMode( int column ) const; // QListView 199 WidthMode columnWidthMode( int column ) const; // QListView
197 int columns() const; // QListView 200 int columns() const; // QListView
198 201
199 virtual void setColumnAlignment( int, int ); // QListView 202 virtual void setColumnAlignment( int, int ); // QListView
200 int columnAlignment( int ) const; // QListView 203 int columnAlignment( int ) const; // QListView
201 204
202 OVersatileViewItem * itemAt( const QPoint & screenPos ) const; // QListView 205 OVersatileViewItem * itemAt( const QPoint & screenPos ) const; // QListView
203 QRect itemRect( const OVersatileViewItem * ) const; // QListView 206 QRect itemRect( const OVersatileViewItem * ) const; // QListView
204 int itemPos( const OVersatileViewItem * ); // QListView 207 int itemPos( const OVersatileViewItem * ); // QListView
205 208
206 bool isSelected( const OVersatileViewItem * ) const; // QListView // also in QIconViewItem but not in QIconView *shrug* 209 bool isSelected( const OVersatileViewItem * ) const; // QListView // also in QIconViewItem but not in QIconView *shrug*
207 210
208 virtual void setMultiSelection( bool enable ); // QListView 211 virtual void setMultiSelection( bool enable ); // QListView
209 bool isMultiSelection() const; // QListView 212 bool isMultiSelection() const; // QListView
210 213
211 OVersatileViewItem * selectedItem() const; // QListView 214 OVersatileViewItem * selectedItem() const; // QListView
212 virtual void setOpen( OVersatileViewItem *, bool ); // QListView 215 virtual void setOpen( OVersatileViewItem *, bool ); // QListView
213 bool isOpen( const OVersatileViewItem * ) const; // QListView 216 bool isOpen( const OVersatileViewItem * ) const; // QListView
214 217
215 OVersatileViewItem * firstChild() const; // QListView 218 OVersatileViewItem * firstChild() const; // QListView
216 int childCount() const; // QListView 219 int childCount() const; // QListView
217 220
218 virtual void setAllColumnsShowFocus( bool ); // QListView 221 virtual void setAllColumnsShowFocus( bool ); // QListView
219 bool allColumnsShowFocus() const; // QListView 222 bool allColumnsShowFocus() const; // QListView
220 223
221 virtual void setItemMargin( int ); // QListView 224 virtual void setItemMargin( int ); // QListView
222 int itemMargin() const; // QListView 225 int itemMargin() const; // QListView
223 226
224 virtual void setRootIsDecorated( bool ); // QListView 227 virtual void setRootIsDecorated( bool ); // QListView
225 bool rootIsDecorated() const; // QListView 228 bool rootIsDecorated() const; // QListView
226 229
227 void setShowSortIndicator( bool show ); // QListView 230 void setShowSortIndicator( bool show ); // QListView
228 bool showSortIndicator() const; // QListView 231 bool showSortIndicator() const; // QListView
229 232
230 int index( const OVersatileViewItem *item ) const; // QIconView 233 int index( const OVersatileViewItem *item ) const; // QIconView
231 234
232 public slots: 235 public slots:
233 void triggerUpdate(); // QListView 236 void triggerUpdate(); // QListView
234 237
235 signals: 238 signals:
236 void expanded( OVersatileViewItem *item ); // QListView 239 void expanded( OVersatileViewItem *item ); // QListView
237 void collapsed( OVersatileViewItem *item ); // QListView 240 void collapsed( OVersatileViewItem *item ); // QListView
238 241
239 // 242 //
240 // only in QIconView 243 // only in QIconView
241 // 244 //
242 245
243 public: 246 public:
244 uint count() const; // QIconView 247 uint count() const; // QIconView
245 248
246 OVersatileViewItem *firstItem() const; // QIconView 249 OVersatileViewItem *firstItem() const; // QIconView
247 OVersatileViewItem *lastItem() const; // QIconView 250 OVersatileViewItem *lastItem() const; // QIconView
248 251
249 OVersatileViewItem *findItem( const QPoint &pos ) const; // QIconView 252 OVersatileViewItem *findItem( const QPoint &pos ) const; // QIconView
250 OVersatileViewItem *findItem( const QString &text ) const; // QIconView 253 OVersatileViewItem *findItem( const QString &text ) const; // QIconView
251 254
252 OVersatileViewItem* findFirstVisibleItem( const QRect &r ) const; // QIconView 255 OVersatileViewItem* findFirstVisibleItem( const QRect &r ) const; // QIconView
253 OVersatileViewItem* findLastVisibleItem( const QRect &r ) const; // QIconView 256 OVersatileViewItem* findLastVisibleItem( const QRect &r ) const; // QIconView
254 257
255 virtual void setGridX( int rx ); // QIconView 258 virtual void setGridX( int rx ); // QIconView
256 virtual void setGridY( int ry ); // QIconView 259 virtual void setGridY( int ry ); // QIconView
257 int gridX() const; // QIconView 260 int gridX() const; // QIconView
258 int gridY() const; // QIconView 261 int gridY() const; // QIconView
259 virtual void setSpacing( int sp ); // QIconView 262 virtual void setSpacing( int sp ); // QIconView
260 int spacing() const; // QIconView 263 int spacing() const; // QIconView
261 virtual void setItemTextPos( QIconView::ItemTextPos pos ); // QIconView 264 virtual void setItemTextPos( QIconView::ItemTextPos pos ); // QIconView
262 QIconView::ItemTextPos itemTextPos() const; // QIconView 265 QIconView::ItemTextPos itemTextPos() const; // QIconView
263 virtual void setItemTextBackground( const QBrush &b ); // QIconView 266 virtual void setItemTextBackground( const QBrush &b ); // QIconView
264 QBrush itemTextBackground() const; // QIconView 267 QBrush itemTextBackground() const; // QIconView
265 virtual void setArrangement( QIconView::Arrangement am ); // QIconView 268 virtual void setArrangement( QIconView::Arrangement am ); // QIconView
266 QIconView::Arrangement arrangement() const; // QIconView 269 QIconView::Arrangement arrangement() const; // QIconView
267 virtual void setResizeMode( QIconView::ResizeMode am ); // QIconView 270 virtual void setResizeMode( QIconView::ResizeMode am ); // QIconView
268 QIconView::ResizeMode resizeMode() const; // QIconView 271 QIconView::ResizeMode resizeMode() const; // QIconView
269 virtual void setMaxItemWidth( int w ); // QIconView 272 virtual void setMaxItemWidth( int w ); // QIconView
270 int maxItemWidth() const; // QIconView 273 int maxItemWidth() const; // QIconView
271 virtual void setMaxItemTextLength( int w ); // QIconView 274 virtual void setMaxItemTextLength( int w ); // QIconView
272 int maxItemTextLength() const; // QIconView 275 int maxItemTextLength() const; // QIconView
273 virtual void setAutoArrange( bool b ); // QIconView 276 virtual void setAutoArrange( bool b ); // QIconView
274 bool autoArrange() const; // QIconView 277 bool autoArrange() const; // QIconView
275 virtual void setShowToolTips( bool b ); // QIconView 278 virtual void setShowToolTips( bool b ); // QIconView
276 bool showToolTips() const; // QIconView 279 bool showToolTips() const; // QIconView
277 280
278 bool sorting() const; // QIconView 281 bool sorting() const; // QIconView
279 bool sortDirection() const; // QIconView 282 bool sortDirection() const; // QIconView
280 283
281 virtual void setItemsMovable( bool b ); // QIconView 284 virtual void setItemsMovable( bool b ); // QIconView
282 bool itemsMovable() const; // QIconView 285 bool itemsMovable() const; // QIconView
283 virtual void setWordWrapIconText( bool b ); // QIconView 286 virtual void setWordWrapIconText( bool b ); // QIconView
284 bool wordWrapIconText() const; // QIconView 287 bool wordWrapIconText() const; // QIconView
285 288
286 public slots: 289 public slots:
287 virtual void arrangeItemsInGrid( const QSize &grid, bool update = TRUE ); // QIconView 290 virtual void arrangeItemsInGrid( const QSize &grid, bool update = TRUE ); // QIconView
288 virtual void arrangeItemsInGrid( bool update = TRUE ); // QIconView 291 virtual void arrangeItemsInGrid( bool update = TRUE ); // QIconView
289 virtual void updateContents(); // QIconView 292 virtual void updateContents(); // QIconView
290 293
291 signals: 294 signals:
292 /*#ifndef QT_NO_DRAGANDDROP 295 /*#ifndef QT_NO_DRAGANDDROP
293 void dropped( QDropEvent *e, const QValueList<QIconDragItem> &lst ); // QIconView 296 void dropped( QDropEvent *e, const QValueList<QIconDragItem> &lst ); // QIconView
294 #endif 297 #endif
295 */ 298 */
296 void moved(); // QIconView 299 void moved(); // QIconView
297 void itemRenamed( OVersatileViewItem *item, const QString & ); // QIconView 300 void itemRenamed( OVersatileViewItem *item, const QString & ); // QIconView
298 void itemRenamed( OVersatileViewItem *item ); // QIconView 301 void itemRenamed( OVersatileViewItem *item ); // QIconView
299 302
300 //==============================================================================================// 303 //==============================================================================================//
301 // "Derived" API - Case 2: Methods existing in QListView and QIconView with the same signatures 304 // "Derived" API - Case 2: Methods existing in QListView and QIconView with the same signatures
302 //==============================================================================================// 305 //==============================================================================================//
303 306
304 public: 307 public:
305 enum SelectionMode { 308 enum SelectionMode {
306 Single = 0, 309 Single = 0,
307 Multi, 310 Multi,
308 Extended, 311 Extended,
309 NoSelection 312 NoSelection
310 }; 313 };
311 314
312 virtual void clear(); 315 virtual void clear();
313 316
314 virtual void setFont( const QFont & ); 317 virtual void setFont( const QFont & );
315 virtual void setPalette( const QPalette & ); 318 virtual void setPalette( const QPalette & );
316 319
317 virtual void takeItem( OVersatileViewItem * ); 320 virtual void takeItem( OVersatileViewItem * );
318 321
319 void setSelectionMode( SelectionMode mode ); 322 void setSelectionMode( SelectionMode mode );
320 SelectionMode selectionMode() const; 323 SelectionMode selectionMode() const;
321 324
322 virtual void selectAll( bool select ); 325 virtual void selectAll( bool select );
323 virtual void clearSelection(); 326 virtual void clearSelection();
324 virtual void invertSelection(); 327 virtual void invertSelection();
325 328
326 void ensureItemVisible( const OVersatileViewItem * ); 329 void ensureItemVisible( const OVersatileViewItem * );
327 virtual void repaintItem( const OVersatileViewItem * ) const; 330 virtual void repaintItem( const OVersatileViewItem * ) const;
328 331
329 virtual void setCurrentItem( OVersatileViewItem * ); 332 virtual void setCurrentItem( OVersatileViewItem * );
330 OVersatileViewItem * currentItem() const; 333 OVersatileViewItem * currentItem() const;
331 334
332 // bool eventFilter( QObject * o, QEvent * ); // use QWidgetStack implementation 335 // bool eventFilter( QObject * o, QEvent * ); // use QWidgetStack implementation
333 336
334 // QSize minimumSizeHint() const; // use QWidgetStack implementation 337 // QSize minimumSizeHint() const; // use QWidgetStack implementation
335 // QSizePolicy sizePolicy() const; // use QWidgetStack implementation 338 // QSizePolicy sizePolicy() const; // use QWidgetStack implementation
336 // QSize sizeHint() const; // use QWidgetStack implementation 339 // QSize sizeHint() const; // use QWidgetStack implementation
337 340
338 signals: 341 signals:
339 void selectionChanged(); 342 void selectionChanged();
340 void selectionChanged( OVersatileViewItem * ); 343 void selectionChanged( OVersatileViewItem * );
341 void currentChanged( OVersatileViewItem * ); 344 void currentChanged( OVersatileViewItem * );
342 void clicked( OVersatileViewItem * ); 345 void clicked( OVersatileViewItem * );
343 void pressed( OVersatileViewItem * ); 346 void pressed( OVersatileViewItem * );
344 347
345 void doubleClicked( OVersatileViewItem * ); 348 void doubleClicked( OVersatileViewItem * );
346 void returnPressed( OVersatileViewItem * ); 349 void returnPressed( OVersatileViewItem * );
347 350
348 void onItem( OVersatileViewItem * ); 351 void onItem( OVersatileViewItem * );
349 void onViewport(); 352 void onViewport();
350 353
351 //==============================================================================================// 354 //==============================================================================================//
352 // "Derived" API - Case 2: Methods existing in QListView and QIconView with differing signatures 355 // "Derived" API - Case 2: Methods existing in QListView and QIconView with differing signatures
353 //==============================================================================================// 356 //==============================================================================================//
354 357
355 /* 358 /*
356 359
357 public: 360 public:
358 virtual void insertItem( OVersatileViewItem * ); // QListView 361 virtual void insertItem( OVersatileViewItem * ); // QListView
359 virtual void insertItem( OVersatileViewItem *item, OVersatileViewItem *after = 0L ); // QIconView 362 virtual void insertItem( OVersatileViewItem *item, OVersatileViewItem *after = 0L ); // QIconView
360 363
361 virtual void setSelected( OVersatileViewItem *, bool ); // QListView 364 virtual void setSelected( OVersatileViewItem *, bool ); // QListView
362 virtual void setSelected( OVersatileViewItem *item, bool s, bool cb = FALSE ); // QIconView 365 virtual void setSelected( OVersatileViewItem *item, bool s, bool cb = FALSE ); // QIconView
363 366
364 virtual void setSorting( int column, bool increasing = TRUE ); // QListView 367 virtual void setSorting( int column, bool increasing = TRUE ); // QListView
365 void setSorting( bool sort, bool ascending = TRUE ); // QIconView 368 void setSorting( bool sort, bool ascending = TRUE ); // QIconView
366 369
367 void sort(); // #### make virtual in next major release // QListView 370 void sort(); // #### make virtual in next major release // QListView
368 virtual void sort( bool ascending = TRUE ); // QIconView 371 virtual void sort( bool ascending = TRUE ); // QIconView
369 372
370 */ 373 */
371 374
372 signals: 375 signals:
373 void clicked( OVersatileViewItem *, const QPoint &, int ); // QListView 376 void clicked( OVersatileViewItem *, const QPoint &, int ); // QListView
374 void clicked( OVersatileViewItem *, const QPoint & ); // QIconView 377 void clicked( OVersatileViewItem *, const QPoint & ); // QIconView
375 378
376 void pressed( OVersatileViewItem *, const QPoint &, int ); // QListView 379 void pressed( OVersatileViewItem *, const QPoint &, int ); // QListView
377 void pressed( OVersatileViewItem *, const QPoint & ); // QIconView 380 void pressed( OVersatileViewItem *, const QPoint & ); // QIconView
378 381
379 void rightButtonClicked( OVersatileViewItem* item, const QPoint& pos ); // QIconView 382 void rightButtonClicked( OVersatileViewItem* item, const QPoint& pos ); // QIconView
380 void rightButtonClicked( OVersatileViewItem *, const QPoint&, int ); // QListView 383 void rightButtonClicked( OVersatileViewItem *, const QPoint&, int ); // QListView
381 384
382 void rightButtonPressed( OVersatileViewItem* item, const QPoint& pos ); // QIconView 385 void rightButtonPressed( OVersatileViewItem* item, const QPoint& pos ); // QIconView
383 void rightButtonPressed( OVersatileViewItem *, const QPoint&, int ); // QListView 386 void rightButtonPressed( OVersatileViewItem *, const QPoint&, int ); // QListView
384 387
385 void mouseButtonPressed( int, OVersatileViewItem *, const QPoint& , int ); // QListView 388 void mouseButtonPressed( int, OVersatileViewItem *, const QPoint& , int ); // QListView
386 void mouseButtonPressed( int button, OVersatileViewItem* item, const QPoint& pos ); // QIconView 389 void mouseButtonPressed( int button, OVersatileViewItem* item, const QPoint& pos ); // QIconView
387 390
388 void mouseButtonClicked( int, OVersatileViewItem *, const QPoint&, int ); // QListView 391 void mouseButtonClicked( int, OVersatileViewItem *, const QPoint&, int ); // QListView
389 void mouseButtonClicked( int button, OVersatileViewItem* item, const QPoint& pos ); // QIconView 392 void mouseButtonClicked( int button, OVersatileViewItem* item, const QPoint& pos ); // QIconView
390 393
391}; 394};
392 395
396}
397}
393#endif 398#endif
394 399
diff --git a/libopie2/opieui/oversatileviewitem.cpp b/libopie2/opieui/oversatileviewitem.cpp
index 66de8eb..03c6738 100644
--- a/libopie2/opieui/oversatileviewitem.cpp
+++ b/libopie2/opieui/oversatileviewitem.cpp
@@ -1,81 +1,83 @@
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#include <opie2/oversatileviewitem.h> 31#include <opie2/oversatileviewitem.h>
32#include <opie2/oversatileview.h> 32#include <opie2/oversatileview.h>
33 33
34using namespace Opie::Ui;
35
34OVersatileViewItem::OVersatileViewItem( OVersatileView * parent ) 36OVersatileViewItem::OVersatileViewItem( OVersatileView * parent )
35 :OListViewItem( parent->_listview ), QIconViewItem( parent->_iconview ), 37 :OListViewItem( parent->_listview ), QIconViewItem( parent->_iconview ),
36 _versatileview( parent ) 38 _versatileview( parent )
37{ 39{
38 init(); 40 init();
39} 41}
40 42
41OVersatileViewItem::OVersatileViewItem( OVersatileView * parent, OVersatileViewItem * after ) 43OVersatileViewItem::OVersatileViewItem( OVersatileView * parent, OVersatileViewItem * after )
42 :OListViewItem( parent->_listview, after ), QIconViewItem( parent->_iconview, after ), 44 :OListViewItem( parent->_listview, after ), QIconViewItem( parent->_iconview, after ),
43 _versatileview( parent ) 45 _versatileview( parent )
44{ 46{
45 init(); 47 init();
46} 48}
47 49
48OVersatileViewItem::OVersatileViewItem( OVersatileView * parent, 50OVersatileViewItem::OVersatileViewItem( OVersatileView * parent,
49 QString a, QString b, QString c, QString d, 51 QString a, QString b, QString c, QString d,
50 QString e, QString f, QString g, QString h ) 52 QString e, QString f, QString g, QString h )
51 :OListViewItem( parent->_listview, a, b, c, d, e, f, g, h ), 53 :OListViewItem( parent->_listview, a, b, c, d, e, f, g, h ),
52 QIconViewItem( parent->_iconview, a ), 54 QIconViewItem( parent->_iconview, a ),
53 _versatileview( parent ) 55 _versatileview( parent )
54{ 56{
55 init(); 57 init();
56} 58}
57 59
58OVersatileViewItem::OVersatileViewItem( OVersatileView * parent, OVersatileViewItem* after, 60OVersatileViewItem::OVersatileViewItem( OVersatileView * parent, OVersatileViewItem* after,
59 QString a, QString b, QString c, QString d, 61 QString a, QString b, QString c, QString d,
60 QString e, QString f, QString g, QString h ) 62 QString e, QString f, QString g, QString h )
61 :OListViewItem( parent->_listview, after, a, b, c, d, e, f, g, h ), 63 :OListViewItem( parent->_listview, after, a, b, c, d, e, f, g, h ),
62 QIconViewItem( parent->_iconview, after, a ), 64 QIconViewItem( parent->_iconview, after, a ),
63 _versatileview( parent ) 65 _versatileview( parent )
64{ 66{
65 init(); 67 init();
66} 68}
67 69
68OVersatileViewItem::OVersatileViewItem( OVersatileViewItem * parent, 70OVersatileViewItem::OVersatileViewItem( OVersatileViewItem * parent,
69 QString a, QString b, QString c, QString d, 71 QString a, QString b, QString c, QString d,
70 QString e, QString f, QString g, QString h ) 72 QString e, QString f, QString g, QString h )
71 :OListViewItem( parent, a, b, c, d, e, f, g, h ), 73 :OListViewItem( parent, a, b, c, d, e, f, g, h ),
72 QIconViewItem( parent->_versatileview->_iconview, a ), 74 QIconViewItem( parent->_versatileview->_iconview, a ),
73 _versatileview( parent->_versatileview ) 75 _versatileview( parent->_versatileview )
74{ 76{
75 init(); 77 init();
76} 78}
77 79
78OVersatileViewItem::OVersatileViewItem( OVersatileViewItem * parent, OVersatileViewItem* after, 80OVersatileViewItem::OVersatileViewItem( OVersatileViewItem * parent, OVersatileViewItem* after,
79 QString a, QString b, QString c, QString d, 81 QString a, QString b, QString c, QString d,
80 QString e, QString f, QString g, QString h ) 82 QString e, QString f, QString g, QString h )
81 :OListViewItem( parent, after, a, b, c, d, e, f, g, h ), 83 :OListViewItem( parent, after, a, b, c, d, e, f, g, h ),
diff --git a/libopie2/opieui/oversatileviewitem.h b/libopie2/opieui/oversatileviewitem.h
index ee8ee20..c4977af 100644
--- a/libopie2/opieui/oversatileviewitem.h
+++ b/libopie2/opieui/oversatileviewitem.h
@@ -1,100 +1,105 @@
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 <mickey@tm.informatik.uni-frankfurt.de> 4              Copyright (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
5 =. 5 =.
6 .=l. 6 .=l.
7           .>+-= 7           .>+-=
8 _;:,     .>    :=|. This program is free software; you can 8 _;:,     .>    :=|. This program is free software; you can
9.> <`_,   >  .   <= redistribute it and/or modify it under 9.> <`_,   >  .   <= redistribute it and/or modify it under
10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
11.="- .-=="i,     .._ License as published by the Free Software 11.="- .-=="i,     .._ License as published by the Free Software
12 - .   .-<_>     .<> Foundation; either version 2 of the License, 12 - .   .-<_>     .<> Foundation; either version 2 of the License,
13     ._= =}       : or (at your option) any later version. 13     ._= =}       : or (at your option) any later version.
14    .%`+i>       _;_. 14    .%`+i>       _;_.
15    .i_,=:_.      -<s. This program is distributed in the hope that 15    .i_,=:_.      -<s. This program is distributed in the hope that
16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
17    : ..    .:,     . . . without even the implied warranty of 17    : ..    .:,     . . . without even the implied warranty of
18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.=       =       ; Library General Public License for more 20..}^=.=       =       ; Library General Public License for more
21++=   -.     .`     .: details. 21++=   -.     .`     .: details.
22 :     =  ...= . :.=- 22 :     =  ...= . :.=-
23 -.   .:....=;==+<; You should have received a copy of the GNU 23 -.   .:....=;==+<; You should have received a copy of the GNU
24  -_. . .   )=.  = Library General Public License along with 24  -_. . .   )=.  = Library General Public License along with
25    --        :-=` this library; see the file COPYING.LIB. 25    --        :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation, 26 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330, 27 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA. 28 Boston, MA 02111-1307, USA.
29 29
30*/ 30*/
31 31
32#ifndef OVERSATILEVIEWITEM_H 32#ifndef OVERSATILEVIEWITEM_H
33#define OVERSATILEVIEWITEM_H 33#define OVERSATILEVIEWITEM_H
34 34
35/* QT */ 35/* QT */
36 36
37#include <qiconview.h> 37#include <qiconview.h>
38 38
39/* OPIE */ 39/* OPIE */
40 40
41#include <opie2/olistview.h> 41#include <opie2/olistview.h>
42 42
43namespace Opie {
44namespace Ui {
45
43class OVersatileView; 46class OVersatileView;
44 47
45class OVersatileViewItem : public OListViewItem, public QIconViewItem 48class OVersatileViewItem : public OListViewItem, public QIconViewItem
46{ 49{
47 public: 50 public:
48 OVersatileViewItem( OVersatileView * parent ); 51 OVersatileViewItem( OVersatileView * parent );
49 52
50 OVersatileViewItem( OVersatileView * parent, OVersatileViewItem * after ); 53 OVersatileViewItem( OVersatileView * parent, OVersatileViewItem * after );
51 54
52 OVersatileViewItem( OVersatileViewItem * parent, OVersatileViewItem * after ); 55 OVersatileViewItem( OVersatileViewItem * parent, OVersatileViewItem * after );
53 56
54 OVersatileViewItem( OVersatileView * parent, QString, 57 OVersatileViewItem( OVersatileView * parent, QString,
55 QString = QString::null, QString = QString::null, 58 QString = QString::null, QString = QString::null,
56 QString = QString::null, QString = QString::null, 59 QString = QString::null, QString = QString::null,
57 QString = QString::null, QString = QString::null, 60 QString = QString::null, QString = QString::null,
58 QString = QString::null ); 61 QString = QString::null );
59 62
60 OVersatileViewItem( OVersatileViewItem * parent, QString, 63 OVersatileViewItem( OVersatileViewItem * parent, QString,
61 QString = QString::null, QString = QString::null, 64 QString = QString::null, QString = QString::null,
62 QString = QString::null, QString = QString::null, 65 QString = QString::null, QString = QString::null,
63 QString = QString::null, QString = QString::null, 66 QString = QString::null, QString = QString::null,
64 QString = QString::null ); 67 QString = QString::null );
65 68
66 OVersatileViewItem( OVersatileView * parent, OVersatileViewItem * after, QString, 69 OVersatileViewItem( OVersatileView * parent, OVersatileViewItem * after, QString,
67 QString = QString::null, QString = QString::null, 70 QString = QString::null, QString = QString::null,
68 QString = QString::null, QString = QString::null, 71 QString = QString::null, QString = QString::null,
69 QString = QString::null, QString = QString::null, 72 QString = QString::null, QString = QString::null,
70 QString = QString::null ); 73 QString = QString::null );
71 74
72 OVersatileViewItem( OVersatileViewItem * parent, OVersatileViewItem * after, QString, 75 OVersatileViewItem( OVersatileViewItem * parent, OVersatileViewItem * after, QString,
73 QString = QString::null, QString = QString::null, 76 QString = QString::null, QString = QString::null,
74 QString = QString::null, QString = QString::null, 77 QString = QString::null, QString = QString::null,
75 QString = QString::null, QString = QString::null, 78 QString = QString::null, QString = QString::null,
76 QString = QString::null ); 79 QString = QString::null );
77 80
78 virtual ~OVersatileViewItem(); 81 virtual ~OVersatileViewItem();
79 82
80 OVersatileView* versatileView() const; 83 OVersatileView* versatileView() const;
81 84
82 // TODO: Implement the remaining constructors from QIconView 85 // TODO: Implement the remaining constructors from QIconView
83 86
84 /* OIconViewItem( QIconView *parent, const QString &text, const QPixmap &icon ); 87 /* OIconViewItem( QIconView *parent, const QString &text, const QPixmap &icon );
85 OIconViewItem( QIconView *parent, QIconViewItem *after, const QString &text, const QPixmap &icon ); 88 OIconViewItem( QIconView *parent, QIconViewItem *after, const QString &text, const QPixmap &icon );
86 */ 89 */
87 90
88 virtual void setRenameEnabled( bool ); 91 virtual void setRenameEnabled( bool );
89 92
90 // TODO: Implement the remaining method multiplexers 93 // TODO: Implement the remaining method multiplexers
91 94
92 private: 95 private:
93 OVersatileView* _versatileview; 96 OVersatileView* _versatileview;
94 97
95 private: 98 private:
96 void init(); 99 void init();
97 100
98}; 101};
99 102
103}
104}
100#endif 105#endif
diff --git a/libopie2/opieui/owait.cpp b/libopie2/opieui/owait.cpp
index 8bb4ed6..9519888 100644
--- a/libopie2/opieui/owait.cpp
+++ b/libopie2/opieui/owait.cpp
@@ -1,88 +1,90 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3              Copyright (C) 2003 Maximilian Reiss <harlekin@handhelds.org> 3              Copyright (C) 2003 Maximilian Reiss <harlekin@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 30
31#include "owait.h" 31#include "owait.h"
32 32
33/* OPIE */ 33/* OPIE */
34#include <qpe/qpeapplication.h> 34#include <qpe/qpeapplication.h>
35#include <qpe/resource.h> 35#include <qpe/resource.h>
36 36
37/* QT */ 37/* QT */
38#include <qlayout.h> 38#include <qlayout.h>
39#include <qpainter.h> 39#include <qpainter.h>
40 40
41using namespace Opie::Ui;
42
41static int frame = 0; 43static int frame = 0;
42 44
43/** 45/**
44 * This will construct a modal dialog. 46 * This will construct a modal dialog.
45 * 47 *
46 * The default timer length is 10. 48 * The default timer length is 10.
47 * 49 *
48 * @param parent The parent of the widget 50 * @param parent The parent of the widget
49 * @param msg The name of the object 51 * @param msg The name of the object
50 * @param dispIcon Display Icon? 52 * @param dispIcon Display Icon?
51 */ 53 */
52OWait::OWait( QWidget *parent, const char* msg, bool dispIcon ) 54OWait::OWait( QWidget *parent, const char* msg, bool dispIcon )
53 :QDialog( parent, msg, TRUE, WStyle_Customize ) 55 :QDialog( parent, msg, TRUE, WStyle_Customize )
54{ 56{
55 57
56 58
57 QHBoxLayout * hbox = new QHBoxLayout( this ); 59 QHBoxLayout * hbox = new QHBoxLayout( this );
58 60
59 m_lb = new QLabel( this ); 61 m_lb = new QLabel( this );
60 m_lb->setBackgroundMode ( NoBackground ); 62 m_lb->setBackgroundMode ( NoBackground );
61 63
62 hbox->addWidget( m_lb ); 64 hbox->addWidget( m_lb );
63 hbox->activate(); 65 hbox->activate();
64 66
65 m_pix = Resource::loadPixmap( "BigBusy" ); 67 m_pix = Resource::loadPixmap( "BigBusy" );
66 m_aniSize = m_pix.height(); 68 m_aniSize = m_pix.height();
67 resize( m_aniSize, m_aniSize ); 69 resize( m_aniSize, m_aniSize );
68 70
69 m_timerLength = 10; 71 m_timerLength = 10;
70 72
71 m_waitTimer = new QTimer( this ); 73 m_waitTimer = new QTimer( this );
72 connect( m_waitTimer, SIGNAL( timeout() ), this, SLOT( hide() ) ); 74 connect( m_waitTimer, SIGNAL( timeout() ), this, SLOT( hide() ) );
73} 75}
74 76
75void OWait::timerEvent( QTimerEvent * ) 77void OWait::timerEvent( QTimerEvent * )
76{ 78{
77 frame = ( ++frame ) % 4; 79 frame = ( ++frame ) % 4;
78 repaint(); 80 repaint();
79} 81}
80 82
81void OWait::paintEvent( QPaintEvent * ) 83void OWait::paintEvent( QPaintEvent * )
82{ 84{
83 QPainter p( m_lb ); 85 QPainter p( m_lb );
84 p.drawPixmap( 0, 0, m_pix, m_aniSize * frame, 0, m_aniSize, m_aniSize ); 86 p.drawPixmap( 0, 0, m_pix, m_aniSize * frame, 0, m_aniSize, m_aniSize );
85} 87}
86 88
87void OWait::show() 89void OWait::show()
88{ 90{
diff --git a/libopie2/opieui/owait.h b/libopie2/opieui/owait.h
index 3267064..03c33e4 100644
--- a/libopie2/opieui/owait.h
+++ b/libopie2/opieui/owait.h
@@ -1,86 +1,90 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3              Copyright (C) 2003 Maximilian Reiss <harlekin@handhelds.org> 3              Copyright (C) 2003 Maximilian Reiss <harlekin@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 30
31#ifndef OWAIT_H 31#ifndef OWAIT_H
32#define OWAIT_H 32#define OWAIT_H
33 33
34/* QT */ 34/* QT */
35#include <qdialog.h> 35#include <qdialog.h>
36#include <qlabel.h> 36#include <qlabel.h>
37#include <qpixmap.h> 37#include <qpixmap.h>
38#include <qtimer.h> 38#include <qtimer.h>
39 39
40
41namespace Opie {
42namespace Ui {
40/** 43/**
41 * This class displays a animated waiting icon in the middle of the screen. 44 * This class displays a animated waiting icon in the middle of the screen.
42 * 45 *
43 * @short modal hour glass dialog 46 * @short modal hour glass dialog
44 * @see QDialog 47 * @see QDialog
45 * @author Maximilian Reiß 48 * @author Maximilian Reiß
46 */ 49 */
47class OWait : public QDialog 50class OWait : public QDialog
48{ 51{
49 Q_OBJECT 52 Q_OBJECT
50 53
51 public: 54 public:
52 OWait( QWidget *parent = 0, const char* name = 0, bool dispIcon = TRUE ); 55 OWait( QWidget *parent = 0, const char* name = 0, bool dispIcon = TRUE );
53 ~OWait(); 56 ~OWait();
54 57
55 /** 58 /**
56 * reimplemented for control reasons 59 * reimplemented for control reasons
57 */ 60 */
58 void show(); 61 void show();
59 62
60 /** 63 /**
61 * Set the time before the icon will be automaticly hidden 64 * Set the time before the icon will be automaticly hidden
62 * The timer will be started once the widget will be shown. 65 * The timer will be started once the widget will be shown.
63 * @param length - time in seconds 66 * @param length - time in seconds
64 */ 67 */
65 void setTimerLength( int length ); 68 void setTimerLength( int length );
66 69
67 public slots: 70 public slots:
68 /** 71 /**
69 * reimplemented for control reasons 72 * reimplemented for control reasons
70 */ 73 */
71 void hide(); 74 void hide();
72 75
73 private: 76 private:
74 void timerEvent( QTimerEvent * ); 77 void timerEvent( QTimerEvent * );
75 void paintEvent( QPaintEvent * ); 78 void paintEvent( QPaintEvent * );
76 79
77 QPixmap m_pix; 80 QPixmap m_pix;
78 QLabel *m_lb; 81 QLabel *m_lb;
79 QTimer *m_waitTimer; 82 QTimer *m_waitTimer;
80 int m_timerLength; 83 int m_timerLength;
81 int m_aniSize; 84 int m_aniSize;
82 class Private; 85 class Private;
83 Private *d; 86 Private *d;
84}; 87};
85 88}
89}
86#endif 90#endif
diff --git a/libqtaux/oticker.cpp b/libqtaux/oticker.cpp
index 2d8397e..e954cc8 100644
--- a/libqtaux/oticker.cpp
+++ b/libqtaux/oticker.cpp
@@ -1,83 +1,85 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3 Copyright (c) 2002 L. Potter <ljp@llornkcor.com> 3 Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
4 =. 4 =.
5 .=l. 5 .=l.
6           .>+-= 6           .>+-=
7 _;:,     .>    :=|. This program is free software; you can 7 _;:,     .>    :=|. This program is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under 8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU General Public 9:`=1 )Y*s>-.--   : the terms of the GNU General Public
10.="- .-=="i,     .._ License as published by the Free Software 10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License, 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version. 12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_. 13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This program is distributed in the hope that 14    .i_,=:_.      -<s. This program is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of 16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more 19..}^=.=       =       ; Library General Public License for more
20++=   -.     .`     .: details. 20++=   -.     .`     .: details.
21 :     =  ...= . :.=- 21 :     =  ...= . :.=-
22 -.   .:....=;==+<; You should have received a copy of the GNU 22 -.   .:....=;==+<; You should have received a copy of the GNU
23  -_. . .   )=.  = Library General Public License along with 23  -_. . .   )=.  = Library General Public License along with
24    --        :-=` this library; see the file COPYING.LIB. 24    --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28 28
29*/ 29*/
30 30
31#include "oticker.h" 31#include "oticker.h"
32 32
33/* OPIE */ 33/* OPIE */
34#include <qpe/config.h> 34#include <qpe/config.h>
35 35
36using namespace Opie::Ui;
37
36OTicker::OTicker( QWidget* parent ) 38OTicker::OTicker( QWidget* parent )
37 : QLabel( parent ) 39 : QLabel( parent )
38{ 40{
39 setTextFormat( Qt::RichText ); 41 setTextFormat( Qt::RichText );
40 Config cfg( "qpe" ); 42 Config cfg( "qpe" );
41 cfg.setGroup( "Appearance" ); 43 cfg.setGroup( "Appearance" );
42 backgroundcolor = QColor( cfg.readEntry( "Background", "#E5E1D5" ) ); 44 backgroundcolor = QColor( cfg.readEntry( "Background", "#E5E1D5" ) );
43 foregroundcolor = Qt::black; 45 foregroundcolor = Qt::black;
44 updateTimerTime = 50; 46 updateTimerTime = 50;
45 scrollLength = 1; 47 scrollLength = 1;
46} 48}
47 49
48OTicker::~OTicker() 50OTicker::~OTicker()
49{} 51{}
50 52
51void OTicker::setBackgroundColor( const QColor& backcolor ) 53void OTicker::setBackgroundColor( const QColor& backcolor )
52{ 54{
53 backgroundcolor = backcolor; 55 backgroundcolor = backcolor;
54 update(); 56 update();
55} 57}
56 58
57void OTicker::setForegroundColor( const QColor& backcolor ) 59void OTicker::setForegroundColor( const QColor& backcolor )
58{ 60{
59 foregroundcolor = backcolor; 61 foregroundcolor = backcolor;
60 update(); 62 update();
61} 63}
62 64
63void OTicker::setFrame( int frameStyle ) 65void OTicker::setFrame( int frameStyle )
64{ 66{
65 setFrameStyle( frameStyle /*WinPanel | Sunken */ ); 67 setFrameStyle( frameStyle /*WinPanel | Sunken */ );
66 update(); 68 update();
67} 69}
68 70
69void OTicker::setText( const QString& text ) 71void OTicker::setText( const QString& text )
70{ 72{
71 pos = 0; // reset it everytime the text is changed 73 pos = 0; // reset it everytime the text is changed
72 scrollText = text; 74 scrollText = text;
73 qDebug( scrollText ); 75 qDebug( scrollText );
74 76
75 int pixelLen = 0; 77 int pixelLen = 0;
76 bool bigger = false; 78 bool bigger = false;
77 int contWidth = contentsRect().width(); 79 int contWidth = contentsRect().width();
78 int contHeight = contentsRect().height(); 80 int contHeight = contentsRect().height();
79 int pixelTextLen = fontMetrics().width( text ); 81 int pixelTextLen = fontMetrics().width( text );
80 qDebug( "<<<<<<<height %d, width %d, text width %d %d\n", contHeight, contWidth, pixelTextLen, scrollText.length() ); 82 qDebug( "<<<<<<<height %d, width %d, text width %d %d\n", contHeight, contWidth, pixelTextLen, scrollText.length() );
81 if ( pixelTextLen < contWidth ) 83 if ( pixelTextLen < contWidth )
82 { 84 {
83 pixelLen = contWidth; 85 pixelLen = contWidth;
diff --git a/libqtaux/oticker.h b/libqtaux/oticker.h
index 4026eb5..a89d334 100644
--- a/libqtaux/oticker.h
+++ b/libqtaux/oticker.h
@@ -1,91 +1,94 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3 Copyright (c) 2002 L. Potter <ljp@llornkcor.com> 3 Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
4 =. 4 =.
5 .=l. 5 .=l.
6           .>+-= 6           .>+-=
7 _;:,     .>    :=|. This program is free software; you can 7 _;:,     .>    :=|. This program is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under 8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU General Public 9:`=1 )Y*s>-.--   : the terms of the GNU General Public
10.="- .-=="i,     .._ License as published by the Free Software 10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License, 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version. 12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_. 13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This program is distributed in the hope that 14    .i_,=:_.      -<s. This program is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of 16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more 19..}^=.=       =       ; Library General Public License for more
20++=   -.     .`     .: details. 20++=   -.     .`     .: details.
21 :     =  ...= . :.=- 21 :     =  ...= . :.=-
22 -.   .:....=;==+<; You should have received a copy of the GNU 22 -.   .:....=;==+<; You should have received a copy of the GNU
23  -_. . .   )=.  = Library General Public License along with 23  -_. . .   )=.  = Library General Public License along with
24    --        :-=` this library; see the file COPYING.LIB. 24    --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28 28
29*/ 29*/
30 30
31#ifndef OTICKER_H 31#ifndef OTICKER_H
32#define OTICKER_H 32#define OTICKER_H
33 33
34#include <qwidget.h> 34#include <qwidget.h>
35#include <qpainter.h> 35#include <qpainter.h>
36#include <qdrawutil.h> 36#include <qdrawutil.h>
37#include <qpixmap.h> 37#include <qpixmap.h>
38#include <qstring.h> 38#include <qstring.h>
39#include <qslider.h> 39#include <qslider.h>
40#include <qlabel.h> 40#include <qlabel.h>
41#include <qframe.h> 41#include <qframe.h>
42#include <qcolor.h> 42#include <qcolor.h>
43 43
44
45namespace Opie {
46namespace Ui {
44/** 47/**
45 * @class OTicker 48 * @class OTicker
46 * @brief The OTicker class provides a QLabel widget that scroll its contents 49 * @brief The OTicker class provides a QLabel widget that scroll its contents
47 * 50 *
48 */ 51 */
49class OTicker : public QLabel { 52class OTicker : public QLabel {
50 Q_OBJECT 53 Q_OBJECT
51 54
52public: 55public:
53 56
54/*! 57/*!
55 * @fn OTicker( QWidget* parent = 0 ) 58 * @fn OTicker( QWidget* parent = 0 )
56 * @brief Object constructor. 59 * @brief Object constructor.
57 * 60 *
58 * @param parent Pointer to parent of this control. 61 * @param parent Pointer to parent of this control.
59 62
60 * Constructs a new OTicker control with parent 63 * Constructs a new OTicker control with parent
61 */ 64 */
62 OTicker( QWidget* parent=0 ); 65 OTicker( QWidget* parent=0 );
63/*! 66/*!
64 * @fn ~OTicker() 67 * @fn ~OTicker()
65 * @brief Object destructor. 68 * @brief Object destructor.
66 */ 69 */
67 ~OTicker(); 70 ~OTicker();
68/*! 71/*!
69 * @fn setText(const QString& ) 72 * @fn setText(const QString& )
70 * @brief sets text to be displayed 73 * @brief sets text to be displayed
71 * @param text QString text to be displayed. 74 * @param text QString text to be displayed.
72 * 75 *
73 */ 76 */
74 void setText( const QString& text ) ; 77 void setText( const QString& text ) ;
75/*! 78/*!
76 * @fn setBackgroundColor(const QColor& color) 79 * @fn setBackgroundColor(const QColor& color)
77 * @brief sets color of the ticker's background 80 * @brief sets color of the ticker's background
78 * @param color QColor color to be set. 81 * @param color QColor color to be set.
79 * 82 *
80 */ 83 */
81 void setBackgroundColor(const QColor& color); 84 void setBackgroundColor(const QColor& color);
82/*! 85/*!
83 * @fn setForegroundColor(const QColor& color) 86 * @fn setForegroundColor(const QColor& color)
84 * @brief sets color of text 87 * @brief sets color of text
85 * @param color QColor color of text 88 * @param color QColor color of text
86 * 89 *
87 */ 90 */
88 void setForegroundColor(const QColor& color); 91 void setForegroundColor(const QColor& color);
89/*! 92/*!
90 * @fn setFrame(int style) 93 * @fn setFrame(int style)
91 * @brief sets frame style 94 * @brief sets frame style
@@ -98,49 +101,51 @@ public:
98 * @brief sets time of update 101 * @brief sets time of update
99 * @param timeout int time in milliseconds between updates. 102 * @param timeout int time in milliseconds between updates.
100 * 103 *
101 */ 104 */
102 void setUpdateTime(int timeout); 105 void setUpdateTime(int timeout);
103/*! 106/*!
104 * @fn setScrollLength(int length) 107 * @fn setScrollLength(int length)
105 * @brief sets amount of scrolling default is 1 108 * @brief sets amount of scrolling default is 1
106 * @param length int scroll length. 109 * @param length int scroll length.
107 * 110 *
108 */ 111 */
109 void setScrollLength(int length); 112 void setScrollLength(int length);
110signals: 113signals:
111/*! 114/*!
112 * @fn mousePressed() 115 * @fn mousePressed()
113 * @brief signal mouse press event 116 * @brief signal mouse press event
114 * 117 *
115 */ 118 */
116 void mousePressed(); 119 void mousePressed();
117protected: 120protected:
118/*! 121/*!
119 * @fn timerEvent( QTimerEvent * e) 122 * @fn timerEvent( QTimerEvent * e)
120 * @brief timer timeout event 123 * @brief timer timeout event
121 * @param e QEvent see QEvent. 124 * @param e QEvent see QEvent.
122 * 125 *
123 */ 126 */
124 void timerEvent( QTimerEvent * e); 127 void timerEvent( QTimerEvent * e);
125/*! 128/*!
126 * @fn drawContents( QPainter *p ) 129 * @fn drawContents( QPainter *p )
127 * @brief draws widget contents 130 * @brief draws widget contents
128 * @param p QPainter. see QPainter 131 * @param p QPainter. see QPainter
129 * 132 *
130 */ 133 */
131 void drawContents( QPainter *p ); 134 void drawContents( QPainter *p );
132/*! 135/*!
133 * @fn mouseReleaseEvent( QMouseEvent *e) 136 * @fn mouseReleaseEvent( QMouseEvent *e)
134 * @brief mouse release event 137 * @brief mouse release event
135 * @param e QMouseEvent. see QMouseEvent. 138 * @param e QMouseEvent. see QMouseEvent.
136 * 139 *
137 */ 140 */
138 void mouseReleaseEvent( QMouseEvent *e); 141 void mouseReleaseEvent( QMouseEvent *e);
139private: 142private:
140 QColor backgroundcolor, foregroundcolor; 143 QColor backgroundcolor, foregroundcolor;
141 QString scrollText; 144 QString scrollText;
142 QPixmap scrollTextPixmap; 145 QPixmap scrollTextPixmap;
143 int pos, updateTimerTime, scrollLength; 146 int pos, updateTimerTime, scrollLength;
144}; 147};
145 148
149}
150}
146#endif 151#endif