summaryrefslogtreecommitdiff
path: root/libopie2
Side-by-side diff
Diffstat (limited to 'libopie2') (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
154 files changed, 994 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 @@
#include <opie2/oapplication.h>
#include <opie2/oconfig.h>
#include <qpe/config.h>
+using namespace Opie::Core;
+
int main( int argc, char** argv )
{
OApplication* app = new OApplication( argc, argv, "MyConfigDemoApplication" );
OConfigGroupSaver c1( app->config(), "MyGroup" );
app->config()->writeEntry( "AnEntry", "InMyGroup" );
{
OConfigGroupSaver c2( c1.config(), "AnotherGroup" );
app->config()->writeEntry( "AnEntry", "InAnotherGroup" );
} // closing the scope returns to the last group
app->config()->writeEntry( "AnotherEntry", "InMyGroup" );
// do more stuff ...
// in this (special) case it is necessary to manually call OConfig::write() (see below)
app->config()->write();
// can't delete the app when using the OConfigGroupSaver on top level scope,
// because the destructor of the OConfigGroupSaver needs an application object
//delete app; // destructor deletes config which writes changes back to disk
return 0;
}
//#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,115 +1,117 @@
/* QT */
#include <qvbox.h>
#include <qhbox.h>
#include <qvbuttongroup.h>
#include <qhbuttongroup.h>
#include <qlineedit.h>
#include <qradiobutton.h>
#include <qpushbutton.h>
/* OPIE */
#include <qpe/config.h>
#include <opie2/odebug.h>
#include <opie2/oapplication.h>
#include <opie2/oglobal.h>
#include <opie2/oglobalsettings.h>
+using namespace Opie::Core;
+
class DemoApp : public OApplication
{
Q_OBJECT
public:
DemoApp( int argc, char** argv ) : OApplication( argc, argv, "libopie2 debug demo" )
{
// you have access to your OApplication object via oApp
qDebug( "Process-wide OApplication object @ %0x", oApp );
// you have access to global settings via OGlobalSettings
int mode = OGlobalSettings::debugMode();
QVBox* vbox = new QVBox();
setMainWidget( vbox );
g = new QVButtonGroup( "Output Strategy", vbox );
QRadioButton* r0 = new QRadioButton( "file", g );
QRadioButton* r1 = new QRadioButton( "messagebox", g );
QRadioButton* r2 = new QRadioButton( "stderr", g );
QRadioButton* r3 = new QRadioButton( "syslog", g );
QRadioButton* r4 = new QRadioButton( "socket", g );
g->insert( r0, 0 );
g->insert( r1, 1 );
g->insert( r2, 2 );
g->insert( r3, 3 );
g->insert( r4, 4 );
g->setRadioButtonExclusive( true );
connect( g, SIGNAL( clicked(int) ), this, SLOT( chooseMethod(int) ) );
if ( mode != -1 ) g->setButton( mode );
QHButtonGroup* hbox = new QHButtonGroup( "Extra Output Information", vbox );
e = new QLineEdit( hbox );
QPushButton* pb = new QPushButton( hbox );
connect( e, SIGNAL( returnPressed() ), this, SLOT( updateDebugOutput() ) );
connect( pb, SIGNAL( clicked() ), this, SLOT( updateDebugOutput() ) );
// show the additional debug mode dependent output information
e->setText( OGlobalSettings::debugOutput() );
// buttos
QPushButton* info = new QPushButton( "Emit Debug(Info) Output!", vbox );
connect( info, SIGNAL( clicked() ), this, SLOT( emitInfoOutput() ) );
QPushButton* warn = new QPushButton( "Emit a Warning Output!", vbox );
connect( warn, SIGNAL( clicked() ), this, SLOT( emitWarningOutput() ) );
QPushButton* error = new QPushButton( "Emit an Error Output!", vbox );
connect( error, SIGNAL( clicked() ), this, SLOT( emitErrorOutput() ) );
QPushButton* fatal = new QPushButton( "Emit a Fatal Output!", vbox );
connect( fatal, SIGNAL( clicked() ), this, SLOT( emitFatalOutput() ) );
QPushButton* tb = new QPushButton( "Emit a Fatal Backtrace!", vbox );
connect( tb, SIGNAL( clicked() ), this, SLOT( emitTBOutput() ) );
info->show();
warn->show();
error->show();
fatal->show();
tb->show();
g->show();
hbox->show();
e->show();
vbox->show();
showMainWidget( vbox );
}
public slots:
void chooseMethod(int method)
{
m = method;
qDebug( "choosing method: %d", method );
OConfig* g = OGlobal::config();
g->setGroup( "General" );
g->writeEntry( "debugMode", m );
e->setText( OGlobalSettings::debugOutput() );
g->write();
}
void updateDebugOutput()
{
OConfig* g = OGlobal::config();
g->setGroup( "General" );
g->writeEntry( "debugOutput"+QString::number(OGlobalSettings::debugMode()), e->text() );
g->write();
}
void emitInfoOutput()
{
odebug << "This is a debug message" << oendl;
}
void emitWarningOutput()
{
owarn << "This is a warning message" << oendl;
}
void emitErrorOutput()
{
oerr << "This is an errror message" << oendl;
}
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 @@
#include <opie2/oglobalsettings.h>
-#include <iostream.h>
+#include <iostream>
+
+using namespace Opie::Core;
int main( int argc, char** argv )
{
printf( "current debugmode seems to be '%d'\n", OGlobalSettings::debugMode() );
printf( "output information for this mode is '%s'\n", (const char*) OGlobalSettings::debugOutput() );
return 0;
}
//#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 @@
#include <opie2/oprocess.h>
-#include <iostream.h>
+#include <iostream>
+
+using namespace Opie::Core;
int main( int argc, char** argv )
{
printf( "my own PID seems to be '%d'\n", OProcess::processPID( "oprocessdemo" ) );
printf( "the PID of process 'Mickey' seems to be '%d'\n\n", OProcess::processPID( "Mickey" ) );
return 0;
}
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 @@
#include <qdir.h>
#include <qpe/qpeapplication.h>
-#include "../osqlmanager.h"
-#include "../osqlquery.h"
-#include "../osqldriver.h"
-#include "../osqlresult.h"
+#include <opie2/osqlmanager.h>
+#include <opie2/osqlquery.h>
+#include <opie2/osqldriver.h>
+#include <opie2/osqlresult.h>
+
+using namespace Opie::DB;
int main( int argc, char* argv[] ) {
QPEApplication app( argc, argv );
OSQLManager man;
man.registerPath( QDir::currentDirPath() );
OSQLBackEnd::ValueList list = man.queryBackEnd();
OSQLDriver *driver = man.standard();
qWarning("testmain" + driver->id() );
driver->setUrl("/home/ich/spaltenweise");
if ( driver->open() ) {
qWarning("could open");
}else
qWarning("wasn't able to open");
OSQLRawQuery *raw = new OSQLRawQuery("create table todolist("
"uid,categories,completed,"
"progress,summary,HasDate,"
"DateDay,DateMonth,DateYear,"
"priority,description)" );
OSQLResult res = driver->query( raw );
delete raw;
for (int i = 0; i< 10000; i++ ) {
int uid = i;
OSQLRawQuery raw("insert into todolist VALUES("+
QString::number(uid)+ ",'-122324;-12132',1,100,"+
"'Summary234-"+QString::number(uid)+"',1,5,8,2002,1,"+
"'Description\n12344')");
OSQLResult res = driver->query( &raw );
}
return 0;
};
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 @@
TEMPLATE = app
CONFIG = qt warn_on release
HEADERS =
SOURCES = spaltenweise.cpp
INCLUDEPATH += $(OPIEDIR)/include
DEPENDPATH += $(OPIEDIR)/include
-LIBS += -lqpe -lopiesql
+LIBS += -lqpe -lopiedb2
TARGET = spaltenweise
include ( $(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,84 +1,86 @@
#include <qdir.h>
#include <qpe/qpeapplication.h>
-#include "../osqlmanager.h"
-#include "../osqlquery.h"
-#include "../osqldriver.h"
-#include "../osqlresult.h"
+#include <opie2/osqlmanager.h>
+#include <opie2/osqlquery.h>
+#include <opie2/osqldriver.h>
+#include <opie2/osqlresult.h>
+
+using namespace Opie::DB;
int main( int argc, char* argv[] ) {
QPEApplication app( argc, argv );
OSQLManager man;
man.registerPath( QDir::currentDirPath() );
OSQLBackEnd::ValueList list = man.queryBackEnd();
OSQLDriver *driver = man.standard();
qWarning("testmain" + driver->id() );
driver->setUrl("/home/ich/zeilenweise");
if ( driver->open() ) {
qWarning("could open");
}else
qWarning("wasn't able to open");
OSQLRawQuery raw2("BEGIN TRANSACTION");
OSQLRawQuery *raw = new OSQLRawQuery("create table todolist(uid,key,value)");
OSQLResult res = driver->query( &raw2 );
res = driver->query( raw );
delete raw;
for (int i = 0; i< 10000; i++ ) {
int uid = i;
OSQLRawQuery *raw;
raw = new OSQLRawQuery("insert into todolist VALUES("+QString::number(uid)+",'Categories',"+"'-122324;-12132')");
OSQLResult res = driver->query(raw );
delete raw;
raw = new OSQLRawQuery("insert into todolist VALUES("+QString::number(uid) +
",'Completed',1)" );
res = driver->query(raw );
delete raw;
raw = new OSQLRawQuery("insert into todolist VALUES("+
QString::number(uid)+",'Progress',100)" );
res = driver->query( raw );
delete raw;
raw = new OSQLRawQuery("insert into todolist VALUES("+
QString::number(uid)+",'Summary',"+
"'Summary234-"+ QString::number(uid) + "')");
res = driver->query( raw );
delete raw;
raw = new OSQLRawQuery("insert into todolist VALUES("+
QString::number(uid)+",'HasDate',1)");
res = driver->query( raw );
delete raw;
raw = new OSQLRawQuery("insert into todolist VALUES("+
QString::number(uid)+",'DateDay',5)");
res = driver->query( raw );
delete raw;
raw = new OSQLRawQuery("insert into todolist VALUES("+
QString::number(uid)+",'DateMonth',8)");
res = driver->query( raw );
delete raw;
raw = new OSQLRawQuery("insert into todolist VALUES("+
QString::number(uid)+",'DateYear',2002)");
res = driver->query( raw );
delete raw;
raw = new OSQLRawQuery("insert into todolist VALUES("+
QString::number(uid)+",'Priority',1)");
res = driver->query( raw );
delete raw;
raw = new OSQLRawQuery("insert into todolist VALUES("+
QString::number(uid)+",'Description','" +
QString::number(uid) + "Description\n12344')");
res = driver->query( raw );
delete raw;
}
OSQLRawQuery raw3("COMMIT");
res = driver->query(&raw3 );
};
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 @@
TEMPLATE = app
CONFIG = qt warn_on release
HEADERS =
SOURCES = zeilenweise.cpp
INCLUDEPATH += $(OPIEDIR)/include
DEPENDPATH += $(OPIEDIR)/include
-LIBS += -lqpe -lopiesql
+LIBS += -lqpe -lopiedb2
TARGET = zeilenweise
include ( $(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 @@
#include <opie2/osoundsystem.h>
+using namespace Opie::MM;
+
int main( int argc, char** argv )
{
qDebug( "OPIE Sound System Demo" );
OSoundSystem* sound = OSoundSystem::instance();
OSoundSystem::CardIterator it = sound->iterator();
/*
while ( it.current() )
{
qDebug( "DEMO: OSoundSystem contains Interface '%s'", (const char*) it.current()->name() );
++it;
}
*/
OSoundCard* card = it.current();
OMixerInterface* mixer = card->mixer();
QStringList channels = mixer->allChannels();
for ( QStringList::Iterator it = channels.begin(); it != channels.end(); ++it )
{
qDebug( "OSSDEMO: Mixer has channel %s", (const char*) *it );
qDebug( "OSSDEMO: +--- volume %d (left) | %d (right)", mixer->volume( *it ) & 0xff, mixer->volume( *it ) >> 8 );
}
return 0;
}
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,107 +1,109 @@
#include <qdict.h>
#include <qsocketnotifier.h>
#include <qstring.h>
#include <opie2/onetwork.h>
#include <qapplication.h>
#include <opie2/opcap.h>
#include <cerrno>
#include <cstdio>
#include <cstdlib>
#include <cstring>
+
+using namespace Opie::Net;
//======================== Station help class ===============================
class Station
{
public:
Station( QString t, int c, bool w ) : type(t), channel(c), wep(w), beacons(1) {};
~Station() {};
QString type;
int channel;
bool wep;
int beacons;
};
QDict<Station> stations;
//======================== Application class ===============================
class Wellenreiter : public QApplication
{
Q_OBJECT
public:
Wellenreiter( int argc, char** argv ) : QApplication( argc, argv ), channel( 1 )
{
ONetwork* net = ONetwork::instance();
if ( argc < 3 )
{
printf( "Usage: ./%s <interface> <driver> <interval>\n", argv[0] );
printf( "\n" );
printf( "Valid wireless interfaces (detected) are:\n" );
ONetwork::InterfaceIterator it = net->iterator();
while ( it.current() )
{
if ( it.current()->isWireless() )
{
printf( " - '%s' (MAC=%s) (IPv4=%s)\n", (const char*) it.current()->name(),
(const char*) it.current()->macAddress().toString(),
(const char*) it.current()->ipV4Address() );
}
++it;
}
exit( -1 );
}
printf( "*******************************************************************\n" );
printf( "* Wellenreiter mini edition 1.0.0 (C) 2003 Michael 'Mickey' Lauer *\n" );
printf( "*******************************************************************\n" );
printf( "\n\n" );
QString interface( argv[1] );
QString driver( argv[2] );
printf( "Trying to use '%s' as %s-controlled device...\n", (const char*) interface, (const char*) driver );
// sanity checks before downcasting
ONetworkInterface* iface = net->interface( interface );
if ( !iface )
{
printf( "Interface '%s' doesn't exist. Exiting.\n", (const char*) interface );
exit( -1 );
}
if ( !iface->isWireless() )
{
printf( "Interface '%s' doesn't support wireless extensions. Exiting.\n", (const char*) interface );
exit( -1 );
}
// downcast should be safe now
wiface = (OWirelessNetworkInterface*) iface;
printf( "Using wireless interface '%s' for scanning (current SSID is '%s')...\n", (const char*) interface, (const char*) wiface->SSID() );
// ifconfig +promisc the interface to receive all packets
if ( !wiface->promiscuousMode() )
{
printf( "Interface status is not promisc... switching to promisc... " );
wiface->setPromiscuousMode( true );
if ( !wiface->promiscuousMode() )
{
printf( "failed (%s). Exiting.\n", strerror( errno ) );
exit( -1 );
}
else
{
printf( "ok.\n" );
}
}
else
printf( "Interface status is already promisc - good.\n" );
// connect a monitoring strategy to the interface
if ( driver == "orinoco" )
new OOrinocoMonitoringInterface( wiface, false );
else
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,102 +1,104 @@
#include <opie2/onetwork.h>
#include <opie2/ostation.h>
#include <opie2/omanufacturerdb.h>
#include <unistd.h>
+using namespace Opie::Net;
+
int main( int argc, char** argv )
{
qDebug( "OPIE Network Demo" );
ONetwork* net = ONetwork::instance();
ONetwork::InterfaceIterator it = net->iterator();
while ( it.current() )
{
qDebug( "DEMO: ONetwork contains Interface '%s'", (const char*) it.current()->name() );
qDebug( "DEMO: Datalink code is '%d'", it.current()->dataLinkType() );
qDebug( "DEMO: MAC Address is '%s'", (const char*) it.current()->macAddress().toString() );
qDebug( "DEMO: MAC Address is '%s'", (const char*) it.current()->macAddress().toString(true) );
qDebug( "DEMO: MAC Manufacturer seems to be '%s'", (const char*) it.current()->macAddress().manufacturer() );
qDebug( "DEMO: Manufacturertest1 = '%s'", (const char*) OManufacturerDB::instance()->lookupExt( "08:00:87" ) );
qDebug( "DEMO: Manufacturertest2 = '%s'", (const char*) OManufacturerDB::instance()->lookupExt( "E2:0C:0F" ) );
qDebug( "Demo: IPv4 Address is '%s'", (const char*) it.current()->ipV4Address() );
if ( it.current()->isWireless() )
{
OWirelessNetworkInterface* iface = static_cast<OWirelessNetworkInterface*>( it.current() );
qDebug( "DEMO: '%s' seems to feature the wireless extensions.", (const char*) iface->name() );
qDebug( "DEMO: Current SSID is '%s'", (const char*) iface->SSID() );
qDebug( "DEMO: Antenna is tuned to '%f', that is channel %d", iface->frequency(), iface->channel() );
//if ( iface->mode() == OWirelessNetworkInterface::adhoc )
//{
//qDebug( "DEMO: Associated AP has MAC Address '%s'", (const char*) iface->associatedAP().toString() );
//}
/*
// nickname
qDebug( "DEMO: Current NickName is '%s'", (const char*) iface->nickName() );
iface->setNickName( "MyNickName" );
if ( iface->nickName() != "MyNickName" )
qDebug( "DEMO: Warning! Can't change nickname" );
else
qDebug( "DEMO: Nickname change successful." );
/*
// operation mode
qDebug( "DEMO: Current OperationMode is '%s'", (const char*) iface->mode() );
iface->setMode( "adhoc" );
if ( iface->mode() != "adhoc" )
qDebug( "DEMO: Warning! Can't change operation mode" );
else
qDebug( "DEMO: Operation Mode change successful." );
// RF channel
qDebug( "DEMO: Current Channel is '%d'", iface->channel() );
iface->setChannel( 1 );
if ( iface->channel() != 1 )
qDebug( "DEMO: Warning! Can't change RF channel" );
else
qDebug( "DEMO: RF channel change successful." );
iface->setMode( "managed" );
*/
/*
// network scan
OStationList* stations = iface->scanNetwork();
if ( stations )
{
qDebug( "DEMO: # of stations around = %d", stations->count() );
OStation* station;
for ( station = stations->first(); station != 0; station = stations->next() )
{
qDebug( "DEMO: station dump following..." );
station->dump();
}
}
else
{
qDebug( "DEMO: Warning! Scan didn't work!" );
}
/*
// first some wrong calls to check if this is working
iface->setPrivate( "seppel", 10 );
iface->setPrivate( "monitor", 0 );
// now the real deal
iface->setPrivate( "monitor", 2, 2, 3 );
// trying to set hw address to 12:34:56:AB:CD:EF
/*
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 @@
/**********************************************************************
** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved.
**
** This file is part of Opie Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
**********************************************************************/
#include "olistviewdemo.h"
#include <opie2/oapplication.h>
+using namespace Opie::Ui;
+using namespace Opie::Core;
+
int main( int argc, char **argv )
{
OApplication a( argc, argv, "OListViewDemo" );
OListViewDemo e;
a.showMainWidget(&e);
return a.exec();
}
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 @@
/*
                This file is part of the Opie Project
              Copyright (C) 2003 Michael 'Mickey' Lauer
<mickey@tm.informatik.uni-frankfurt.de>
=.
.=l.
           .>+-=
 _;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include "olistviewdemo.h"
#include <opie2/olistview.h>
#include <qstring.h>
#include <qpixmap.h>
#include <qlistview.h>
+using namespace Opie::Ui;
+
OListViewDemo::OListViewDemo( QWidget* parent, const char* name, WFlags f )
:QVBox( parent, name, f )
{
lv = new ONamedListView( this );
lv->setRootIsDecorated( true );
lv->addColumns( QStringList::split( ' ', "Column1 Column2 Column3 Column4" ) );
ONamedListViewItem* item = new ONamedListViewItem( lv, QStringList::split( ' ', "Text1 Text2 Text3 Text4" ) );
item->setText( "Column2", "ModifiedText" );
item->setText( "Column5", "ThisColumnDoesNotExits" );
new ONamedListViewItem( lv, QStringList::split( ' ', "Text1 Text2 Text3 Text4" ) );
new ONamedListViewItem( lv, QStringList::split( ' ', "Text1 Text2 Text3 Text4" ) );
new ONamedListViewItem( lv, QStringList::split( ' ', "Text1 Text2 Text3 Minni" ) );
item = new ONamedListViewItem( lv, QStringList::split( ' ', "XXX YYY ZZZ ***" ) );
new ONamedListViewItem( lv, QStringList::split( ' ', "Text1 Text2 Text3 Text4" ) );
new ONamedListViewItem( lv, QStringList::split( ' ', "Text1 Text2 Text3 Text4" ) );
new ONamedListViewItem( item, QStringList::split( ' ', "SubText1 Text2 Text3 Text4" ) );
new ONamedListViewItem( item, QStringList::split( ' ', "SubText1 Text2 Text3 Text4" ) );
new ONamedListViewItem( item, QStringList::split( ' ', "SubText1 Text2 Text3 Text4" ) );
item = new ONamedListViewItem( item, QStringList::split( ' ', "Text1 Text2 Text3 HereItComes" ) );
item = new ONamedListViewItem( item, QStringList::split( ' ', "Text1 Text2 Text3 HereItComesSoon" ) );
item = new ONamedListViewItem( item, QStringList::split( ' ', "Text1 Text2 Text3 Mickey" ) );
if ( lv->find( 3, "Mickey", 3 ) )
qDebug( "found Mickey :-)" );
else
qDebug( "did not found Mickey :-(" );
if ( lv->find( 3, "Minni", 0 ) )
qDebug( "found Minni :-)" );
else
qDebug( "did not found Minni :-(" );
}
OListViewDemo::~OListViewDemo()
{
}
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 @@
/*
                This file is part of the Opie Project
              Copyright (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
=.
.=l.
           .>+-=
 _;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef OLISTVIEWDEMO_H
#define OLISTVIEWDEMO_H
#include <qvbox.h>
#include <opie2/olistview.h>
class OListViewDemo: public QVBox
{
Q_OBJECT
public:
OListViewDemo( QWidget* parent=0, const char* name=0, WFlags f=0 );
virtual ~OListViewDemo();
private:
- ONamedListView* lv;
+ Opie::Ui::ONamedListView* lv;
};
#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 @@
#include "osplitter_example.h"
/* OPIE */
#include <opie2/osplitter.h>
+#include <opie2/ofileselector.h>
#include <qpe/qpeapplication.h>
#include <opie2/oapplicationfactory.h>
/* QT*/
#include <qdir.h>
#include <qlayout.h>
-using namespace Opie;
+using namespace Opie::Ui;
OPIE_EXPORT_APP( OApplicationFactory<OSplitterExample> )
OSplitterExample::OSplitterExample( QWidget *w,const char* n,WFlags f )
: QWidget( w, n, f ){
QVBoxLayout * lay = new QVBoxLayout(this);
OSplitter * splitter = new OSplitter( Horizontal, this );
lay->addWidget( splitter );
OFileSelector *selector = new OFileSelector( splitter, OFileSelector::FileSelector,
OFileSelector::Normal, QDir::homeDirPath(),
QString::null );
splitter->addWidget( selector, "zoom", tr("Selector 1") );
selector = new OFileSelector( splitter, OFileSelector::FileSelector, OFileSelector::Normal,
QDir::homeDirPath(), QString::null );
splitter->addWidget( selector, "zoom", tr("Selector 2") );
}
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 @@
/*
* May be used, copied and modified wihtout any limitation
*/
#ifndef OSPlitter_EXAMPLE_H
#define OSPlitter_EXAMPLE_H
#include <qvbox.h>
-#include <opie2/ofileselector.h>
class OSplitterExample : public QWidget {
Q_OBJECT
public:
static QString appName() { return QString::fromLatin1("osplitter_example"); }
OSplitterExample( QWidget *parent, const char* name, WFlags fl );
};
#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 @@
#include <qstring.h>
#include <qlabel.h>
#include <qheader.h>
#include <qlayout.h>
#include <qpe/qpeapplication.h>
#include <opie2/oapplicationfactory.h>
#include "osplitter_mail.h"
+using namespace Opie::Ui;
+
OPIE_EXPORT_APP( OApplicationFactory<ListViews> )
class Folder {
int dummy;
};
// -----------------------------------------------------------------
ListViews::ListViews( QWidget* p, const char* name, WFlags fl )
: QWidget( p, name, fl ) {
qApp->installEventFilter( this );
m_lstFolders.setAutoDelete( true );
QHBoxLayout *lay = new QHBoxLayout(this);
m_splitter = new OSplitter( Horizontal, this, "SPlitter 1" );
lay->addWidget( m_splitter );
- connect(m_splitter, SIGNAL(sizeChange(bool,const QSize&) ),
- this, SLOT(slotSizeChange(bool,const QSize&) ) );
+ connect(m_splitter, SIGNAL(sizeChanged(bool,Orientation) ),
+ this, SLOT(slotSizeChange(bool,Orientation) ) );
m_overview = new QListView( m_splitter );
m_overview->header()->setClickEnabled( FALSE );
m_overview->addColumn( tr("Folder") );
- m_overview->setMaximumWidth( 200 );
+// m_overview->setMaximumWidth( 200 );
m_splitter->addWidget( m_overview, "zoom", tr("Folder Overview") );
m_splitter->setSizeChange( 300 );
/* OSplitter starts with the small mode */
m_messages = 0;
m_message = m_attach = 0;
splitti = new OSplitter( Vertical, m_splitter, "Splitti2" );
splitti->setSizeChange( 300 );
splitti->setSizePolicy( QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding ) );
QLabel *lbl = new QLabel(splitti);
lbl->setTextFormat ( Qt::RichText );
lbl->setText("<br><br><b>Test Test Test</b><br><br><p>Fooooo hjhh</p>");
m_messages = new QListView( splitti );
m_messages->addColumn(" Messages ");
folder1 = new QListView( splitti );
folder1->addColumn( "Messages 2 " );
splitti->addWidget(m_messages, "mail", tr("Mails") );
splitti->addWidget(folder1, "folder", tr("Folder") );
splitti->addWidget( lbl, "logo", tr("Label") );
m_message = lbl;
m_splitter->addWidget( splitti );
}
ListViews::~ListViews() {
}
bool ListViews::eventFilter( QObject* obj, QEvent* ev ) {
if (!obj->isWidgetType() )
return false;
if ( ev->type() == QEvent::MouseButtonRelease ) {
qWarning(" name %s, class %s", obj->name(), obj->className() );
}
return false;
}
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 @@
/*
* You may use, modify and distribute this code without any limitation
*/
/*
* Header file for a more complete email client like
* layout
*/
#ifndef OPIE_SPLITTER_MAIL_EXAMPLE_H
#define OPIE_SPLITTER_MAIL_EXAMPLE_H
#include <qwidget.h>
#include <qlist.h>
#include <qlistview.h>
#include <opie2/osplitter.h>
-using Opie::OSplitter;
class Folder;
class QLabel;
-class OSplitter;
class ListViews : public QWidget {
Q_OBJECT
public:
static QString appName() { return QString::fromLatin1("osplitter-mail"); }
ListViews( QWidget* parent, const char * name, WFlags fl );
~ListViews();
bool eventFilter( QObject* , QEvent* );
private:
void initFolders();
void initFolder( Folder *folder, unsigned int &count );
QListView *m_messages, *m_overview;
QLabel *m_message, *m_attach;
QList<QListView> m_folders; // used in tab mode
QList<Folder> m_lstFolders;
bool m_mode : 1; // bitfield
- OSplitter *m_splitter;
- OSplitter *splitti;
+ Opie::Ui::OSplitter *m_splitter;
+ Opie::Ui::OSplitter *splitti;
QListView *folder1;
#if 0
//private slots:
// void slotFolderChanged( QListViewItem* );
// void slotMessageChanged();
// void slotSizeChange( bool, const QSize& );
#endif
};
#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 @@
/**********************************************************************
** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved.
**
** This file is part of Opie Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
**********************************************************************/
#include "opieuidemo.h"
#include <opie2/oapplication.h>
+using namespace Opie::Core;
+using namespace Opie::Ui;
+
int main( int argc, char **argv )
{
OApplication a( argc, argv, "Opie UI Demo" );
qDebug( "." );
OpieUIDemo e;
qDebug( "." );
a.showMainWidget(&e);
qDebug( "." );
return a.exec();
}
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,149 +1,147 @@
/**********************************************************************
** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved.
**
** This file is part of Opie Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
***********************************************************************/
// Qt
#include <qcolor.h>
#include <qpopupmenu.h>
#include <qmenubar.h>
#include <qmessagebox.h>
#include <qvbox.h>
#include <qstring.h>
#include <qstringlist.h>
// Qtopia
-#ifdef QWS
#include <qpe/qpeapplication.h>
#include <qpe/global.h>
-#endif
// Opie
-#ifdef QWS
#include <opie2/odevice.h>
-using namespace Opie;
-#endif
#include <opie2/ocompletionbox.h>
#include <opie2/olineedit.h>
#include <opie2/ocombobox.h>
#include <opie2/oeditlistbox.h>
#include <opie2/oselector.h>
#include <opie2/opopupmenu.h>
#include <qtabwidget.h>
#include "oversatileviewdemo.h"
// Local
#include "opieuidemo.h"
+using namespace Opie::Core;
+using namespace Opie::Ui;
+
enum Demos { ocompletionbox, olineedit, ocombobox, oeditlistbox, oselector };
OpieUIDemo::OpieUIDemo( QWidget* parent, const char* name, WFlags fl )
: QMainWindow( parent, name, fl )
{
QMenuBar* mbar = this->menuBar();
OPopupMenu* demo = new OPopupMenu( this );
demo->setTitle( "Title" );
demo->setItemParameter( demo->insertItem( "OCompletionBox", this, SLOT( demo(int) ) ), ocompletionbox );
demo->setItemParameter( demo->insertItem( "OLineEdit", this, SLOT( demo(int) ) ), olineedit );
demo->setItemParameter( demo->insertItem( "OComboBox", this, SLOT( demo(int) ) ), ocombobox );
demo->setItemParameter( demo->insertItem( "OEditListBox", this, SLOT( demo(int) ) ), oeditlistbox );
demo->setItemParameter( demo->insertItem( "OSelector", this, SLOT( demo(int) ) ), oselector );
mbar->insertItem( "Demonstrate", demo );
build();
}
OpieUIDemo::~OpieUIDemo()
{
}
void OpieUIDemo::build()
{
main = new QTabWidget( this, "tabwidget" );
setCentralWidget( main );
main->show();
main->addTab( new OVersatileViewDemo( main ), "VersatileView" );
}
void OpieUIDemo::demo( int d )
{
switch (d)
{
case ocompletionbox: demoOCompletionBox(); break;
case olineedit: demoOLineEdit(); break;
case ocombobox: demoOComboBox(); break;
case oeditlistbox: demoOEditListBox(); break;
case oselector: demoOSelector(); break;
}
}
void OpieUIDemo::demoOCompletionBox()
{
qDebug( "ocompletionbox" );
OCompletionBox* box = new OCompletionBox( 0 );
box->insertItem( "This CompletionBox" );
box->insertItem( "Says 'Hello World'" );
box->insertItem( "Here are some" );
box->insertItem( "Additional Items" );
box->insertItem( "Complete Completion Box" );
connect( box, SIGNAL( activated(const QString&) ), this, SLOT( messageBox(const QString&) ) );
box->popup();
}
void OpieUIDemo::demoOLineEdit()
{
qDebug( "olineedit" );
OLineEdit *edit = new OLineEdit( 0, "lineedit" );
edit->setCompletionMode( OGlobalSettings::CompletionPopup );
OCompletion* comp = edit->completionObject();
QStringList list;
list << "mickeyl@handhelds.org";
list << "mickey@tm.informatik.uni-frankfurt.de";
list << "mickey@vanille.de";
comp->setItems( list );
edit->show();
}
void OpieUIDemo::demoOComboBox()
{
qDebug( "ocombobox" );
OComboBox *combo = new OComboBox( true, 0, "combobox" );
combo->setCompletionMode( OGlobalSettings::CompletionPopup );
OCompletion* comp = combo->completionObject();
QStringList ilist;
ilist << "kergoth@handhelds.org";
ilist << "harlekin@handhelds.org";
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 @@
/**********************************************************************
** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved.
**
** This file is part of Opie Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
**********************************************************************/
#ifndef OPIEUIDEMO_H
#define OPIEUIDEMO_H
#include <qmainwindow.h>
+namespace Opie {
+namespace Ui {
class OVersatileView;
+}
+}
class QTabWidget;
class QVBox;
class OpieUIDemo : public QMainWindow {
Q_OBJECT
public:
OpieUIDemo( QWidget* parent = 0, const char* name = 0, WFlags fl = WType_TopLevel );
~OpieUIDemo();
void demoOCompletionBox();
void demoOLineEdit();
void demoOComboBox();
void demoOEditListBox();
void demoOSelector();
public slots:
void demo( int );
void messageBox( const QString& text );
protected:
void build();
void buildVV( QVBox* b );
private:
QTabWidget* main;
- OVersatileView* vv;
+ Opie::Ui::OVersatileView* vv;
};
#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,136 +1,138 @@
/*
                This file is part of the Opie Project
              Copyright (C) 2003 Michael 'Mickey' Lauer
<mickey@tm.informatik.uni-frankfurt.de>
=.
.=l.
           .>+-=
 _;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include "oversatileviewdemo.h"
#include <opie2/oversatileview.h>
#include <opie2/oversatileviewitem.h>
#include <qstring.h>
#include <qpixmap.h>
#include <qlistview.h>
+using namespace Opie::Ui;
+
OVersatileViewDemo::OVersatileViewDemo( QWidget* parent, const char* name, WFlags f )
:QVBox( parent, name, f )
{
vv = new OVersatileView( this );
vv->addColumn( "First" );
vv->addColumn( "2nd" );
vv->addColumn( "IIIrd" );
QString counter;
QPixmap leaf( "leaf.png" );
QPixmap opened( "folder_opened.png" );
QPixmap closed( "folder_closed.png" );
QPixmap leaf32( "leaf32.png" );
QPixmap opened32( "folder_opened32.png" );
QPixmap closed32( "folder_closed32.png" );
vv->setDefaultPixmaps( OVersatileView::Tree, leaf, opened, closed );
vv->setDefaultPixmaps( OVersatileView::Icons, leaf32, opened32, closed32 );
OVersatileViewItem* item;
OVersatileViewItem* item2;
for ( int i = 0; i < 5; ++i )
{
counter.sprintf( "%d", i );
item = new OVersatileViewItem( vv, "Item", "Text", "Some more", counter );
item->setRenameEnabled( true );
item2 = new OVersatileViewItem( item, "OSubitem", "123", "...", counter );
item2->setRenameEnabled( true );
}
connect( vv, SIGNAL( selectionChanged() ), this, SLOT( selectionChanged() ) );
connect( vv, SIGNAL( selectionChanged(OVersatileViewItem*) ), this, SLOT( selectionChanged(OVersatileViewItem*) ) );
connect( vv, SIGNAL( currentChanged(OVersatileViewItem*) ), this, SLOT( currentChanged(OVersatileViewItem*) ) );
connect( vv, SIGNAL( clicked(OVersatileViewItem*) ), this, SLOT( clicked(OVersatileViewItem*) ) );
connect( vv, SIGNAL( pressed(OVersatileViewItem*) ), this, SLOT( pressed(OVersatileViewItem*) ) );
connect( vv, SIGNAL( doubleClicked(OVersatileViewItem*) ), this, SLOT( doubleClicked(OVersatileViewItem*) ) );
connect( vv, SIGNAL( returnPressed(OVersatileViewItem*) ), this, SLOT( returnPressed(OVersatileViewItem*) ) );
connect( vv, SIGNAL( onItem(OVersatileViewItem*) ), this, SLOT( onItem(OVersatileViewItem*) ) );
connect( vv, SIGNAL( onViewport() ), this, SLOT( onViewport() ) );
connect( vv, SIGNAL( expanded(OVersatileViewItem*) ), this, SLOT( expanded(OVersatileViewItem*) ) );
connect( vv, SIGNAL( collapsed(OVersatileViewItem*) ), this, SLOT( collapsed(OVersatileViewItem*) ) );
connect( vv, SIGNAL( moved() ), this, SLOT( moved() ) );
connect( vv, SIGNAL( contextMenuRequested(OVersatileViewItem*,const QPoint&,int) ), this, SLOT( contextMenuRequested(OVersatileViewItem*,const QPoint&,int) ) );
}
OVersatileViewDemo::~OVersatileViewDemo()
{
}
void OVersatileViewDemo::selectionChanged()
{
qDebug( "received signal selectionChanged()" );
}
void OVersatileViewDemo::selectionChanged( OVersatileViewItem * item )
{
qDebug( "received signal selectionChanged(OVersatileViewItem*)" );
}
void OVersatileViewDemo::currentChanged( OVersatileViewItem * item )
{
qDebug( "received signal currentChanged( OVersatileViewItem * )" );
}
void OVersatileViewDemo::clicked( OVersatileViewItem * item )
{
qDebug( "received signal clicked( OVersatileViewItem * )" );
}
void OVersatileViewDemo::pressed( OVersatileViewItem * item )
{
qDebug( "received signal pressed( OVersatileViewItem * )" );
}
void OVersatileViewDemo::doubleClicked( OVersatileViewItem *item )
{
qDebug( "received signal doubleClicked( OVersatileViewItem *item )" );
}
void OVersatileViewDemo::returnPressed( OVersatileViewItem *item )
{
qDebug( "received signal returnPressed( OVersatileViewItem *item )" );
}
void OVersatileViewDemo::onItem( OVersatileViewItem *item )
{
qDebug( "received signal onItem( OVersatileViewItem *item )" );
}
void OVersatileViewDemo::onViewport()
{
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 @@
/*
                This file is part of the Opie Project
              Copyright (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
=.
.=l.
           .>+-=
 _;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef OVERSATILEVIEWDEMO_H
#define OVERSATILEVIEWDEMO_H
#include <qvbox.h>
+namespace Opie {
+namespace Ui {
class OVersatileView;
class OVersatileViewItem;
+}
+}
class OVersatileViewDemo: public QVBox
{
Q_OBJECT
public:
OVersatileViewDemo( QWidget* parent=0, const char* name=0, WFlags f=0 );
virtual ~OVersatileViewDemo();
public slots:
void selectionChanged();
- void selectionChanged( OVersatileViewItem * );
- void currentChanged( OVersatileViewItem * );
- void clicked( OVersatileViewItem * );
- void pressed( OVersatileViewItem * );
+ void selectionChanged( Opie::Ui::OVersatileViewItem * );
+ void currentChanged( Opie::Ui::OVersatileViewItem * );
+ void clicked( Opie::Ui::OVersatileViewItem * );
+ void pressed( OPie::Ui::OVersatileViewItem * );
- void doubleClicked( OVersatileViewItem *item );
- void returnPressed( OVersatileViewItem *item );
+ void doubleClicked( Opie::Ui::OVersatileViewItem *item );
+ void returnPressed( Opie::Ui::OVersatileViewItem *item );
- void onItem( OVersatileViewItem *item );
+ void onItem( Opie::Ui::OVersatileViewItem *item );
void onViewport();
- void expanded( OVersatileViewItem *item );
- void collapsed( OVersatileViewItem *item );
+ void expanded( Opie::Ui::OVersatileViewItem *item );
+ void collapsed( Opie::Ui::OVersatileViewItem *item );
void moved();
- void contextMenuRequested( OVersatileViewItem *item, const QPoint&, int col );
+ void contextMenuRequested( Opie::Ui::OVersatileViewItem *item, const QPoint&, int col );
private:
- OVersatileView* vv;
+ Opie::Ui::OVersatileView* vv;
};
#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,118 +1,118 @@
/*
* You may use, modify and distribute this example without any limitation
*/
#include "owidgetstack_example.h"
/* OPIE */
#include <opie2/oapplicationfactory.h>
#include <opie2/owidgetstack.h>
#include <qpe/resource.h>
/* QT */
#include <qaction.h>
#include <qtoolbar.h>
#include <qpopupmenu.h>
#include <qmenubar.h>
#include <qlayout.h>
#include <qlabel.h>
#include <qpushbutton.h>
#include <qsignalmapper.h>
-using namespace Opie;
+using namespace Opie::Ui;
OPIE_EXPORT_APP( OApplicationFactory<StackExample> )
StackExample::StackExample( QWidget* parent, const char* name, WFlags fl )
: QMainWindow( parent, name, fl )
{
m_stack = new OWidgetStack( this );
setCentralWidget( m_stack );
/* nice Signal Mapper ;) */
QSignalMapper *sm = new QSignalMapper(this);
connect(sm, SIGNAL(mapped(int) ), m_stack, SLOT(raiseWidget(int)) );
/* toolbar first but this should be known from the other examples */
setToolBarsMovable( false );
/* only a menubar here */
QToolBar* holder = new QToolBar( this );
holder->setHorizontalStretchable( true );
QMenuBar *bar = new QMenuBar( holder );
QPopupMenu *menu = new QPopupMenu( this );
QAction* a = new QAction( tr("Show MainWidget"), Resource::loadPixmap("zoom"),
QString::null, 0, this, 0 );
sm->setMapping(a, 1 );
connect(a, SIGNAL(activated() ),
sm, SLOT(map() ) );
a->addTo( menu );
a = new QAction( tr("Show Details Small"), Resource::loadPixmap("zoom"),
QString::null, 0, this, 0 );
sm->setMapping(a, 2 );
connect(a, SIGNAL(activated() ),
sm, SLOT(map() ) );
a->addTo( menu );
a = new QAction( tr("Show Details More"), Resource::loadPixmap("zoom"),
QString::null, 0, this, 0 );
sm->setMapping(a, 3 );
connect(a, SIGNAL(activated() ),
sm, SLOT(map() ) );
a->addTo( menu );
a = new QAction( tr("Show Details All"), Resource::loadPixmap("zoom"),
QString::null, 0, this, 0 );
sm->setMapping(a, 4 );
connect(a, SIGNAL(activated() ),
sm, SLOT(map() ) );
bar->insertItem( tr("Actions"), menu );
/* now the gui */
/* first widget, main widget */
QWidget * wid = new QWidget( m_stack );
QGridLayout *grid = new QGridLayout(wid, 2, 2 );
QPushButton *btn = new QPushButton( tr("Show Details Small"), wid, "details1" );
sm->setMapping(btn, 2 );
connect(btn, SIGNAL(clicked()), sm, SLOT(map() ) );
grid->addWidget( btn, 0, 0 );
btn = new QPushButton( tr("Show Details Medium"), wid, "details2");
sm->setMapping(btn, 3 );
connect(btn, SIGNAL(clicked()), sm, SLOT(map() ) );
grid->addWidget( btn, 0, 1 );
btn = new QPushButton( tr("Show Details All"), wid, "details3");
sm->setMapping(btn, 4 );
connect(btn, SIGNAL(clicked()), sm, SLOT(map() ) );
grid->addWidget( btn, 1, 1 );
m_stack->addWidget( wid, 1 );
m_main = wid;
QLabel *lbl = new QLabel(m_stack );
lbl->setText(tr("Only small Details are shown here. Määh") );
m_stack->addWidget( lbl, 2 );
lbl = new QLabel( m_stack );
lbl->setText( tr("Some more details....Wo ist das Schaf?") );
m_stack->addWidget( lbl, 3 );
lbl = new QLabel( m_stack );
lbl->setText( tr("<qt>Ne nicht in Bayerisch Gmain sondern in Berlin<br>Vermiss und meine Augen werden nicht eckig, da mein Bildschirm abgerundet ist<br>Es lebe Hamburg Süd,weiss du, verstehst du? ;)<br>Susi ist dOOf, es lebe die Ofenecke...", "hard to translate that") );
m_stack->addWidget( lbl, 4 );
/* THE signal mapper does all the magic */
m_stack->raiseWidget( m_main );
}
StackExample::~StackExample() {
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 @@
/*
* You may use, modify and distribute this example without any limitation
*/
#ifndef O_STACK_EXAMPLE_SIMPLE_H
#define O_STACK_EXAMPLE_SIMPLE_H
#include <qmainwindow.h>
#include <opie2/owidgetstack.h>
-using namespace Opie;
class StackExample : public QMainWindow {
Q_OBJECT
public:
StackExample( QWidget* paren, const char* name, WFlags fl );
~StackExample();
static QString appName() { return QString::fromLatin1("owidgetstack-example"); }
protected:
void closeEvent( QCloseEvent* e );
private:
- OWidgetStack* m_stack;
+ Opie::Ui::OWidgetStack* m_stack;
QWidget* m_main;
};
#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
@@ -1,286 +1,286 @@
/*
This file is part of the Opie Project
Copyright (C) The Opie Team <opie-devel@handhelds.org>
=.
.=l.
.>+-=
_;:, .> :=|. This program is free software; you can
.> <`_, > . <= redistribute it and/or modify it under
:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
.="- .-=="i, .._ License as published by the Free Software
- . .-<_> .<> Foundation; either version 2 of the License,
._= =} : or (at your option) any later version.
.%`+i> _;_.
.i_,=:_. -<s. This program is distributed in the hope that
+ . -:. = it will be useful, but WITHOUT ANY WARRANTY;
: .. .:, . . . without even the implied warranty of
=_ + =;=|` MERCHANTABILITY or FITNESS FOR A
_.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.= = ; Library General Public License for more
++= -. .` .: details.
: = ...= . :.=-
-. .:....=;==+<; You should have received a copy of the GNU
-_. . . )=. = Library General Public License along with
-- :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include "odevice_ipaq.h"
#include "odevice_jornada.h"
#include "odevice_ramses.h"
#include "odevice_simpad.h"
#include "odevice_yopy.h"
#include "odevice_zaurus.h"
/* QT */
#include <qapplication.h>
#include <qfile.h>
#include <qtextstream.h>
#include <qwindowsystem_qws.h>
/* OPIE */
#include <qpe/config.h>
#include <qpe/resource.h>
#include <qpe/sound.h>
#include <qpe/qcopenvelope_qws.h>
/* STD */
#include <fcntl.h>
#include <math.h>
#include <stdlib.h>
#include <signal.h>
#include <sys/ioctl.h>
#include <sys/time.h>
#include <unistd.h>
#ifndef QT_NO_SOUND
#include <linux/soundcard.h>
#endif
const char* PATH_PROC_CPUINFO = "/proc/cpuinfo";
-using namespace Opie;
+using namespace Opie::Core;
ODevice *ODevice::inst()
{
static ODevice *dev = 0;
// rewrite this to only use /proc/cpuinfo or so
if ( !dev )
{
QFile f( PATH_PROC_CPUINFO );
if ( f.open( IO_ReadOnly ) )
{
QTextStream s( &f );
while ( !s.atEnd() )
{
QString line;
line = s.readLine();
if ( line.startsWith( "Hardware" ) )
{
qDebug( "ODevice() - found '%s'", (const char*) line );
- if ( line.contains( "sharp", false ) ) dev = new Zaurus();
- else if ( line.contains( "ipaq", false ) ) dev = new iPAQ();
- else if ( line.contains( "simpad", false ) ) dev = new SIMpad();
- else if ( line.contains( "jornada", false ) ) dev = new Jornada();
- else if ( line.contains( "ramses", false ) ) dev = new Ramses();
+ if ( line.contains( "sharp", false ) ) dev = new Private::Zaurus();
+ else if ( line.contains( "ipaq", false ) ) dev = new Private::iPAQ();
+ else if ( line.contains( "simpad", false ) ) dev = new Private::SIMpad();
+ else if ( line.contains( "jornada", false ) ) dev = new Private::Jornada();
+ else if ( line.contains( "ramses", false ) ) dev = new Private::Ramses();
else qWarning( "ODevice() - unknown hardware - using default." );
break;
}
}
}
else
{
qWarning( "ODevice() - can't open '%s' - unknown hardware - using default." );
}
if ( !dev ) dev = new ODevice();
dev->init();
}
return dev;
}
ODevice::ODevice()
{
d = new ODeviceData;
d->m_modelstr = "Unknown";
d->m_model = Model_Unknown;
d->m_vendorstr = "Unknown";
d->m_vendor = Vendor_Unknown;
d->m_systemstr = "Unknown";
d->m_system = System_Unknown;
d->m_sysverstr = "0.0";
d->m_rotation = Rot0;
d->m_direction = CW;
d->m_holdtime = 1000; // 1000ms
d->m_buttons = 0;
d->m_cpu_frequencies = new QStrList;
}
void ODevice::systemMessage ( const QCString &msg, const QByteArray & )
{
if ( msg == "deviceButtonMappingChanged()" ) {
reloadButtonMapping();
}
}
void ODevice::init()
{
}
/**
* This method initialises the button mapping
*/
void ODevice::initButtons()
{
if ( d->m_buttons )
return;
qDebug ( "init Buttons" );
d->m_buttons = new QValueList <ODeviceButton>;
reloadButtonMapping();
QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&)));
}
ODevice::~ODevice()
{
// we leak m_devicebuttons and m_cpu_frequency
// but it's a singleton and it is not so importantant
// -zecke
delete d;
}
bool ODevice::setSoftSuspend ( bool /*soft*/ )
{
return false;
}
//#include <linux/apm_bios.h>
#define APM_IOC_SUSPEND OD_IO( 'A', 2 )
/**
* This method will try to suspend the device
* It only works if the user is the QWS Server and the apm application
* is installed.
* It tries to suspend and then waits some time cause some distributions
* do have asynchronus apm implementations.
* This method will either fail and return false or it'll suspend the
* device and return once the device got woken up
*
* @return if the device got suspended
*/
bool ODevice::suspend()
{
qDebug("ODevice::suspend");
if ( !isQWS( ) ) // only qwsserver is allowed to suspend
return false;
if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices
return false;
bool res = false;
ODevice::sendSuspendmsg();
-
+
struct timeval tvs, tvn;
::gettimeofday ( &tvs, 0 );
::sync(); // flush fs caches
res = ( ::system ( "apm --suspend" ) == 0 );
// This is needed because the iPAQ apm implementation is asynchronous and we
// can not be sure when exactly the device is really suspended
// This can be deleted as soon as a stable familiar with a synchronous apm implementation exists.
if ( res ) {
do { // wait at most 1.5 sec: either suspend didn't work or the device resumed
::usleep ( 200 * 1000 );
::gettimeofday ( &tvn, 0 );
} while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 );
}
return res;
}
//#include <linux/fb.h> better not rely on kernel headers in userspace ...
#define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611
/* VESA Blanking Levels */
#define VESA_NO_BLANKING 0
#define VESA_VSYNC_SUSPEND 1
#define VESA_HSYNC_SUSPEND 2
#define VESA_POWERDOWN 3
/**
* This sets the display on or off
*/
bool ODevice::setDisplayStatus ( bool on )
{
qDebug("ODevice::setDisplayStatus(%d)", on);
if ( d->m_model == Model_Unknown )
return false;
bool res = false;
int fd;
if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) {
res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 );
::close ( fd );
}
return res;
}
/**
* This sets the display brightness
*
* @param p The brightness to be set on a scale from 0 to 255
* @return success or failure
*/
bool ODevice::setDisplayBrightness ( int p)
{
Q_UNUSED( p )
return false;
}
/**
* @return returns the number of steppings on the brightness slider
* in the Light-'n-Power settings.
*/
int ODevice::displayBrightnessResolution() const
{
return 16;
}
/**
* This sets the display contrast
* @param p The contrast to be set on a scale from 0 to 255
* @return success or failure
*/
bool ODevice::setDisplayContrast ( int p)
{
Q_UNUSED( p )
return false;
}
/**
* @return return the max value for the brightness settings slider
* or 0 if the device doesn't support setting of a contrast
*/
int ODevice::displayContrastResolution() const
{
return 0;
}
/**
* This returns the vendor as string
* @return Vendor as QString
*/
QString ODevice::vendorString() const
@@ -531,98 +531,101 @@ uint ODevice::buttonHoldTime() const
* or 0 if no special hardware button is available for the device
*
* @return The devicebutton or 0l
* @see ODeviceButton
*/
const ODeviceButton *ODevice::buttonForKeycode ( ushort code )
{
initButtons();
for ( QValueListConstIterator<ODeviceButton> it = d->m_buttons->begin(); it != d->m_buttons->end(); ++it ) {
if ( (*it). keycode() == code )
return &(*it);
}
return 0;
}
void ODevice::reloadButtonMapping()
{
initButtons();
Config cfg ( "ButtonSettings" );
for ( uint i = 0; i < d->m_buttons->count(); i++ ) {
ODeviceButton &b = ( *d->m_buttons ) [i];
QString group = "Button" + QString::number ( i );
QCString pch, hch;
QCString pm, hm;
QByteArray pdata, hdata;
if ( cfg. hasGroup ( group )) {
cfg. setGroup ( group );
pch = cfg. readEntry ( "PressedActionChannel" ). latin1();
pm = cfg. readEntry ( "PressedActionMessage" ). latin1();
// pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" ));
hch = cfg. readEntry ( "HeldActionChannel" ). latin1();
hm = cfg. readEntry ( "HeldActionMessage" ). latin1();
// hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" ));
}
b. setPressedAction ( OQCopMessage ( pch, pm, pdata ));
b. setHeldAction ( OQCopMessage ( hch, hm, hdata ));
}
}
void ODevice::remapPressedAction ( int button, const OQCopMessage &action )
{
initButtons();
QString mb_chan;
if ( button >= (int) d->m_buttons->count())
return;
ODeviceButton &b = ( *d->m_buttons ) [button];
b. setPressedAction ( action );
mb_chan=b. pressedAction(). channel();
Config buttonFile ( "ButtonSettings" );
buttonFile. setGroup ( "Button" + QString::number ( button ));
buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan);
buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction(). message());
// buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction(). data()));
QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
}
void ODevice::remapHeldAction ( int button, const OQCopMessage &action )
{
initButtons();
if ( button >= (int) d->m_buttons->count())
return;
ODeviceButton &b = ( *d->m_buttons ) [button];
b. setHeldAction ( action );
Config buttonFile ( "ButtonSettings" );
buttonFile. setGroup ( "Button" + QString::number ( button ));
buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction(). channel());
buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction(). message());
// buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction(). data()));
QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
}
void ODevice::virtual_hook(int, void* ){
}
void ODevice::sendSuspendmsg()
{
+ if ( isQWS() )
+ return;
+
QCopEnvelope ( "QPE/System", "aboutToSuspend()" );
}
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,140 +1,141 @@
/*
This file is part of the Opie Project
Copyright (C) The Opie Team <opie-devel@handhelds.org>
=.
.=l.
.>+-=
_;:, .> :=|. This program is free software; you can
.> <`_, > . <= redistribute it and/or modify it under
:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
.="- .-=="i, .._ License as published by the Free Software
- . .-<_> .<> Foundation; either version 2 of the License,
._= =} : or (at your option) any later version.
.%`+i> _;_.
.i_,=:_. -<s. This program is distributed in the hope that
+ . -:. = it will be useful, but WITHOUT ANY WARRANTY;
: .. .:, . . . without even the implied warranty of
=_ + =;=|` MERCHANTABILITY or FITNESS FOR A
_.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.= = ; Library General Public License for more
++= -. .` .: details.
: = ...= . :.=-
-. .:....=;==+<; You should have received a copy of the GNU
-_. . . )=. = Library General Public License along with
-- :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef ODEVICE_H_
#define ODEVICE_H_
/* OPIE */
#include <opie2/odevicebutton.h>
#include <qpe/qpeapplication.h> /* for Transformation enum.. */
/* QT */
#include <qnamespace.h>
#include <qobject.h>
#include <qstring.h>
#include <qstrlist.h>
-namespace Opie
-{
+namespace Opie{
+namespace Core{
+
class ODeviceData;
/**
* The available devices
*/
enum OModel {
Model_Unknown, // = 0
Model_Series_Mask = 0xff000000,
Model_iPAQ = ( 1 << 24 ),
Model_iPAQ_All = ( Model_iPAQ | 0xffffff ),
Model_iPAQ_H31xx = ( Model_iPAQ | 0x000001 ),
Model_iPAQ_H36xx = ( Model_iPAQ | 0x000002 ),
Model_iPAQ_H37xx = ( Model_iPAQ | 0x000004 ),
Model_iPAQ_H38xx = ( Model_iPAQ | 0x000008 ),
Model_iPAQ_H39xx = ( Model_iPAQ | 0x000010 ),
Model_iPAQ_H5xxx = ( Model_iPAQ | 0x000011 ),
Model_Jornada = ( 6 << 24 ),
Model_Jornada_56x = ( Model_Jornada | 0x000001 ),
Model_Zaurus = ( 2 << 24 ),
Model_Zaurus_SL5000 = ( Model_Zaurus | 0x000001 ),
Model_Zaurus_SL5500 = ( Model_Zaurus | 0x000002 ),
Model_Zaurus_SLA300 = ( Model_Zaurus | 0x000003 ),
Model_Zaurus_SLB600 = ( Model_Zaurus | 0x000004 ),
Model_Zaurus_SLC7x0 = ( Model_Zaurus | 0x000005 ),
Model_SIMpad = ( 3 << 24 ),
Model_SIMpad_All = ( Model_SIMpad | 0xffffff ),
Model_SIMpad_CL4 = ( Model_SIMpad | 0x000001 ),
Model_SIMpad_SL4 = ( Model_SIMpad | 0x000002 ),
Model_SIMpad_SLC = ( Model_SIMpad | 0x000004 ),
Model_SIMpad_TSinus = ( Model_SIMpad | 0x000008 ),
Model_Ramses = ( 4 << 24 ),
Model_Ramses_All = ( Model_Ramses | 0xffffff ),
Model_Ramses_MNCI = ( Model_Ramses | 0x000001 ),
Model_Yopy = ( 5 << 24 ),
Model_Yopy_All = ( Model_Yopy | 0xffffff ),
Model_Yopy_3000 = ( Model_Yopy | 0x000001 ),
Model_Yopy_3500 = ( Model_Yopy | 0x000002 ),
Model_Yopy_3700 = ( Model_Yopy | 0x000003 ),
};
/**
* The vendor of the device
*/
enum OVendor {
Vendor_Unknown,
Vendor_HP,
Vendor_Sharp,
Vendor_SIEMENS,
Vendor_MundN,
Vendor_GMate,
};
/**
* The System used
*/
enum OSystem {
System_Unknown,
System_Familiar,
System_Zaurus,
System_OpenZaurus,
System_Linupy,
};
enum OLedState {
Led_Off,
Led_On,
Led_BlinkSlow,
Led_BlinkFast
};
enum OLed {
Led_Mail,
Led_Power,
Led_BlueTooth
};
enum OHardKey {
HardKey_Datebook = Qt::Key_F9,
HardKey_Contacts = Qt::Key_F10,
HardKey_Menu = Qt::Key_F11,
HardKey_Home = Qt::Key_F12,
HardKey_Mail = Qt::Key_F13,
@@ -157,176 +158,178 @@ enum OHingeStatus {
CASE_PORTRAIT = 2,
CASE_LANDSCAPE = 0,
CASE_UNKNOWN = 1,
};
/**
* A singleton which gives informations about device specefic option
* like the Hardware used, LEDs, the Base Distribution and
* hardware key mappings.
*
* @short A small class for device specefic options
* @see QObject
* @author Robert Griebl
* @version 1.0
*/
class ODevice : public QObject
{
Q_OBJECT
private:
/* disable copy */
ODevice ( const ODevice & );
protected:
ODevice();
virtual void init();
virtual void initButtons();
static void sendSuspendmsg();
ODeviceData *d;
public:
// sandman do we want to allow destructions? -zecke?
virtual ~ODevice();
static ODevice *inst();
// information
QString modelString() const;
OModel model() const;
inline OModel series() const { return (OModel) ( model() & Model_Series_Mask ); }
QString vendorString() const;
OVendor vendor() const;
QString systemString() const;
OSystem system() const;
QString systemVersionString() const;
virtual Transformation rotation() const;
virtual ODirection direction() const;
// system
virtual bool setSoftSuspend ( bool on );
virtual bool suspend();
virtual bool setDisplayStatus ( bool on );
virtual bool setDisplayBrightness ( int brightness );
virtual int displayBrightnessResolution() const;
virtual bool setDisplayContrast ( int contrast );
virtual int displayContrastResolution() const;
// don't add new virtual methods, use this:
// /*virtual */ void boo(int i ) { return virtual_hook(1,&i); };
// and in your subclass do do overwrite
// protected virtual int virtual_hook(int, void *)
// which is defined below
// input / output
virtual void playAlarmSound();
virtual void playKeySound();
virtual void playTouchSound();
virtual QValueList <OLed> ledList() const;
virtual QValueList <OLedState> ledStateList ( OLed led ) const;
virtual OLedState ledState ( OLed led ) const;
virtual bool setLedState ( OLed led, OLedState st );
virtual bool hasLightSensor() const;
virtual int readLightSensor();
virtual int lightSensorResolution() const;
virtual bool hasHingeSensor() const;
virtual OHingeStatus readHingeSensor();
const QStrList &allowedCpuFrequencies() const;
bool setCurrentCpuFrequency(uint index);
/**
* Returns the available buttons on this device. The number and location
* of buttons will vary depending on the device. Button numbers will be assigned
* by the device manufacturer and will be from most preferred button to least preffered
* button. Note that this list only contains "user mappable" buttons.
- *
+ *
* @todo Make method const and take care of calling initButtons or make that const too
*
*/
const QValueList<ODeviceButton> &buttons();
/**
* Returns the DeviceButton for the \a keyCode. If \a keyCode is not found, it
* returns 0L
*/
const ODeviceButton *buttonForKeycode ( ushort keyCode );
/**
* Reassigns the pressed action for \a button. To return to the factory
* default pass an empty string as \a qcopMessage.
*/
void remapPressedAction ( int button, const OQCopMessage &qcopMessage );
/**
* Reassigns the held action for \a button. To return to the factory
* default pass an empty string as \a qcopMessage.
*/
void remapHeldAction ( int button, const OQCopMessage &qcopMessage );
/**
* How long (in ms) you have to press a button for a "hold" action
*/
uint buttonHoldTime() const;
signals:
void buttonMappingChanged();
private slots:
void systemMessage ( const QCString &, const QByteArray & );
protected:
void reloadButtonMapping();
/* ugly virtual hook */
virtual void virtual_hook( int id, void* data );
};
class ODeviceData {
public:
QString m_vendorstr;
OVendor m_vendor;
QString m_modelstr;
OModel m_model;
QString m_systemstr;
OSystem m_system;
QString m_sysverstr;
Transformation m_rotation;
ODirection m_direction;
QValueList <ODeviceButton> *m_buttons;
uint m_holdtime;
QStrList *m_cpu_frequencies;
};
}
+}
static inline bool isQWS()
{
return qApp ? ( qApp->type() == QApplication::GuiServer ) : false;
}
static QCString makeChannel ( const char *str )
{
if ( str && !::strchr ( str, '/' ))
return QCString ( "QPE/Application/" ) + str;
else
return str;
}
+
#endif
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
@@ -1,151 +1,155 @@
/*
                This file is part of the Opie Project
              Copyright (C) The Opie Team <opie-devel@handhelds.org>
=.
.=l.
           .>+-=
 _;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include "odevice_ipaq.h"
/* QT */
#include <qapplication.h>
#include <qfile.h>
#include <qtextstream.h>
#include <qwindowsystem_qws.h>
/* OPIE */
#include <qpe/config.h>
#include <qpe/resource.h>
#include <qpe/sound.h>
#include <qpe/qcopenvelope_qws.h>
/* STD */
#include <fcntl.h>
#include <math.h>
#include <stdlib.h>
#include <signal.h>
#include <sys/ioctl.h>
#include <sys/time.h>
#include <unistd.h>
#ifndef QT_NO_SOUND
#include <linux/soundcard.h>
#endif
+
+using namespace Opie::Core;
+using namespace Opie::Core::Private;
+
/* KERNEL */
#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 ))
#define OD_IO(type,number) OD_IOC(0,type,number,0)
#define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size))
#define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size))
#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size))
typedef struct {
unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */
unsigned char TotalTime; /* Units of 5 seconds */
unsigned char OnTime; /* units of 100m/s */
unsigned char OffTime; /* units of 100m/s */
} LED_IN;
typedef struct {
unsigned char mode;
unsigned char pwr;
unsigned char brightness;
} FLITE_IN;
#define LED_ON OD_IOW( 'f', 5, LED_IN )
#define FLITE_ON OD_IOW( 'f', 7, FLITE_IN )
struct i_button ipaq_buttons [] = {
{ Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx,
Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
"devicebuttons/ipaq_calendar",
"datebook", "nextView()",
"today", "raise()" },
{ Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx,
Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
"devicebuttons/ipaq_contact",
"addressbook", "raise()",
"addressbook", "beamBusinessCard()" },
{ Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx,
Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
"devicebuttons/ipaq_menu",
"QPE/TaskBar", "toggleMenu()",
"QPE/TaskBar", "toggleStartMenu()" },
{ Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx,
Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
"devicebuttons/ipaq_mail",
"mail", "raise()",
"mail", "newMail()" },
{ Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx,
Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
"devicebuttons/ipaq_home",
"QPE/Launcher", "home()",
"buttonsettings", "raise()" },
{ Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx,
Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"),
"devicebuttons/ipaq_record",
"QPE/VMemo", "toggleRecord()",
"sound", "raise()" },
};
void iPAQ::init()
{
d->m_vendorstr = "HP";
d->m_vendor = Vendor_HP;
QFile f ( "/proc/hal/model" );
if ( f. open ( IO_ReadOnly )) {
QTextStream ts ( &f );
d->m_modelstr = "H" + ts. readLine();
if ( d->m_modelstr == "H3100" )
d->m_model = Model_iPAQ_H31xx;
else if ( d->m_modelstr == "H3600" )
d->m_model = Model_iPAQ_H36xx;
else if ( d->m_modelstr == "H3700" )
d->m_model = Model_iPAQ_H37xx;
else if ( d->m_modelstr == "H3800" )
d->m_model = Model_iPAQ_H38xx;
else if ( d->m_modelstr == "H3900" )
d->m_model = Model_iPAQ_H39xx;
else if ( d->m_modelstr == "H5400" )
d->m_model = Model_iPAQ_H5xxx;
else
d->m_model = Model_Unknown;
f. close();
}
switch ( d->m_model ) {
case Model_iPAQ_H31xx:
case Model_iPAQ_H38xx:
d->m_rotation = Rot90;
break;
case Model_iPAQ_H36xx:
case Model_iPAQ_H37xx:
case Model_iPAQ_H39xx:
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 @@
/*
                This file is part of the Opie Project
              Copyright (C) The Opie Team <opie-devel@handhelds.org>
=.
.=l.
           .>+-=
 _;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef ODEVICE_IPAQ
#define ODEVICE_IPAQ
#include "odevice.h"
/* QT */
#include <qwindowsystem_qws.h>
-using namespace Opie;
+namespace Opie {
+namespace Core {
+namespace Private {
class iPAQ : public ODevice, public QWSServer::KeyboardFilter
{
protected:
virtual void init();
virtual void initButtons();
public:
virtual bool setSoftSuspend( bool soft );
virtual bool setDisplayBrightness( int b );
virtual int displayBrightnessResolution() const;
virtual void playAlarmSound();
virtual QValueList <OLed> ledList() const;
virtual QValueList <OLedState> ledStateList( OLed led ) const;
virtual OLedState ledState( OLed led ) const;
virtual bool setLedState( OLed led, OLedState st );
virtual bool hasLightSensor() const;
virtual int readLightSensor();
virtual int lightSensorResolution() const;
protected:
virtual bool filter( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat );
virtual void timerEvent( QTimerEvent *te );
int m_power_timer;
OLedState m_leds [2];
};
struct i_button {
uint model;
Qt::Key code;
char *utext;
char *pix;
char *fpressedservice;
char *fpressedaction;
char *fheldservice;
char *fheldaction;
};
+}
+}
+}
+
#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
@@ -1,150 +1,150 @@
/*
                This file is part of the Opie Project
              Copyright (C) The Opie Team <opie-devel@handhelds.org>
=.
.=l.
           .>+-=
 _;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include "odevice_jornada.h"
/* QT */
#include <qapplication.h>
#include <qfile.h>
#include <qtextstream.h>
#include <qwindowsystem_qws.h>
/* OPIE */
#include <qpe/config.h>
#include <qpe/resource.h>
#include <qpe/sound.h>
#include <qpe/qcopenvelope_qws.h>
/* STD */
#include <fcntl.h>
#include <math.h>
#include <stdlib.h>
#include <signal.h>
#include <sys/ioctl.h>
#include <sys/time.h>
#include <unistd.h>
#ifndef QT_NO_SOUND
#include <linux/soundcard.h>
#endif
/* KERNEL */
#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 ))
#define OD_IO(type,number) OD_IOC(0,type,number,0)
#define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size))
#define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size))
#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size))
typedef struct {
unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */
unsigned char TotalTime; /* Units of 5 seconds */
unsigned char OnTime; /* units of 100m/s */
unsigned char OffTime; /* units of 100m/s */
} LED_IN;
typedef struct {
unsigned char mode;
unsigned char pwr;
unsigned char brightness;
} FLITE_IN;
#define LED_ON OD_IOW( 'f', 5, LED_IN )
#define FLITE_ON OD_IOW( 'f', 7, FLITE_IN )
-using namespace Opie;
+using namespace Opie::Core::Private;
void Jornada::init()
{
d->m_vendorstr = "HP";
d->m_vendor = Vendor_HP;
d->m_modelstr = "Jornada 56x";
d->m_model = Model_Jornada_56x;
d->m_systemstr = "Familiar";
d->m_system = System_Familiar;
d->m_rotation = Rot0;
QFile f ( "/etc/familiar-version" );
f.setName ( "/etc/familiar-version" );
if ( f.open ( IO_ReadOnly )) {
QTextStream ts ( &f );
d->m_sysverstr = ts.readLine().mid( 10 );
f. close();
}
}
int Jornada::displayBrightnessResolution() const
{
return 0;
}
bool Jornada::setDisplayBrightness( int bright )
{
bool res = false;
int fd;
if ( bright > 255 )
bright = 255;
if ( bright < 0 )
bright = 0;
if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) {
FLITE_IN bl;
bl. mode = 1;
bl. pwr = bright ? 1 : 0;
bl. brightness = ( bright * ( displayBrightnessResolution() - 1 ) + 127 ) / 255;
res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 );
::close ( fd );
}
return res;
}
bool Jornada::setSoftSuspend( bool soft )
{
bool res = false;
int fd;
if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) {
if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 )
res = true;
else
::perror ( "write to /proc/sys/ts/suspend_button_mode" );
::close ( fd );
}
else
::perror ( "/proc/sys/ts/suspend_button_mode" );
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 @@
/*
                This file is part of the Opie Project
              Copyright (C) The Opie Team <opie-devel@handhelds.org>
=.
.=l.
           .>+-=
 _;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef ODEVICE_JORNADA
#define ODEVICE_JORNADA
#include <opie2/odevice.h>
-using namespace Opie;
-
+namespace Opie {
+namespace Core {
+namespace Private {
class Jornada : public ODevice
{
protected:
virtual void init();
public:
virtual bool setSoftSuspend ( bool soft );
virtual bool setDisplayBrightness ( int b );
virtual int displayBrightnessResolution() const;
};
-
+}
+}
+}
#endif
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
@@ -1,151 +1,154 @@
/*
                This file is part of the Opie Project
              Copyright (C) The Opie Team <opie-devel@handhelds.org>
=.
.=l.
           .>+-=
 _;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include "odevice_ramses.h"
/* QT */
#include <qapplication.h>
#include <qfile.h>
#include <qtextstream.h>
#include <qwindowsystem_qws.h>
/* OPIE */
#include <qpe/config.h>
#include <qpe/resource.h>
#include <qpe/sound.h>
#include <qpe/qcopenvelope_qws.h>
/* STD */
#include <fcntl.h>
#include <math.h>
#include <stdlib.h>
#include <signal.h>
#include <sys/ioctl.h>
#include <sys/time.h>
#include <unistd.h>
#ifndef QT_NO_SOUND
#include <linux/soundcard.h>
#endif
+using namespace Opie::Core;
+using namespace Opie::Core::Private;
+
struct r_button ramses_buttons [] = {
{ Model_Ramses_MNCI,
Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
"devicebuttons/z_menu",
"QPE/TaskBar", "toggleMenu()",
"QPE/TaskBar", "toggleStartMenu()" },
{ Model_Ramses_MNCI,
Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
"devicebuttons/ipaq_home",
"QPE/Launcher", "home()",
"buttonsettings", "raise()" },
};
void Ramses::init()
{
d->m_vendorstr = "M und N";
d->m_vendor = Vendor_MundN;
QFile f("/proc/sys/board/ramses");
d->m_modelstr = "Ramses";
d->m_model = Model_Ramses_MNCI;
d->m_rotation = Rot0;
d->m_holdtime = 1000;
f.setName("/etc/oz_version");
if (f.open(IO_ReadOnly)) {
d->m_systemstr = "OpenEmbedded/Ramses";
d->m_system = System_OpenZaurus;
QTextStream ts(&f);
ts.setDevice(&f);
d->m_sysverstr = ts.readLine();
f.close();
}
m_power_timer = 0;
#ifdef QT_QWS_ALLOW_OVERCLOCK
#warning *** Overclocking enabled - this may fry your hardware - you have been warned ***
#define OC(x...) x
#else
#define OC(x...)
#endif
// This table is true for a Intel XScale PXA 255
d->m_cpu_frequencies->append("99000"); // mem= 99, run= 99, turbo= 99, PXbus= 50
OC(d->m_cpu_frequencies->append("118000"); ) // mem=118, run=118, turbo=118, PXbus= 59 OC'd mem
d->m_cpu_frequencies->append("199100"); // mem= 99, run=199, turbo=199, PXbus= 99
OC(d->m_cpu_frequencies->append("236000"); ) // mem=118, run=236, turbo=236, PXbus=118 OC'd mem
d->m_cpu_frequencies->append("298600"); // mem= 99, run=199, turbo=298, PXbus= 99
OC(d->m_cpu_frequencies->append("354000"); ) // mem=118, run=236, turbo=354, PXbus=118 OC'd mem
d->m_cpu_frequencies->append("398099"); // mem= 99, run=199, turbo=398, PXbus= 99
d->m_cpu_frequencies->append("398100"); // mem= 99, run=398, turbo=398, PXbus=196
OC(d->m_cpu_frequencies->append("471000"); ) // mem=118, run=471, turbo=471, PXbus=236 OC'd mem/core/bus
}
bool Ramses::filter(int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat)
{
Q_UNUSED( keycode );
Q_UNUSED( modifiers );
Q_UNUSED( isPress );
Q_UNUSED( autoRepeat );
return false;
}
void Ramses::timerEvent(QTimerEvent *)
{
killTimer(m_power_timer);
m_power_timer = 0;
QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, true, false);
QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, false, false);
}
bool Ramses::setSoftSuspend(bool soft)
{
qDebug("Ramses::setSoftSuspend(%d)", soft);
#if 0
bool res = false;
int fd;
if (((fd = ::open("/dev/apm_bios", O_RDWR)) >= 0) ||
((fd = ::open("/dev/misc/apm_bios",O_RDWR)) >= 0)) {
int sources = ::ioctl(fd, APM_IOCGEVTSRC, 0); // get current event sources
if (sources >= 0) {
if (soft)
sources &= ~APM_EVT_POWER_BUTTON;
else
sources |= APM_EVT_POWER_BUTTON;
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 @@
/*
                This file is part of the Opie Project
              Copyright (C) The Opie Team <opie-devel@handhelds.org>
=.
.=l.
           .>+-=
 _;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef ODEVICE_RAMSES
#define ODEVICE_RAMSES
#include <opie2/odevice.h>
/* QT */
#include <qwindowsystem_qws.h>
-using namespace Opie;
+namespace Opie {
+namespace Core {
+namespace Private {
class Ramses : public ODevice, public QWSServer::KeyboardFilter
{
protected:
virtual void init();
public:
virtual bool setSoftSuspend( bool soft );
virtual bool suspend();
virtual bool setDisplayStatus( bool on );
virtual bool setDisplayBrightness( int b );
virtual int displayBrightnessResolution() const;
virtual bool setDisplayContrast( int b );
virtual int displayContrastResolution() const;
protected:
virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat );
virtual void timerEvent ( QTimerEvent *te );
int m_power_timer;
};
struct r_button {
uint model;
Qt::Key code;
char *utext;
char *pix;
char *fpressedservice;
char *fpressedaction;
char *fheldservice;
char *fheldaction;
};
+}
+}
+}
#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
@@ -1,152 +1,153 @@
/*
This file is part of the Opie Project
Copyright (C) The Opie Team <opie-devel@handhelds.org>
=.
.=l.
.>+-=
_;:, .> :=|. This program is free software; you can
.> <`_, > . <= redistribute it and/or modify it under
:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
.="- .-=="i, .._ License as published by the Free Software
- . .-<_> .<> Foundation; either version 2 of the License,
._= =} : or (at your option) any later version.
.%`+i> _;_.
.i_,=:_. -<s. This program is distributed in the hope that
+ . -:. = it will be useful, but WITHOUT ANY WARRANTY;
: .. .:, . . . without even the implied warranty of
=_ + =;=|` MERCHANTABILITY or FITNESS FOR A
_.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.= = ; Library General Public License for more
++= -. .` .: details.
: = ...= . :.=-
-. .:....=;==+<; You should have received a copy of the GNU
-_. . . )=. = Library General Public License along with
-- :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include "odevice_simpad.h"
/* QT */
#include <qapplication.h>
#include <qfile.h>
#include <qtextstream.h>
#include <qwindowsystem_qws.h>
/* OPIE */
#include <qpe/config.h>
#include <qpe/resource.h>
#include <qpe/sound.h>
#include <qpe/qcopenvelope_qws.h>
/* STD */
#include <fcntl.h>
#include <math.h>
#include <stdlib.h>
#include <signal.h>
#include <sys/ioctl.h>
#include <sys/time.h>
#include <unistd.h>
#ifndef QT_NO_SOUND
#include <linux/soundcard.h>
#endif
-using namespace Opie;
+using namespace Opie::Core;
+using namespace Opie::Core::Private;
struct s_button simpad_buttons [] = {
{ Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Lower+Up"),
"devicebuttons/simpad_lower_up",
"datebook", "nextView()",
"today", "raise()" },
{ Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Lower+Down"),
"devicebuttons/simpad_lower_down",
"addressbook", "raise()",
"addressbook", "beamBusinessCard()" },
{ Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Lower+Right"),
"devicebuttons/simpad_lower_right",
"QPE/TaskBar", "toggleMenu()",
"QPE/TaskBar", "toggleStartMenu()" },
{ Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Lower+Left"),
"devicebuttons/simpad_lower_left",
"mail", "raise()",
"mail", "newMail()" },
{ Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
Qt::Key_F5, QT_TRANSLATE_NOOP("Button", "Upper+Up"),
"devicebuttons/simpad_upper_up",
"QPE/Launcher", "home()",
"buttonsettings", "raise()" },
{ Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
Qt::Key_F6, QT_TRANSLATE_NOOP("Button", "Upper+Down"),
"devicebuttons/simpad_upper_down",
"addressbook", "raise()",
"addressbook", "beamBusinessCard()" },
{ Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
Qt::Key_F7, QT_TRANSLATE_NOOP("Button", "Upper+Right"),
"devicebuttons/simpad_upper_right",
"QPE/TaskBar", "toggleMenu()",
"QPE/TaskBar", "toggleStartMenu()" },
{ Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Upper+Left"),
"devicebuttons/simpad_upper_left",
"QPE/Rotation", "flip()",
"QPE/Rotation", "flip()" },
/*
{ Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"),
"devicebuttons/simpad_lower_upper",
"QPE/Launcher", "home()",
"buttonsettings", "raise()" },
{ Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"),
"devicebuttons/simpad_upper_lower",
"QPE/Launcher", "home()",
"buttonsettings", "raise()" },
*/
};
void SIMpad::init()
{
d->m_vendorstr = "SIEMENS";
d->m_vendor = Vendor_SIEMENS;
QFile f ( "/proc/hal/model" );
//TODO Implement model checking
//FIXME For now we assume an SL4
d->m_modelstr = "SL4";
d->m_model = Model_SIMpad_SL4;
switch ( d->m_model ) {
default:
d->m_rotation = Rot0;
d->m_direction = CCW;
d->m_holdtime = 1000; // 1000ms
break;
}
f. setName ( "/etc/familiar-version" );
if ( f. open ( IO_ReadOnly )) {
d->m_systemstr = "Familiar";
d->m_system = System_Familiar;
QTextStream ts ( &f );
d->m_sysverstr = ts. readLine(). mid ( 10 );
f. close();
} else {
f. setName ( "/etc/oz_version" );
if ( f. open ( IO_ReadOnly )) {
d->m_systemstr = "OpenEmbedded/SIMpad";
d->m_system = System_OpenZaurus;
QTextStream ts ( &f );
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 @@
/*
                This file is part of the Opie Project
              Copyright (C) The Opie Team <opie-devel@handhelds.org>
=.
.=l.
           .>+-=
 _;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef ODEVICE_SIMPAD
#define ODEVICE_SIMPAD
#include <opie2/odevice.h>
/* QT */
#include <qwindowsystem_qws.h>
-using namespace Opie;
+namespace Opie {
+namespace Core {
+namespace Private {
class SIMpad : public ODevice, public QWSServer::KeyboardFilter
{
protected:
virtual void init();
virtual void initButtons();
public:
virtual bool setSoftSuspend( bool soft );
virtual bool suspend();
virtual bool setDisplayStatus( bool on );
virtual bool setDisplayBrightness( int b );
virtual int displayBrightnessResolution() const;
virtual void playAlarmSound();
virtual QValueList <OLed> ledList() const;
virtual QValueList <OLedState> ledStateList( OLed led ) const;
virtual OLedState ledState( OLed led ) const;
virtual bool setLedState( OLed led, OLedState st );
protected:
virtual bool filter( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat );
virtual void timerEvent( QTimerEvent *te );
int m_power_timer;
OLedState m_leds [1];
};
struct s_button {
uint model;
Qt::Key code;
char *utext;
char *pix;
char *fpressedservice;
char *fpressedaction;
char *fheldservice;
char *fheldaction;
};
+}
+}
+}
+
#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
@@ -1,152 +1,153 @@
/*
                This file is part of the Opie Project
            Copyright (C) The Opie Team <opie-devel@handhelds.org>
=.
.=l.
         .>+-=
_;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
- .   .-<_>     .<> Foundation; either version 2 of the License,
   ._= =}       : or (at your option) any later version.
  .%`+i>       _;_.
  .i_,=:_.      -<s. This program is distributed in the hope that
   +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
  : ..    .:,     . . . without even the implied warranty of
  =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
_.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
:     =  ...= . :.=-
-.   .:....=;==+<; You should have received a copy of the GNU
-_. . .   )=.  = Library General Public License along with
  --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include "odevice_yopy.h"
/* QT */
#include <qapplication.h>
#include <qfile.h>
#include <qtextstream.h>
#include <qwindowsystem_qws.h>
/* OPIE */
#include <qpe/config.h>
#include <qpe/resource.h>
#include <qpe/sound.h>
#include <qpe/qcopenvelope_qws.h>
/* STD */
#include <fcntl.h>
#include <math.h>
#include <stdlib.h>
#include <signal.h>
#include <sys/ioctl.h>
#include <sys/time.h>
#include <unistd.h>
#ifndef QT_NO_SOUND
#include <linux/soundcard.h>
#endif
-using namespace Opie;
+using namespace Opie::Core;
+using namespace Opie::Core::Private;
struct yopy_button yopy_buttons [] = {
{ Qt::Key_F10, QT_TRANSLATE_NOOP( "Button", "Action Button" ),
"devicebuttons/yopy_action",
"datebook", "nextView()",
"today", "raise()" },
{ Qt::Key_F11, QT_TRANSLATE_NOOP( "Button", "OK Button" ),
"devicebuttons/yopy_ok",
"addressbook", "raise()",
"addressbook", "beamBusinessCard()" },
{ Qt::Key_F12, QT_TRANSLATE_NOOP( "Button", "End Button" ),
"devicebuttons/yopy_end",
"QPE/Launcher", "home()",
"buttonsettings", "raise()" },
};
void Yopy::init()
{
d->m_vendorstr = "G.Mate";
d->m_vendor = Vendor_GMate;
d->m_modelstr = "Yopy3700";
d->m_model = Model_Yopy_3700;
d->m_rotation = Rot0;
d->m_systemstr = "Linupy";
d->m_system = System_Linupy;
QFile f ( "/etc/issue" );
if ( f. open ( IO_ReadOnly ) )
{
QTextStream ts ( &f );
ts.readLine();
d->m_sysverstr = ts. readLine();
f. close();
}
}
void Yopy::initButtons()
{
if ( d->m_buttons )
return ;
d->m_buttons = new QValueList <ODeviceButton>;
for ( uint i = 0; i < ( sizeof( yopy_buttons ) / sizeof( yopy_button ) ); i++ )
{
yopy_button *ib = yopy_buttons + i;
ODeviceButton b;
b. setKeycode ( ib->code );
b. setUserText ( QObject::tr ( "Button", ib->utext ) );
b. setPixmap ( Resource::loadPixmap ( ib->pix ) );
b. setFactoryPresetPressedAction
( OQCopMessage( makeChannel( ib->fpressedservice ), ib->fpressedaction ) );
b. setFactoryPresetHeldAction
( OQCopMessage( makeChannel( ib->fheldservice ), ib->fheldaction ) );
d->m_buttons->append ( b );
}
reloadButtonMapping();
QCopChannel *sysch = new QCopChannel( "QPE/System", this );
connect( sysch, SIGNAL( received(const QCString&,const QByteArray&) ),
this, SLOT( systemMessage(const QCString&,const QByteArray&) ) );
}
bool Yopy::suspend()
{
/* Opie for Yopy does not implement its own power management at the
moment. The public version runs parallel to X, and relies on the
existing power management features. */
return false;
}
bool Yopy::setDisplayBrightness( int bright )
{
/* The code here works, but is disabled as the current version runs
parallel to X, and relies on the existing backlight demon. */
#if 0
if ( QFile::exists( "/proc/sys/pm/light" ) )
{
int fd = ::open( "/proc/sys/pm/light", O_WRONLY );
if ( fd >= 0 )
{
if ( bright )
::write( fd, "1\n", 2 );
else
::write( fd, "0\n", 2 );
::close( fd );
return true;
}
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 @@
/*
                This file is part of the Opie Project
            Copyright (C) The Opie Team <opie-devel@handhelds.org>
=.
.=l.
         .>+-=
_;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
- .   .-<_>     .<> Foundation; either version 2 of the License,
   ._= =}       : or (at your option) any later version.
  .%`+i>       _;_.
  .i_,=:_.      -<s. This program is distributed in the hope that
   +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
  : ..    .:,     . . . without even the implied warranty of
  =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
_.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
:     =  ...= . :.=-
-.   .:....=;==+<; You should have received a copy of the GNU
-_. . .   )=.  = Library General Public License along with
  --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef ODEVICE_YOPY
#define ODEVICE_YOPY
#include <opie2/odevice.h>
-using namespace Opie;
-
+namespace Opie {
+namespace Core {
+namespace Private {
class Yopy : public ODevice
{
protected:
virtual void init();
virtual void initButtons();
public:
virtual bool suspend();
virtual bool setDisplayBrightness ( int b );
virtual int displayBrightnessResolution() const;
};
struct yopy_button
{
Qt::Key code;
char *utext;
char *pix;
char *fpressedservice;
char *fpressedaction;
char *fheldservice;
char *fheldaction;
};
+}
+}
+}
+
#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
@@ -1,152 +1,153 @@
/*
This file is part of the Opie Project
Copyright (C) The Opie Team <opie-devel@handhelds.org>
=.
.=l.
.>+-=
_;:, .> :=|. This program is free software; you can
.> <`_, > . <= redistribute it and/or modify it under
:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
.="- .-=="i, .._ License as published by the Free Software
- . .-<_> .<> Foundation; either version 2 of the License,
._= =} : or (at your option) any later version.
.%`+i> _;_.
.i_,=:_. -<s. This program is distributed in the hope that
+ . -:. = it will be useful, but WITHOUT ANY WARRANTY;
: .. .:, . . . without even the implied warranty of
=_ + =;=|` MERCHANTABILITY or FITNESS FOR A
_.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.= = ; Library General Public License for more
++= -. .` .: details.
: = ...= . :.=-
-. .:....=;==+<; You should have received a copy of the GNU
-_. . . )=. = Library General Public License along with
-- :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include "odevice_zaurus.h"
/* QT */
#include <qapplication.h>
#include <qfile.h>
#include <qtextstream.h>
#include <qwindowsystem_qws.h>
/* OPIE */
#include <qpe/config.h>
#include <qpe/resource.h>
#include <qpe/sound.h>
#include <qpe/qcopenvelope_qws.h>
/* STD */
#include <fcntl.h>
#include <math.h>
#include <stdlib.h>
#include <signal.h>
#include <sys/ioctl.h>
#include <sys/time.h>
#include <unistd.h>
#ifndef QT_NO_SOUND
#include <linux/soundcard.h>
#endif
-using namespace Opie;
+using namespace Opie::Core;
+using namespace Opie::Core::Private;
struct z_button z_buttons [] = {
{ Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
"devicebuttons/z_calendar",
"datebook", "nextView()",
"today", "raise()" },
{ Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
"devicebuttons/z_contact",
"addressbook", "raise()",
"addressbook", "beamBusinessCard()" },
{ Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
"devicebuttons/z_home",
"QPE/Launcher", "home()",
"buttonsettings", "raise()" },
{ Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
"devicebuttons/z_menu",
"QPE/TaskBar", "toggleMenu()",
"QPE/TaskBar", "toggleStartMenu()" },
{ Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
"devicebuttons/z_mail",
"mail", "raise()",
"mail", "newMail()" },
};
struct z_button z_buttons_c700 [] = {
{ Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
"devicebuttons/z_calendar",
"datebook", "nextView()",
"today", "raise()" },
{ Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
"devicebuttons/z_contact",
"addressbook", "raise()",
"addressbook", "beamBusinessCard()" },
{ Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
"devicebuttons/z_home",
"QPE/Launcher", "home()",
"buttonsettings", "raise()" },
{ Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
"devicebuttons/z_menu",
"QPE/TaskBar", "toggleMenu()",
"QPE/TaskBar", "toggleStartMenu()" },
{ Qt::Key_F14, QT_TRANSLATE_NOOP("Button", "Display Rotate"),
"devicebuttons/z_hinge",
"QPE/Rotation", "rotateDefault()",
"QPE/Dummy", "doNothing()" },
};
// FIXME This gets unnecessary complicated. We should think about splitting the Zaurus
// class up into individual classes. We need three classes
//
// Zaurus-Collie (SA-model w/ 320x240 lcd, for SL5500 and SL5000)
// Zaurus-Poodle (PXA-model w/ 320x240 lcd, for SL5600)
// Zaurus-Corgi (PXA-model w/ 640x480 lcd, for C700, C750, C760, and C860)
//
// Only question right now is: Do we really need to do it? Because as soon
// as the OpenZaurus kernel is ready, there will be a unified interface for all
// Zaurus models (concerning apm, backlight, buttons, etc.)
//
// Comments? - mickeyl.
void Zaurus::init()
{
d->m_vendorstr = "Sharp";
d->m_vendor = Vendor_Sharp;
m_embedix = true; // Not openzaurus means: It has an embedix kernel !
// QFile f ( "/proc/filesystems" );
QString model;
// It isn't a good idea to check the system configuration to
// detect the distribution !
// Otherwise it may happen that any other distribution is detected as openzaurus, just
// because it uses a jffs2 filesystem..
// (eilers)
// if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read(). find ( "\tjffs2\n" ) >= 0 )) {
QFile f ("/etc/oz_version");
if ( f.exists() ){
d->m_vendorstr = "OpenZaurus Team";
d->m_systemstr = "OpenZaurus";
d->m_system = System_OpenZaurus;
if ( f. open ( IO_ReadOnly )) {
QTextStream ts ( &f );
d->m_sysverstr = ts. readLine();//. mid ( 10 );
f. close();
}
// Openzaurus sometimes uses the embedix kernel!
// => Check whether this is an embedix kernel
FILE *uname = popen("uname -r", "r");
QString line;
if ( f.open(IO_ReadOnly, uname) ) {
QTextStream ts ( &f );
line = ts. readLine();
int loc = line. find ( "embedix" );
if ( loc != -1 )
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 @@
/*
                This file is part of the Opie Project
              Copyright (C) The Opie Team <opie-devel@handhelds.org>
=.
.=l.
           .>+-=
 _;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef ODEVICE_ZAURUS
#define ODEVICE_ZAURUS
#include <opie2/odevice.h>
#ifndef ARRAY_SIZE
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
#endif
// _IO and friends are only defined in kernel headers ...
#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 ))
#define OD_IO(type,number) OD_IOC(0,type,number,0)
#define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size))
#define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size))
#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size))
-using namespace Opie;
+namespace Opie {
+namespace Core {
+namespace Private {
class Zaurus : public ODevice
{
protected:
virtual void init();
virtual void initButtons();
public:
virtual bool setSoftSuspend ( bool soft );
virtual bool setDisplayBrightness ( int b );
virtual int displayBrightnessResolution() const;
virtual void playAlarmSound();
virtual void playKeySound();
virtual void playTouchSound();
virtual QValueList <OLed> ledList() const;
virtual QValueList <OLedState> ledStateList ( OLed led ) const;
virtual OLedState ledState( OLed led ) const;
virtual bool setLedState( OLed led, OLedState st );
virtual bool hasHingeSensor() const;
virtual OHingeStatus readHingeSensor();
virtual bool suspend();
virtual Transformation rotation() const;
virtual ODirection direction() const;
protected:
virtual void buzzer ( int snd );
OLedState m_leds [1];
bool m_embedix;
};
struct z_button {
Qt::Key code;
char *utext;
char *pix;
char *fpressedservice;
char *fpressedaction;
char *fheldservice;
char *fheldaction;
};
-
+}
+}
+}
#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,246 +1,255 @@
/*
                This file is part of the Opie Project
              Copyright (C) The Opie Team <opie-devel@handhelds.org>
=.
.=l.
           .>+-=
 _;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include <qpixmap.h>
#include <qstring.h>
#include <qpe/qcopenvelope_qws.h>
#include <opie2/odevicebutton.h>
-using namespace Opie;
+
+namespace Opie {
+namespace Core {
+namespace Private {
class OQCopMessageData
{
public:
QCString m_channel;
QCString m_message;
QByteArray m_data;
};
+}
+using namespace Opie::Core;
+using namespace Opie::Core::Private;
OQCopMessage::OQCopMessage()
: d ( 0 )
{
init ( QCString(), QCString(), QByteArray());
}
OQCopMessage::OQCopMessage ( const OQCopMessage &copy )
: d ( 0 )
{
init ( copy. channel(), copy. message(), copy. data());
}
OQCopMessage &OQCopMessage::operator = ( const OQCopMessage &assign )
{
init ( assign. channel(), assign. message(), assign. data());
return *this;
}
OQCopMessage::OQCopMessage ( const QCString &ch, const QCString &m, const QByteArray &arg )
: d ( 0 )
{
init ( ch, m, arg );
}
void OQCopMessage::init ( const QCString &ch, const QCString &m, const QByteArray &arg )
{
if ( !d )
d = new OQCopMessageData();
d->m_channel = ch;
d->m_message = m;
d->m_data = arg;
}
bool OQCopMessage::send()
{
if ( d->m_channel. isEmpty() || d->m_message. isEmpty() )
return false;
QCopEnvelope e ( d->m_channel, d->m_message );
if ( d->m_data. size())
e. writeRawBytes ( d->m_data. data(), d->m_data. size());
return true;
}
QCString OQCopMessage::channel() const
{
return d->m_channel;
}
QCString OQCopMessage::message() const
{
return d->m_message;
}
QByteArray OQCopMessage::data() const
{
return d->m_data;
}
bool OQCopMessage::isNull() const
{
return d->m_message.isNull() || d->m_channel.isNull();
}
void OQCopMessage::setChannel ( const QCString &ch )
{
d->m_channel = ch;
}
void OQCopMessage::setMessage ( const QCString &m )
{
d->m_message = m;
}
void OQCopMessage::setData ( const QByteArray &data )
{
d->m_data = data;
}
-/*! \class Opie::ODeviceButton
- \brief The Opie::ODeviceButton class represents a physical user mappable button on a Qtopia device.
+/*! \class Opie::Core::ODeviceButton
+ \brief The Opie::Core::ODeviceButton class represents a physical user mappable button on a Qtopia device.
This class represents a physical button on a Qtopia device. A
device may have "user programmable" buttons.
The location and number of buttons will vary from device to
device. userText() and pixmap() may be used to describe this button
to the user in help documentation.
\ingroup qtopiaemb
\internal
*/
ODeviceButton::ODeviceButton()
{}
ODeviceButton::~ODeviceButton()
{}
/*!
Returns the button's keycode.
*/
ushort ODeviceButton::keycode() const
{
return m_Keycode;
}
/*!
This function returns a human readable, translated description of the button.
*/
QString ODeviceButton::userText() const
{
return m_UserText;
}
/*!
This function returns the pixmap for this button. If there isn't one
it will return an empty (null) pixmap.
*/
QPixmap ODeviceButton::pixmap() const
{
return m_Pixmap;
}
/*!
This function returns the factory preset (default) action for when this button
is pressed. The return value is a legal QCop message.
*/
OQCopMessage ODeviceButton::factoryPresetPressedAction() const
{
return m_FactoryPresetPressedAction;
}
/*!
This function returns the user assigned action for when this button is pressed.
If no action is assigned, factoryPresetAction() is returned.
*/
OQCopMessage ODeviceButton::pressedAction() const
{
if (m_PressedAction.channel().isEmpty())
return factoryPresetPressedAction();
return m_PressedAction;
}
/*!
This function returns the factory preset (default) action for when this button
is pressed and held. The return value is a legal QCop message.
*/
OQCopMessage ODeviceButton::factoryPresetHeldAction() const
{
return m_FactoryPresetHeldAction;
}
/*!
This function returns the user assigned action for when this button is pressed
and held. If no action is assigned, factoryPresetAction() is returned.
*/
OQCopMessage ODeviceButton::heldAction() const
{
if (m_HeldAction.channel().isEmpty())
return factoryPresetHeldAction();
return m_HeldAction;
}
void ODeviceButton::setKeycode(ushort keycode)
{
m_Keycode = keycode;
}
void ODeviceButton::setUserText(const QString& text)
{
m_UserText = text;
}
void ODeviceButton::setPixmap(const QPixmap& picture)
{
m_Pixmap = picture;
}
void ODeviceButton::setFactoryPresetPressedAction(const OQCopMessage& action)
{
m_FactoryPresetPressedAction = action;
}
void ODeviceButton::setPressedAction(const OQCopMessage& action)
{
m_PressedAction = action;
}
void ODeviceButton::setFactoryPresetHeldAction(const OQCopMessage& action)
{
m_FactoryPresetHeldAction = action;
}
void ODeviceButton::setHeldAction(const OQCopMessage& action)
{
m_HeldAction = action;
}
+
+}
+}
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 @@
/**********************************************************************
** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
**
** This file is part of the Qtopia Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#ifndef DEVICE_BUTTON_H
#define DEVICE_BUTTON_H
#include <qpixmap.h>
#include <qstring.h>
-class OQCopMessageData;
-namespace Opie
-{
+namespace Opie{
+namespace Core{
+namespace Private {
+class OQCopMessageData;
+}
class OQCopMessage
{
public:
OQCopMessage ( );
OQCopMessage ( const OQCopMessage &copy );
OQCopMessage ( const QCString &m_channel, const QCString &message, const QByteArray &args = QByteArray ( ));
OQCopMessage &operator = ( const OQCopMessage &assign );
void setChannel ( const QCString &channel );
void setMessage ( const QCString &message );
void setData ( const QByteArray &ba );
QCString channel ( ) const;
QCString message ( ) const;
QByteArray data ( ) const;
bool isNull()const;
bool send ( );
private:
void init ( const QCString &m_channel, const QCString &message, const QByteArray &args );
- OQCopMessageData *d;
+ Private::OQCopMessageData *d;
class Private;
Private* m_data;
};
/**
* This class represents a physical button on a Qtopia device. A device may
* have n "user programmable" buttons, which are number 1..n. The location
* and number of buttons will vary from device to device. userText() and pixmap()
* may be used to describe this button to the user in help documentation.
*
* @version 1.0
* @author Trolltech
* @short A representation of buttons
*/
class ODeviceButton
{
public:
ODeviceButton();
virtual ~ODeviceButton();
ushort keycode ( ) const;
QString userText ( ) const;
QPixmap pixmap ( ) const;
OQCopMessage factoryPresetPressedAction ( ) const;
OQCopMessage pressedAction ( ) const;
OQCopMessage factoryPresetHeldAction ( ) const;
OQCopMessage heldAction ( ) const;
void setKeycode ( ushort keycode );
void setUserText ( const QString& text );
void setPixmap ( const QPixmap& picture );
void setFactoryPresetPressedAction ( const OQCopMessage& qcopMessage );
void setPressedAction ( const OQCopMessage& qcopMessage );
void setFactoryPresetHeldAction ( const OQCopMessage& qcopMessage );
void setHeldAction ( const OQCopMessage& qcopMessage );
private:
ushort m_Keycode;
QString m_UserText;
QPixmap m_Pixmap;
OQCopMessage m_FactoryPresetPressedAction;
OQCopMessage m_PressedAction;
OQCopMessage m_FactoryPresetHeldAction;
OQCopMessage m_HeldAction;
class Private;
Private *d;
};
}
+}
#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 @@
/*
                This file is part of the Opie Project
              Copyright (C) 2003 Michael 'Mickey' Lauer <mickey@Vanille.de>
=.
.=l.
           .>+-=
 _;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include <opie2/oapplication.h>
#include <opie2/oconfig.h>
#include <opie2/odebug.h>
#include <signal.h>
#include <stdio.h>
+using namespace Opie::Core;
+
+
OApplication* OApplication::_instance = 0;
/**************************************************************************************************
* OApplicationPrivate
**************************************************************************************************/
+namespace Opie {
+namespace Core {
+namespace Private {
class OApplicationPrivate
{
public:
OApplicationPrivate() {};
~OApplicationPrivate() {};
};
+}
/**************************************************************************************************
* OApplication
**************************************************************************************************/
OApplication::OApplication( int& argc, char** argv, const QCString& rAppName )
:QPEApplication( argc, argv ),
_appname( rAppName ),
_config( 0 )
{
init();
}
OApplication::~OApplication()
{
delete d;
if ( _config )
delete _config;
OApplication::_instance = 0;
// after deconstruction of the one-and-only application object,
// the construction of another object is allowed
}
OConfig* OApplication::config()
{
if ( !_config )
{
_config = new OConfig( _appname );
}
return _config;
}
void OApplication::init()
{
- d = new OApplicationPrivate();
+ d = new Private::OApplicationPrivate();
if ( !OApplication::_instance )
{
OApplication::_instance = this;
/* register SIGSEGV handler to give programs an option
* to exit gracefully, e.g. save or close devices or files.
struct sigaction sa;
sa.sa_handler = ( void (*)(int) ) &segv_handler;
sa.sa_flags = SA_SIGINFO | SA_RESTART;
sigemptyset(&sa.sa_mask);
sigaction(SIGSEGV, &sa, NULL);
*/
}
else
{
ofatal << "OApplication: Can't create more than one OApplication object. Aborting." << oendl;
//FIXME exit gracefully ?
::exit( -1 );
}
}
void OApplication::showMainWidget( QWidget* widget, bool nomax )
{
QPEApplication::showMainWidget( widget, nomax );
widget->setCaption( _appname );
}
void OApplication::setTitle( const QString& title ) const
{
if ( mainWidget() )
{
if ( !title.isNull() )
mainWidget()->setCaption( QString(_appname) + QString( " - " ) + title );
else
mainWidget()->setCaption( _appname );
}
}
+}
+}
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 @@
/*
                This file is part of the Opie Project
              Copyright (C) 2003 Michael 'Mickey' Lauer <mickey@Vanille.de>
=.
.=l.
           .>+-=
 _;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef OAPPLICATION_H
#define OAPPLICATION_H
-#define oApp OApplication::oApplication()
+#define oApp Opie::Core::OApplication::oApplication()
#include <qpe/qpeapplication.h>
-
+namespace Opie {
+namespace Core {
+namespace Private {
class OApplicationPrivate;
+} // private class
+
class OConfig;
class OApplication : public QPEApplication
{
Q_OBJECT
public:
/**
* Constructor. Parses command-line arguments and sets the window caption.
*
* @param rAppName application name. Will be used for finding the
* associated message, icon and configuration files
*
*/
OApplication( int& argc, char** argv, const QCString& rAppName );
/**
* Destructor. Destroys the application object and its children.
*/
virtual ~OApplication();
/**
* @returns the process-wide application object
*
* This is similar to the global @ref QApplication pointer qApp. It
* allows access to the single global OApplication object, since
* more than one cannot be created in the same application. It
* saves you the trouble of having to pass the pointer explicitly
* to every function that may require it.
*/
static OApplication* oApplication() { return _instance; };
/**
* Returns the application name as given during creation.
*
* @returns a reference to the application name
*/
const QCString& appName() const { return _appname; };
/**
* @returns the application session config object.
*
* @see OConfig
*/
OConfig* config();
/**
* Shows the main @a widget and sets the name of the application as window caption.
*/
virtual void showMainWidget( QWidget* widget, bool nomax = false );
/**
* Set the application title. The application title will be concatenated
* to the application name given in the constructor.
*
* @param title the title. If not given, resets caption to appname
*/
virtual void setTitle( const QString& title = QString::null ) const;
protected:
void init();
private:
const QCString _appname;
static OApplication* _instance;
OConfig* _config;
- OApplicationPrivate* d;
+ Private::OApplicationPrivate* d;
};
+} // Core
+} // Opie
+
#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,136 +1,138 @@
/*
                This file is part of the Opie Project
(C) 2003 Michael Lauer <mickey@tm.informatik.uni-frankfurt.de>
Inspired by the config classes from the KDE Project which are
=. (C) 1997 Matthias Kalle Dalheimer <kalle@kde.org>
.=l.
           .>+-=
 _;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
/* QT */
#include <qfont.h>
#include <qcolor.h>
/* OPIE */
#include <opie2/oconfig.h>
+using namespace Opie::Core;
+
OConfig::OConfig( const QString &name, Domain domain )
:Config( name, domain )
{
qDebug( "OConfig::OConfig()" );
}
OConfig::~OConfig()
{
qDebug( "OConfig::~OConfig()" );
}
QColor OConfig::readColorEntry( const QString& key, const QColor* pDefault ) const
{
QColor aRetColor;
int nRed = 0, nGreen = 0, nBlue = 0;
QString aValue = readEntry( key );
if( !aValue.isEmpty() )
{
if ( aValue.at(0) == '#' )
{
aRetColor.setNamedColor(aValue);
}
else
{
bool bOK;
// find first part (red)
int nIndex = aValue.find( ',' );
if( nIndex == -1 )
{
// return a sensible default -- Bernd
if( pDefault )
aRetColor = *pDefault;
return aRetColor;
}
nRed = aValue.left( nIndex ).toInt( &bOK );
// find second part (green)
int nOldIndex = nIndex;
nIndex = aValue.find( ',', nOldIndex+1 );
if( nIndex == -1 )
{
// return a sensible default -- Bernd
if( pDefault )
aRetColor = *pDefault;
return aRetColor;
}
nGreen = aValue.mid( nOldIndex+1,
nIndex-nOldIndex-1 ).toInt( &bOK );
// find third part (blue)
nBlue = aValue.right( aValue.length()-nIndex-1 ).toInt( &bOK );
aRetColor.setRgb( nRed, nGreen, nBlue );
}
}
else {
if( pDefault )
aRetColor = *pDefault;
}
return aRetColor;
}
// FIXME: The whole font handling has to be revised for Opie
QFont OConfig::readFontEntry( const QString& key, const QFont* pDefault ) const
{
/*
QFont aRetFont;
QString aValue = readEntry( key );
if( !aValue.isNull() ) {
if ( aValue.contains( ',' ) > 5 ) {
// KDE3 and upwards entry
if ( !aRetFont.fromString( aValue ) && pDefault )
aRetFont = *pDefault;
}
else {
// backward compatibility with older font formats
// ### remove KDE 3.1 ?
// find first part (font family)
int nIndex = aValue.find( ',' );
if( nIndex == -1 ){
if( pDefault )
aRetFont = *pDefault;
return aRetFont;
}
aRetFont.setFamily( aValue.left( nIndex ) );
// find second part (point size)
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 @@
/*
                This file is part of the Opie Project
(C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
Inspired by the config classes from the KDE Project which are
=. (C) 1997 Matthias Kalle Dalheimer <kalle@kde.org>
.=l.
           .>+-=
 _;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef OCONFIG_H
#define OCONFIG_H
//FIXME: Implement for X11 or reuse libqpe/Config there also?
//FIXME: Or rather use QSettings also for libqpe?
#include <qpe/config.h>
class QColor;
class QFont;
+namespace Opie {
+namespace Core {
+
/**
* A Configuration class based on the Qtopia @ref Config class
* featuring additional handling of color and font entries
*/
class OConfig : public Config
{
public:
/**
* Constructs a OConfig object with a @a name.
*/
OConfig( const QString &name, Domain domain = User );
/**
* Destructs the OConfig object.
*
* Writes back any dirty configuration entries, and destroys
* dynamically created objects.
*/
virtual ~OConfig();
/**
* @returns the name of the current group.
* The current group is used for searching keys and accessing entries.
+ * @todo make const
*/
const QString& group() { return git.key(); };
/**
* @returns a @ref QColor entry or a @a default value if the key is not found.
*/
QColor readColorEntry( const QString& key, const QColor* pDefault ) const;
/**
* @returns a @ref QFont value or a @a default value if the key is not found.
*/
QFont readFontEntry( const QString& key, const QFont* pDefault ) const;
+
+private:
+ class Private;
+ Private *d;
};
/**
* @brief Helper class for easier use of OConfig groups.
*
* Careful programmers always set the group of a
* @ref OConfig object to the group they want to read from
* and set it back to the old one of afterwards. This is usually
* written as:
* <pre>
*
* QString oldgroup config()->group();
* config()->setGroup( "TheGroupThatIWant" );
* ...
* config()->writeEntry( "Blah", "Blubb" );
*
* config()->setGroup( oldgroup );
* </pre>
*
* In order to facilitate this task, you can use
* OConfigGroupSaver. Simply construct such an object ON THE STACK
* when you want to switch to a new group. Then, when the object goes
* out of scope, the group will automatically be restored. If you
* want to use several different groups within a function or method,
* you can still use OConfigGroupSaver: Simply enclose all work with
* one group (including the creation of the OConfigGroupSaver object)
* in one block.
*
* @author Matthias Kalle Dalheimer <Kalle@kde.org>
* @version $Id$
* @see OConfig
*/
class OConfigGroupSaver
{
public:
/**
* Constructor.
* Create the object giving a @config object and a @a group to become
* the current group.
*/
OConfigGroupSaver( OConfig* config, QString group ) :_config(config), _oldgroup(config->group() )
{ _config->setGroup( group ); }
OConfigGroupSaver( OConfig* config, const char *group ) :_config(config), _oldgroup(config->group())
{ _config->setGroup( group ); }
OConfigGroupSaver( OConfig* config, const QCString &group ) : _config(config), _oldgroup(config->group())
{ _config->setGroup( group ); }
/**
* Destructor.
* Restores the last current group.
* @todo make it not inline for bc reasons. See KDE BC guide
*/
~OConfigGroupSaver() { _config->setGroup( _oldgroup ); }
OConfig* config() { return _config; };
private:
OConfig* _config;
QString _oldgroup;
OConfigGroupSaver( const OConfigGroupSaver& );
OConfigGroupSaver& operator=( const OConfigGroupSaver& );
+
+ class Private;
+ Private *d;
};
+}
+}
#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
@@ -1,164 +1,165 @@
/*
This file is part of the Opie Project
(C) 2003 Michael 'Mickey' Lauer (mickey@tm.informatik.uni-frankfurt.de)
(C) 2002 Holger Freyther (freyther@kde.org)
(C) 1997 Matthias Kalle Dalheimer (kalle@kde.org)
=.
.=l.
           .>+-=
 _;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
// Include this header without OPIE_NO_DEBUG defined to avoid having the oDebugInfo
// functions inlined to noops (which would then conflict with their definition here).
#include <opie2/odebug.h>
#ifdef OPIE_NO_DEBUG
#undef odDebug
#undef odBacktrace
#endif
/* OPIE */
#include <opie2/oapplication.h>
#include <opie2/oglobalsettings.h>
#include <opie2/oconfig.h>
/* QT */
#include <qfile.h>
#include <qmessagebox.h>
#include <qsocketdevice.h>
/* UNIX */
#include <stdlib.h> // abort
#include <unistd.h> // getpid
#include <stdarg.h> // vararg stuff
#include <ctype.h> // isprint
#include <syslog.h>
#include <errno.h>
#include <string.h>
#ifndef OPIE_NO_BACKTRACE
#include <execinfo.h>
#endif
-
+namespace Opie {
+namespace Core {
/*======================================================================================
* debug levels
*======================================================================================*/
enum DebugLevels {
ODEBUG_INFO = 0,
ODEBUG_WARN = 1,
ODEBUG_ERROR = 2,
ODEBUG_FATAL = 3
};
/*======================================================================================
* oDebug private data
*======================================================================================*/
/*======================================================================================
* the main debug function
*======================================================================================*/
static void oDebugBackend( unsigned short level, unsigned int area, const char *data)
{
//qDebug( "oDebugBackend: Level=%d, Area=%d, Data=%s", level, area, data );
// ML: OPIE doesn't use areacodes at the moment. See the KDE debug classes for an
// ML: example use. I think it's not necessary to implement such a strategy here.
// ML: Comments?
int priority = 0;
QString caption;
QString lev;
switch( level )
{
case ODEBUG_INFO: lev = "(Info)"; caption = "Info"; priority = LOG_INFO; break;
case ODEBUG_WARN: lev = "(Warn)"; caption = "Warning"; priority = LOG_WARNING; break;
case ODEBUG_FATAL: lev = "(Fatal)"; caption = "Fatal Error"; priority = LOG_CRIT; break;
default: qDebug( "oDebugBackend: Warning: Unknown debug level! - defaulting to ODEBUG_ERROR." );
case ODEBUG_ERROR: lev = "(Error)"; caption = "Error"; priority = LOG_ERR; break;
}
short output = OGlobalSettings::debugMode();
if (!oApp && (output == 1))
{
qDebug( "oDebugBackend: Warning: no oapplication object - can't use MsgBox" );
output = 2; // need an application object to use MsgBox
}
// gcc 2.9x is dumb and sucks... can you hear it?
//QString areaName = (oApp) ? oApp->appName() : "<unknown>";
QString areaName;
if ( oApp ) areaName = oApp->appName();
else areaName = "<unknown>";
// Output
switch( output )
{
case -1: // ignore
{
return;
}
case 0: // File
{
QString outputFilename = OGlobalSettings::debugOutput();
const int BUFSIZE = 4096;
char buf[BUFSIZE] = "";
buf[BUFSIZE-1] = '\0';
int nSize;
nSize = snprintf( buf, BUFSIZE-1, "%s: %s", (const char*) areaName, data);
QFile outputFile( outputFilename );
if ( outputFile.open( IO_WriteOnly | IO_Append ) )
{
if ( ( nSize == -1 ) || ( nSize >= BUFSIZE ) )
{
outputFile.writeBlock( buf, BUFSIZE-1 );
}
else
{
outputFile.writeBlock( buf, nSize );
}
}
else
{
qDebug( "ODebug: can't write to file '%s' (%s)", (const char*) outputFilename, strerror(errno) );
}
break;
} // automatic close of file here
case 1: // Message Box
{
// Since we are in opiecore here, we cannot use OMsgBox and use
// QMessageBox instead
caption += QString("(") + areaName + ")";
QMessageBox::warning( 0L, caption, data, ("&OK") ); // tr?
@@ -521,100 +522,104 @@ odbgstream& odbgstream::operator<<( const QSize& s )
odbgstream& odbgstream::operator<<( const QRect& r )
{
*this << "[" << r.left() << ", " << r.top() << " - " << r.right() << ", " << r.bottom() << "]";
return *this;
}
odbgstream& odbgstream::operator<<( const QRegion& reg )
{
/* Qt2 doesn't have a QMemArray... :(
*this << "[ ";
QMemArray<QRect>rs=reg.rects();
for (uint i=0;i<rs.size();++i)
*this << QString("[%1, %2 - %3, %4] ").arg(rs[i].left()).arg(rs[i].top()).arg(rs[i].right()).arg(rs[i].bottom() ) ;
*this <<"]";
*/
return *this;
}
odbgstream& odbgstream::operator<<( const QStringList& l )
{
*this << "(";
*this << l.join(",");
*this << ")";
return *this;
}
odbgstream& odbgstream::operator<<( const QColor& c )
{
if ( c.isValid() )
*this << c.name();
else
*this << "(invalid/default)";
return *this;
}
odbgstream& odbgstream::operator<<( const QBrush& b)
{
static const char* const s_brushStyles[] = {
"NoBrush", "SolidPattern", "Dense1Pattern", "Dense2Pattern", "Dense3Pattern",
"Dense4Pattern", "Dense5Pattern", "Dense6Pattern", "Dense7Pattern",
"HorPattern", "VerPattern", "CrossPattern", "BDiagPattern", "FDiagPattern",
"DiagCrossPattern" };
*this <<"[ style: ";
*this <<s_brushStyles[ b.style() ];
*this <<" color: ";
// can't use operator<<(str, b.color()) because that terminates a odbgstream (flushes)
if ( b.color().isValid() )
*this <<b.color().name() ;
else
*this <<"(invalid/default)";
if ( b.pixmap() )
*this <<" has a pixmap";
*this <<" ]";
return *this;
}
QString odBacktrace( int levels )
{
QString s;
#ifndef OPIE_NO_BACKTRACE
void* trace[256];
int n = backtrace(trace, 256);
char** strings = backtrace_symbols (trace, n);
if ( levels != -1 )
n = QMIN( n, levels );
s = "[\n";
for (int i = 0; i < n; ++i)
s += QString::number(i) +
QString::fromLatin1(": ") +
QString::fromLatin1(strings[i]) + QString::fromLatin1("\n");
s += "]\n";
free (strings);
#endif
return s;
}
void odClearDebugConfig()
{
/*
delete oDebug_data->config;
oDebug_data->config = 0;
*/
}
+
#ifdef OPIE_NO_DEBUG
#define odDebug ondDebug
#define odBacktrace ondBacktrace
#endif
+
+}
+} \ 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
@@ -1,145 +1,148 @@
/*
This file is part of the Opie Project
(C) 2003 Michael 'Mickey' Lauer (mickey@tm.informatik.uni-frankfurt.de)
Inspired by the KDE debug classes, which are
(C) 1997 Matthias Kalle Dalheimer (kalle@kde.org)
(C) 2002 Holger Freyther (freyther@kde.org)
=.
.=l.
           .>+-=
 _;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef ODEBUG_H
#define ODEBUG_H
#include <qstring.h>
class QWidget;
class QDateTime;
class QDate;
class QTime;
class QPoint;
class QSize;
class QRect;
class QRegion;
class QStringList;
class QColor;
class QBrush;
+namespace Opie {
+namespace Core {
+
class odbgstream;
class ondbgstream;
#ifdef __GNUC__
#define o_funcinfo "[" << __PRETTY_FUNCTION__ << "] "
#else
#define o_funcinfo "[" << __FILE__ << ":" << __LINE__ << "] "
#endif
#define o_lineinfo "[" << __FILE__ << ":" << __LINE__ << "] "
#define owarn odWarning()
#define oerr odError()
#define odebug odDebug()
#define ofatal odFatal()
#define oendl "\n"
class odbgstreamprivate;
/**
* odbgstream is a text stream that allows you to print debug messages.
* Using the overloaded "<<" operator you can send messages. Usually
* you do not create the odbgstream yourself, but use @ref odDebug() (odebug)
* @ref odWarning() (owarn), @ref odError() (oerr) or @ref odFatal (ofatal) to obtain one.
*
* Example:
* <pre>
* int i = 5;
* odebug << "The value of i is " << i << oendl;
* </pre>
* @see odbgstream
*/
/*======================================================================================
* odbgstream
*======================================================================================*/
class odbgstream
{
public:
/**
* @internal
*/
odbgstream(unsigned int _area, unsigned int _level, bool _print = true);
odbgstream(const char * initialString, unsigned int _area, unsigned int _level, bool _print = true);
odbgstream(odbgstream &str);
odbgstream(const odbgstream &str);
virtual ~odbgstream();
/**
* Prints the given value.
* @param i the boolean to print (as "true" or "false")
* @return this stream
*/
odbgstream &operator<<(bool i);
/**
* Prints the given value.
* @param i the short to print
* @return this stream
*/
odbgstream &operator<<(short i);
/**
* Prints the given value.
* @param i the unsigned short to print
* @return this stream
*/
odbgstream &operator<<(unsigned short i);
/**
* Prints the given value.
* @param i the char to print
* @return this stream
*/
odbgstream &operator<<(char i);
/**
* Prints the given value.
* @param i the unsigned char to print
* @return this stream
*/
odbgstream &operator<<(unsigned char i);
/**
* Prints the given value.
* @param i the int to print
* @return this stream
*/
odbgstream &operator<<(int i);
/**
* Prints the given value.
* @param i the unsigned int to print
* @return this stream
*/
odbgstream &operator<<(unsigned int i);
/**
* Prints the given value.
* @param i the long to print
* @return this stream
*/
odbgstream &operator<<(long i);
@@ -301,174 +304,180 @@ class ondbgstream {
~ondbgstream() {}
/**
* Does nothing.
* @return this stream
*/
ondbgstream &operator<<(short int ) { return *this; }
/**
* Does nothing.
* @return this stream
*/
ondbgstream &operator<<(unsigned short int ) { return *this; }
/**
* Does nothing.
* @return this stream
*/
ondbgstream &operator<<(char ) { return *this; }
/**
* Does nothing.
* @return this stream
*/
ondbgstream &operator<<(unsigned char ) { return *this; }
/**
* Does nothing.
* @return this stream
*/
ondbgstream &operator<<(int ) { return *this; }
/**
* Does nothing.
* @return this stream
*/
ondbgstream &operator<<(unsigned int ) { return *this; }
/**
* Does nothing.
*/
void flush() {}
/**
* Does nothing.
* @return this stream
*/
ondbgstream &operator<<(const QString& ) { return *this; }
/**
* Does nothing.
* @return this stream
*/
ondbgstream &operator<<(const QCString& ) { return *this; }
/**
* Does nothing.
* @return this stream
*/
ondbgstream &operator<<(const char *) { return *this; }
/**
* Does nothing.
* @return this stream
*/
ondbgstream& operator<<(const void *) { return *this; }
/**
* Does nothing.
* @return this stream
*/
ondbgstream& operator<<(void *) { return *this; }
/**
* Does nothing.
* @return this stream
*/
ondbgstream& operator<<(double) { return *this; }
/**
* Does nothing.
* @return this stream
*/
ondbgstream& operator<<(long) { return *this; }
/**
* Does nothing.
* @return this stream
*/
ondbgstream& operator<<(unsigned long) { return *this; }
/**
* Does nothing.
* @return this stream
*/
ondbgstream& operator << (QWidget*) { return *this; }
/**
* Does nothing.
* @return this stream
*/
ondbgstream &form(const char *, ...) { return *this; }
ondbgstream& operator<<( const QDateTime& ) { return *this; }
ondbgstream& operator<<( const QDate& ) { return *this; }
ondbgstream& operator<<( const QTime& ) { return *this; }
ondbgstream& operator<<( const QPoint & ) { return *this; }
ondbgstream& operator<<( const QSize & ) { return *this; }
ondbgstream& operator<<( const QRect & ) { return *this; }
ondbgstream& operator<<( const QRegion & ) { return *this; }
ondbgstream& operator<<( const QStringList & ) { return *this; }
ondbgstream& operator<<( const QColor & ) { return *this; }
ondbgstream& operator<<( const QBrush & ) { return *this; }
+
+private:
+ class Private;
+ Private *d;
};
/*======================================================================================
* related functions
*======================================================================================*/
/**
* Does nothing.
* @param a stream
* @return the given @p s
*/
inline ondbgstream& endl( ondbgstream & s) { return s; }
/**
* Does nothing.
* @param a stream
* @return the given @p s
*/
inline ondbgstream& flush( ondbgstream & s) { return s; }
inline ondbgstream& perror( ondbgstream & s) { return s; }
/**
* Returns a debug stream. You can use it to print debug
* information.
* @param area an id to identify the output, 0 for default
*/
odbgstream odDebug(int area = 0);
odbgstream odDebug(bool cond, int area = 0);
/**
* Returns a backtrace.
* @param levels the number of levels (-1 for unlimited) of the backtrace
* @return a backtrace
*/
QString odBacktrace(int levels = -1);
/**
* Returns a dummy debug stream. The stream does not print anything.
* @param area an id to identify the output, 0 for default
* @see odDebug()
*/
inline ondbgstream ondDebug(int = 0) { return ondbgstream(); }
inline ondbgstream ondDebug(bool , int = 0) { return ondbgstream(); }
inline QString ondBacktrace() { return QString::null; }
inline QString ondBacktrace(int) { return QString::null; }
/**
* Returns a warning stream. You can use it to print warning
* information.
* @param area an id to identify the output, 0 for default
*/
odbgstream odWarning(int area = 0);
odbgstream odWarning(bool cond, int area = 0);
/**
* Returns an error stream. You can use it to print error
* information.
* @param area an id to identify the output, 0 for default
*/
odbgstream odError(int area = 0);
odbgstream odError(bool cond, int area = 0);
/**
* Returns a fatal error stream. You can use it to print fatal error
* information.
* @param area an id to identify the output, 0 for default
*/
odbgstream odFatal(int area = 0);
odbgstream odFatal(bool cond, int area = 0);
/**
* Deletes the odebugrc cache and therefore forces KDebug to reread the
* config file
*/
void odClearDebugConfig();
#ifdef OPIE_NO_DEBUG
#define odDebug ondDebug
#define odBacktrace ondBacktrace
#endif
#endif
+}
+}
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,136 +1,138 @@
/*
This file is part of the Opie Project
Copyright (C) 2003 Michael 'Mickey' Lauer <mickey@Vanille.de>
=. Copyright (C) 2004 Holger 'zecke' Freyther <zecke@handhelds.org>
.=l.
.>+-=
_;:, .> :=|. This program is free software; you can
.> <`_, > . <= redistribute it and/or modify it under
:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
.="- .-=="i, .._ License as published by the Free Software
- . .-<_> .<> Foundation; either version 2 of the License,
._= =} : or (at your option) any later version.
.%`+i> _;_.
.i_,=:_. -<s. This program is distributed in the hope that
+ . -:. = it will be useful, but WITHOUT ANY WARRANTY;
: .. .:, . . . without even the implied warranty of
=_ + =;=|` MERCHANTABILITY or FITNESS FOR A
_.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.= = ; Library General Public License for more
++= -. .` .: details.
: = ...= . :.=-
-. .:....=;==+<; You should have received a copy of the GNU
-_. . . )=. = Library General Public License along with
-- :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include <opie2/oglobal.h>
#include <qtextstream.h>
#include <qdir.h>
#include <qpe/mimetype.h>
#include <qpe/qpeapplication.h>
#include <qpe/storage.h>
#include <unistd.h>
#include <sys/types.h>
+using namespace Opie::Core;
+
static const char Base64EncMap[64] =
{
0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48,
0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50,
0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58,
0x59, 0x5A, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66,
0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E,
0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76,
0x77, 0x78, 0x79, 0x7A, 0x30, 0x31, 0x32, 0x33,
0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x2B, 0x2F
};
static char Base64DecMap[128] =
{
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x3E, 0x00, 0x00, 0x00, 0x3F,
0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B,
0x3C, 0x3D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06,
0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E,
0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16,
0x17, 0x18, 0x19, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20,
0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28,
0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30,
0x31, 0x32, 0x33, 0x00, 0x00, 0x00, 0x00, 0x00
};
OConfig* OGlobal::_config = 0;
OConfig* OGlobal::_qpe_config = 0;
OConfig* OGlobal::config()
{
if ( !OGlobal::_config )
{
// odebug classes are reading config, so can't use them here!
qDebug( "OGlobal::creating global configuration instance." );
OGlobal::_config = new OConfig( "global" );
}
return OGlobal::_config;
}
/**
* Return the internal builtin Global::Command object
*
*/
Global::Command* OGlobal::builtinCommands() {
return builtin;
}
/**
* Return the internal builtin QGuardedPtr<QWidget> object
*/
QGuardedPtr<QWidget>* OGlobal::builtinRunning() {
return running;
}
/**
* \brief generate a new UUID as QString
* Return a new UUID as QString. UUID are global unique
*
*
* @return the UUID or QString::null
*/
QString OGlobal::generateUuid() {
QFile file( "/proc/sys/kernel/random/uuid" );
if (!file.open(IO_ReadOnly ) )
return QString::null;
QTextStream stream(&file);
return "{" + stream.read().stripWhiteSpace() + "}";
}
/**
* \brief Encode a QByteArray in base64
*
* An Implementation of the RF1521 base64 encoding.
*
* The boolean argument determines if the encoded data is
* going to be restricted to 76 characters or less per line
* as specified by RFC 2045. If @p insertLFs is true, then
* there will be 76 characters or less per line.
*
* If you use this to create a QCString remember that it is null terminated!
* \code
* QByteArray ar = OGlobal::encodeBase64(&array);
@@ -219,192 +221,192 @@ QByteArray OGlobal::encodeBase64(const QByteArray& in, bool insertLFs ) {
return out;
}
/**
* Decodes the given data that was encoded with the base64
* algorithm.
*
*
* @param in the encoded data to be decoded.
* @return the decoded QByteArray or QByteArray() in case of failure
* @see OGlobal::encodeBase64
*/
QByteArray OGlobal::decodeBase64( const QByteArray& in) {
if ( in.isEmpty() )
return QByteArray();
QByteArray out;
unsigned int count = 0;
unsigned int len = in.size(), tail = len;
const char* data = in.data();
// Deal with possible *nix "BEGIN" marker!!
while ( count < len && (data[count] == '\n' || data[count] == '\r' ||
data[count] == '\t' || data[count] == ' ') )
count++;
if ( strncasecmp(data+count, "begin", 5) == 0 )
{
count += 5;
while ( count < len && data[count] != '\n' && data[count] != '\r' )
count++;
while ( count < len && (data[count] == '\n' || data[count] == '\r') )
count ++;
data += count;
tail = (len -= count);
}
// Find the tail end of the actual encoded data even if
// there is/are trailing CR and/or LF.
while ( data[tail-1] == '=' || data[tail-1] == '\n' ||
data[tail-1] == '\r' )
if ( data[--tail] != '=' ) len = tail;
unsigned int outIdx = 0;
out.resize( (count=len) );
for (unsigned int idx = 0; idx < count; idx++)
{
// Adhere to RFC 2045 and ignore characters
// that are not part of the encoding table.
unsigned char ch = data[idx];
if ( (ch > 47 && ch < 58) || (ch > 64 && ch < 91 ) ||
(ch > 96 && ch < 123)|| ch == '+' || ch == '/' || ch == '=')
{
out[outIdx++] = Base64DecMap[ch];
}
else
{
len--;
tail--;
}
}
// kdDebug() << "Tail size = " << tail << ", Length size = " << len << endl;
// 4-byte to 3-byte conversion
len = (tail>(len/4)) ? tail-(len/4) : 0;
unsigned int sidx = 0, didx = 0;
if ( len > 1 )
{
while (didx < len-2)
{
out[didx] = (((out[sidx] << 2) & 255) | ((out[sidx+1] >> 4) & 003));
out[didx+1] = (((out[sidx+1] << 4) & 255) | ((out[sidx+2] >> 2) & 017));
out[didx+2] = (((out[sidx+2] << 6) & 255) | (out[sidx+3] & 077));
sidx += 4;
didx += 3;
}
}
if (didx < len)
out[didx] = (((out[sidx] << 2) & 255) | ((out[sidx+1] >> 4) & 003));
if (++didx < len )
out[didx] = (((out[sidx+1] << 4) & 255) | ((out[sidx+2] >> 2) & 017));
// Resize the output buffer
if ( len == 0 || len < out.size() )
out.resize(len);
return out;
}
bool OGlobal::isAppLnkFileName( const QString& str )
{
- if (str.length()==0||str.at(str.length()-1)==QDir::separator()) return false;
+ if (str.isEmpty()||str.at(str.length()-1)==QDir::separator()) return false;
return str.startsWith(MimeType::appsFolderName()+QDir::separator());
}
/* ToDo:
* This fun should check the document-path value for the mounted media
* which has to be implemented later. this moment we just check for a
* mounted media name.
*/
bool OGlobal::isDocumentFileName( const QString& file )
{
- if (file.length()==0||file.at(file.length()-1)==QDir::separator()) return false;
+ if (file.isEmpty()||file.at(file.length()-1)==QDir::separator()) return false;
if (file.startsWith(QPEApplication::documentDir()+QDir::separator())) return true;
StorageInfo si;
QList< FileSystem > fl = si.fileSystems();
FileSystem*fs;
for (fs = fl.first();fs!=0;fs=fl.next()) {
if (fs->isRemovable()&&file.startsWith(fs->name()+QDir::separator()))
return true;
}
if (file.startsWith(homeDirPath())+"/Documents/") return true;
return false;
}
QString OGlobal::tempDirPath()
{
static QString defstring="/tmp";
char * tmpp = 0;
if ( (tmpp=getenv("TEMP"))) {
return tmpp;
}
return defstring;
}
QString OGlobal::homeDirPath()
{
char * tmpp = getenv("HOME");
return (tmpp?tmpp:"/");
}
bool OGlobal::weekStartsOnMonday()
{
OConfig*conf=OGlobal::qpe_config();
if (!conf)return false;
conf->setGroup("Time");
return conf->readBoolEntry("MONDAY",true);
}
void OGlobal::setWeekStartsOnMonday( bool what)
{
OConfig*conf=OGlobal::qpe_config();
if (!conf)return;
conf->setGroup("Time");
return conf->writeEntry("MONDAY",what);
}
bool OGlobal::useAMPM()
{
OConfig*conf=OGlobal::qpe_config();
if (!conf)return false;
conf->setGroup("Time");
return conf->readBoolEntry("AMPM",false);
}
void OGlobal::setUseAMPM( bool what)
{
OConfig*conf=OGlobal::qpe_config();
if (!conf)return;
conf->setGroup("Time");
return conf->writeEntry("AMPM",what);
}
OConfig* OGlobal::qpe_config()
{
if ( !OGlobal::_qpe_config ) {
OGlobal::_qpe_config = new OConfig( "qpe" );
}
return OGlobal::_qpe_config;
}
bool OGlobal::truncateFile( QFile &f, off_t size )
{
/* or should we let enlarge Files? then remove this
f.size()< part! - Alwin
*/
if (!f.exists()||f.size()<(unsigned)size) return false;
bool closeit=false;
if (!f.isOpen()) {
closeit=true;
f.open(IO_Raw | IO_ReadWrite | IO_Append);
}
if (!f.isOpen()) { return false; }
int r = ftruncate(f.handle(),size);
if (closeit) f.close();
return r==0;
}
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
@@ -1,151 +1,159 @@
/*
This file is part of the Opie Project
Copyright (C) 2003 Michael 'Mickey' Lauer <mickey@Vanille.de>
=. Copyright (C) 2004 Holger 'zecke' Freyther <zecke@handhelds.org>
.=l.
.>+-=
_;:, .> :=|. This program is free software; you can
.> <`_, > . <= redistribute it and/or modify it under
:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
.="- .-=="i, .._ License as published by the Free Software
- . .-<_> .<> Foundation; either version 2 of the License,
._= =} : or (at your option) any later version.
.%`+i> _;_.
.i_,=:_. -<s. This program is distributed in the hope that
+ . -:. = it will be useful, but WITHOUT ANY WARRANTY;
: .. .:, . . . without even the implied warranty of
=_ + =;=|` MERCHANTABILITY or FITNESS FOR A
_.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.= = ; Library General Public License for more
++= -. .` .: details.
: = ...= . :.=-
-. .:....=;==+<; You should have received a copy of the GNU
-_. . . )=. = Library General Public License along with
-- :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef OGLOBAL_H
#define OGLOBAL_H
#include <opie2/oconfig.h>
#ifndef private
#define HACK_DEFINED
#define private protected
#endif
#include <qpe/global.h>
#ifdef HACK_DEFINED
#undef private
#endif
#include <sys/types.h>
//FIXME Is it wise or even necessary to inherit OGlobal from Global?
// once we totally skip libqpe it should ideally swallow Global -zecke
// You're right. I deleted global as the base class. -mickeyl
class QFile;
class QString;
class DateFormat;
+
+
+
+namespace Opie {
+namespace Core {
/**
*\brief OGlobal contains a list of generic functions
*
* The class OGlobal contains small utility functions
* which might be useful for other applications to use. It features access
* to the global device config and specialized functions to get information
* out of this config like Weekstart or Owner name.
*
* @todo ODP implement the things from Global which are good
* @author mickey,alwin,zecke
* @version 0.1
*/
class OGlobal : public Global
{
public:
// how do they relate to our Document Idea
/** @name Document System related functions
*
*/
//@{
static bool isAppLnkFileName( const QString& str );
static bool isDocumentFileName( const QString& file );
//@}
/** @name File Operations
* File operations provided by OGlobal
*/
//@{
/** the content of TEMP
* reads the environment variable TEMP and returns the content.
* if not set returns "/tmp"
* @return a string containing a dir without trailing slash!
*/
static QString tempDirPath();
/** the content of HOME
* reads the environment variable HOME and returns the content.
* if not set returns "/"
* @return a string containing a dir without trailing slash!
*/
static QString homeDirPath();
static QString tempFileName( const QString& );
static bool renameFile( const QString& from, const QString& to );
static bool truncateFile( QFile &f, off_t size );
//@}
static QString generateUuid();
/** @name Convert Content
* Convert Content of a QByteArray
*/
//@{
static QByteArray encodeBase64(const QByteArray&, bool insertLF = false );
static QByteArray decodeBase64(const QByteArray& );
//@}
//FIXME Do we want to put that into OApplication as in KApplication? -zecke
// We already have a per-application config in OApplication
// ( accessed through oApp->config() ), but this one is the global one! -mickeyl
/** @name Config and Owner related Information
*
*/
//@{
static OConfig* config();
static OConfig* qpe_config();
static QString ownerName();
static bool weekStartsOnMonday();
static bool useAMPM();
#ifdef ODP
#error "Fix dateFormat"
/**
* For Qt3/Qt4 we can use QDate::toString(OGlobal::dateFormat)
* See if we need to use the function with String in it
* Anyway this is the future
* for now still use TimeString!
*/
#endif
static DateFormat dateFormat();
static void setDateFormat( const DateFormat& );
static void setWeekStartsOnMonday( bool );
static void setUseAMPM( bool );
//@}
//@{
static Global::Command* builtinCommands();
static QGuardedPtr<QWidget>* builtinRunning();
//@}
private:
static OConfig* _config;
static OConfig* _qpe_config;
+ class Private;
+ Private *d;
};
-
+}
+}
#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,142 +1,145 @@
/*
                This file is part of the Opie Project
              Copyright (C) 2003 Michael Lauer <mickey@tm.informatik.uni-frankfurt.de>
Inspired by the KDE globalsettings which are
Copyright (C) 2000 David Faure <faure@kde.org>
=.
.=l.
           .>+-=
 _;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
/* OPIE */
#include <opie2/oglobalsettings.h>
#include <opie2/oconfig.h>
#include <opie2/oglobal.h>
/* QT */
#include <qdir.h>
/* UNIX */
#include <stdlib.h>
+
+using namespace Opie::Core;
+
QString* OGlobalSettings::s_desktopPath = 0;
QString* OGlobalSettings::s_autostartPath = 0;
QString* OGlobalSettings::s_trashPath = 0;
QString* OGlobalSettings::s_documentPath = 0;
QFont *OGlobalSettings::_generalFont = 0;
QFont *OGlobalSettings::_fixedFont = 0;
QFont *OGlobalSettings::_toolBarFont = 0;
QFont *OGlobalSettings::_menuFont = 0;
QFont *OGlobalSettings::_windowTitleFont = 0;
QFont *OGlobalSettings::_taskbarFont = 0;
QColor *OGlobalSettings::OpieGray = 0;
QColor *OGlobalSettings::OpieHighlight = 0;
QColor *OGlobalSettings::OpieAlternate = 0;
OGlobalSettings::OMouseSettings *OGlobalSettings::s_mouseSettings = 0;
//FIXME: Add manipulators to the accessors
int OGlobalSettings::dndEventDelay()
{
OConfig *c = OGlobal::config();
OConfigGroupSaver cgs( c, "General" );
return c->readNumEntry("DndDelay", 2);
}
bool OGlobalSettings::singleClick()
{
OConfig *c = OGlobal::config();
OConfigGroupSaver cgs( c, "OPIE" );
return c->readBoolEntry("SingleClick", OPIE_DEFAULT_SINGLECLICK);
}
bool OGlobalSettings::insertTearOffHandle()
{
OConfig *c = OGlobal::config();
OConfigGroupSaver cgs( c, "OPIE" );
return c->readBoolEntry("InsertTearOffHandle", OPIE_DEFAULT_INSERTTEAROFFHANDLES);
}
bool OGlobalSettings::changeCursorOverIcon()
{
OConfig *c = OGlobal::config();
OConfigGroupSaver cgs( c, "OPIE" );
return c->readBoolEntry("ChangeCursor", OPIE_DEFAULT_CHANGECURSOR);
}
bool OGlobalSettings::visualActivate()
{
OConfig *c = OGlobal::config();
OConfigGroupSaver cgs( c, "OPIE" );
return c->readBoolEntry("VisualActivate", OPIE_DEFAULT_VISUAL_ACTIVATE);
}
unsigned int OGlobalSettings::visualActivateSpeed()
{
OConfig *c = OGlobal::config();
OConfigGroupSaver cgs( c, "OPIE" );
return
c->readNumEntry(
"VisualActivateSpeed",
OPIE_DEFAULT_VISUAL_ACTIVATE_SPEED
);
}
int OGlobalSettings::autoSelectDelay()
{
OConfig *c = OGlobal::config();
OConfigGroupSaver cgs( c, "OPIE" );
return c->readNumEntry("AutoSelectDelay", OPIE_DEFAULT_AUTOSELECTDELAY);
}
OGlobalSettings::Completion OGlobalSettings::completionMode()
{
int completion;
OConfig *c = OGlobal::config();
OConfigGroupSaver cgs( c, "General" );
completion = c->readNumEntry("completionMode", -1);
if ((completion < (int) CompletionNone) ||
(completion > (int) CompletionPopupAuto))
{
completion = (int) CompletionPopup; // Default
}
return (Completion) completion;
}
bool OGlobalSettings::showContextMenusOnPress ()
{
OConfig *c = OGlobal::config();
OConfigGroupSaver cgs (c, "ContextMenus");
return cgs.config()->readBoolEntry("ShowOnPress", true);
}
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,147 +1,153 @@
/*
                This file is part of the Opie Project
              Copyright (C) 2003 Michael Lauer <mickey@tm.informatik.uni-frankfurt.de>
Inspired by KDE OGlobalSettings
Copyright (C) 2000 David Faure <faure@kde.org>
=.
.=l.
           .>+-=
 _;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef OGLOBALSETTINGS_H
#define OGLOBALSETTINGS_H
#include <qstring.h>
#include <qcolor.h>
#include <qfont.h>
+/**
+ * \todo make real const values
+ */
#define OPIE_DEFAULT_SINGLECLICK true
#define OPIE_DEFAULT_INSERTTEAROFFHANDLES true
#define OPIE_DEFAULT_AUTOSELECTDELAY -1
#define OPIE_DEFAULT_CHANGECURSOR true
#define OPIE_DEFAULT_LARGE_CURSOR false
#define OPIE_DEFAULT_VISUAL_ACTIVATE true
#define OPIE_DEFAULT_VISUAL_ACTIVATE_SPEED 50
//FIXME: There's still a whole lot of stuff in here which has to be revised
//FIXME: before public usage... lack of time to do it at once - so it will
//FIXME: happen step-by-step. ML.
// we should not habe too much configure options!!!!!! -zecke
+namespace Opie {
+namespace Core {
+
/**
* Access the OPIE global configuration settings.
*
*/
class OGlobalSettings
{
public:
/**
* Returns a threshold in pixels for drag & drop operations.
* As long as the mouse movement has not exceeded this number
* of pixels in either X or Y direction no drag operation may
* be started. This prevents spurious drags when the user intended
* to click on something but moved the mouse a bit while doing so.
*
* For this to work you must save the position of the mouse (oldPos)
* in the @ref QWidget::mousePressEvent().
* When the position of the mouse (newPos)
* in a @ref QWidget::mouseMoveEvent() exceeds this threshold
* you may start a drag
* which should originate from oldPos.
*
* Example code:
* <pre>
* void OColorCells::mousePressEvent( QMouseEvent *e )
* {
* mOldPos = e->pos();
* }
*
* void OColorCells::mouseMoveEvent( QMouseEvent *e )
* {
* if( !(e->state() && LeftButton)) return;
*
* int delay = OGlobalSettings::dndEventDelay();
* QPoint newPos = e->pos();
* if(newPos.x() > mOldPos.x()+delay || newPos.x() < mOldPos.x()-delay ||
* newPos.y() > mOldPos.y()+delay || newPos.y() < mOldPos.y()-delay)
* {
* // Drag color object
* int cell = posToCell(mOldPos); // Find color at mOldPos
* if ((cell != -1) && colors[cell].isValid())
* {
* OColorDrag *d = OColorDrag::makeDrag( colors[cell], this);
* d->dragCopy();
* }
* }
* }
* </pre>
*
*/
// we do not support DND at the momemt -zecke
static int dndEventDelay();
/**
* Returns whether OPIE runs in single (default) or double click
* mode.
*
* @return @p true if single click mode, or @p false if double click mode.
*
* see @ref http://opie.handhelds.org/documentation/standards/opie/style/mouse/index.html
**/
static bool singleClick();
/**
* Returns whether tear-off handles are inserted in OPopupMenus.
**/
// would clutter the small screen -zecke
static bool insertTearOffHandle();
/**
* @return the OPIE setting for "change cursor over icon"
*/
static bool changeCursorOverIcon();
/**
* @return whether to show some feedback when an item (specifically an
* icon) is activated.
*/
static bool visualActivate();
static unsigned int visualActivateSpeed();
/**
* Returns the OPIE setting for the auto-select option
*
* @return the auto-select delay or -1 if auto-select is disabled.
*/
static int autoSelectDelay();
/**
* Returns the OPIE setting for the shortcut key to open
* context menus.
*
* @return the key that pops up context menus.
*/
static int contextMenuKey();
@@ -275,99 +281,105 @@ class OGlobalSettings
/**
* The default color to use when highlighting toolbar buttons
*/
static QColor toolBarHighlightColor();
static QColor inactiveTitleColor();
static QColor inactiveTextColor();
static QColor activeTitleColor();
static QColor activeTextColor();
static int contrast();
/**
* The default colors to use for text and links.
*/
static QColor baseColor(); // Similair to QColorGroup::base()
static QColor textColor(); // Similair to QColorGroup::text()
static QColor linkColor();
static QColor visitedLinkColor();
static QColor highlightedTextColor(); // Similair to QColorGroup::hightlightedText()
static QColor highlightColor(); // Similair to QColorGroup::highlight()
/**
* Returns the alternate background color used by @ref OListView with
* @ref OListViewItem. Any other list that uses alternating background
* colors should use this too, to obey to the user's preferences. Returns
* an invalid color if the user doesn't want alternating backgrounds.
* @see #calculateAlternateBackgroundColor
*/
static QColor alternateBackgroundColor();
/**
* Calculates a color based on @p base to be used as alternating
* color for e.g. listviews.
* @see #alternateBackgroundColor
*/
static QColor calculateAlternateBackgroundColor(const QColor& base);
static QFont generalFont();
static QFont fixedFont();
static QFont toolBarFont();
static QFont menuFont();
static QFont windowTitleFont();
static QFont taskbarFont();
/**
* Returns if the user specified multihead. In case the display
* has multiple screens, the return value of this function specifies
* if the user wants OPIE to run on all of them or just on the primary
*/
static bool isMultiHead();
private:
/**
* reads in all paths from kdeglobals
*/
static void initStatic();
/**
* initialise kde2Blue
*/
static void initColors();
/**
* drop cached values for fonts (called by OApplication)
*/
static void rereadFontSettings();
/**
* drop cached values for paths (called by OApplication)
*/
static void rereadPathSettings();
/**
* drop cached values for mouse settings (called by OApplication)
*/
static void rereadMouseSettings();
static QString* s_desktopPath;
static QString* s_autostartPath;
static QString* s_trashPath;
static QString* s_documentPath;
static QFont *_generalFont;
static QFont *_fixedFont;
static QFont *_toolBarFont;
static QFont *_menuFont;
static QFont *_windowTitleFont;
static QFont *_taskbarFont;
static QColor * kde2Gray;
static QColor * kde2Blue;
static QColor * kde2AlternateColor;
static OMouseSettings *s_mouseSettings;
static QColor * OpieGray;
static QColor * OpieBlue;
static QColor * OpieAlternate;
static QColor * OpieHighlight;
friend class OApplication;
+private:
+ class Private;
+ Private *d;
};
+}
+}
+
#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 @@
TEMPLATE = lib
CONFIG += qt warn_on debug
DESTDIR = $(OPIEDIR)/lib
HEADERS = oapplication.h \
oconfig.h \
odebug.h \
oglobal.h \
oglobalsettings.h \
oprocess.h \
oprocctrl.h \
osmartpointer.h \
- ostorageinfo.h \
- xmltree.h
+ ostorageinfo.h
SOURCES = oapplication.cpp \
oconfig.cpp \
odebug.cpp \
oglobal.cpp \
oglobalsettings.cpp \
oprocess.cpp \
oprocctrl.cpp \
- ostorageinfo.cpp \
- xmltree.cc
+ ostorageinfo.cpp
include ( device/device.pro )
INTERFACES =
TARGET = opiecore2
-VERSION = 1.8.5
+VERSION = 1.9.0
INCLUDEPATH += $(OPIEDIR)/include
DEPENDPATH += $(OPIEDIR)/include
!contains( platform, x11 ) {
LIBS = -lqpe
include ( $(OPIEDIR)/include.pro )
}
contains( platform, x11 ) {
LIBS = -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib
}
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,139 +1,141 @@
/* This file is part of the KDE libraries
Copyright (C) 1997 Christian Czezakte (e9025461@student.tuwien.ac.at)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
//
// KPROCESSCONTROLLER -- A helper class for KProcess
//
// version 0.3.1, Jan, 8th 1997
//
// (C) Christian Czezatke
// e9025461@student.tuwien.ac.at
// Ported by Holger Freyther
//
//#include <config.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <assert.h>
#include <qsocketnotifier.h>
#include "oprocctrl.h"
+using namespace Opie::Core::Private;
+
OProcessController *OProcessController::theOProcessController = 0;
struct sigaction OProcessController::oldChildHandlerData;
bool OProcessController::handlerSet = false;
OProcessController::OProcessController()
{
assert( theOProcessController == 0 );
if (0 > pipe(fd))
printf(strerror(errno));
notifier = new QSocketNotifier(fd[0], QSocketNotifier::Read);
notifier->setEnabled(true);
QObject::connect(notifier, SIGNAL(activated(int)),
this, SLOT(slotDoHousekeeping(int)));
connect( &delayedChildrenCleanupTimer, SIGNAL( timeout()),
SLOT( delayedChildrenCleanup()));
theOProcessController = this;
setupHandlers();
}
void OProcessController::setupHandlers()
{
if( handlerSet )
return;
struct sigaction act;
act.sa_handler=theSigCHLDHandler;
sigemptyset(&(act.sa_mask));
sigaddset(&(act.sa_mask), SIGCHLD);
// Make sure we don't block this signal. gdb tends to do that :-(
sigprocmask(SIG_UNBLOCK, &(act.sa_mask), 0);
act.sa_flags = SA_NOCLDSTOP;
// CC: take care of SunOS which automatically restarts interrupted system
// calls (and thus does not have SA_RESTART)
#ifdef SA_RESTART
act.sa_flags |= SA_RESTART;
#endif
sigaction( SIGCHLD, &act, &oldChildHandlerData );
act.sa_handler=SIG_IGN;
sigemptyset(&(act.sa_mask));
sigaddset(&(act.sa_mask), SIGPIPE);
act.sa_flags = 0;
sigaction( SIGPIPE, &act, 0L);
handlerSet = true;
}
void OProcessController::resetHandlers()
{
if( !handlerSet )
return;
sigaction( SIGCHLD, &oldChildHandlerData, 0 );
// there should be no problem with SIGPIPE staying SIG_IGN
handlerSet = false;
}
// block SIGCHLD handler, because it accesses processList
void OProcessController::addOProcess( OProcess* p )
{
sigset_t newset, oldset;
sigemptyset( &newset );
sigaddset( &newset, SIGCHLD );
sigprocmask( SIG_BLOCK, &newset, &oldset );
processList.append( p );
sigprocmask( SIG_SETMASK, &oldset, 0 );
}
void OProcessController::removeOProcess( OProcess* p )
{
sigset_t newset, oldset;
sigemptyset( &newset );
sigaddset( &newset, SIGCHLD );
sigprocmask( SIG_BLOCK, &newset, &oldset );
processList.remove( p );
sigprocmask( SIG_SETMASK, &oldset, 0 );
}
//using a struct which contains both the pid and the status makes it easier to write
//and read the data into the pipe
//especially this solves a problem which appeared on my box where slotDoHouseKeeping() received
//only 4 bytes (with some debug output around the write()'s it received all 8 bytes)
//don't know why this happened, but when writing all 8 bytes at once it works here, aleXXX
struct waitdata
{
pid_t pid;
int status;
};
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 @@
/* This file is part of the KDE libraries
Copyright (C) 1997 Christian Czezakte (e9025461@student.tuwien.ac.at)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
//
// KPROCESSCONTROLLER -- A helper class for KProcess
//
// version 0.3.1, Jan 8th 1997
//
// (C) Christian Czezatke
// e9025461@student.tuwien.ac.at
// Ported by Holger Freyther
//
#ifndef __KPROCCTRL_H__
#define __KPROCCTRL_H__
#include <qvaluelist.h>
#include <qtimer.h>
#include "oprocess.h"
-class OProcessControllerPrivate;
class QSocketNotifier;
+
+namespace Opie {
+namespace Core {
+namespace Private {
+class OProcessControllerPrivate;
+
/**
* @short Used internally by @ref OProcess
* @internal
* @author Christian Czezakte <e9025461@student.tuwien.ac.at>
*
* A class for internal use by OProcess only. -- Exactly one instance
* of this class is generated by the first instance of OProcess that is
* created (a pointer to it gets stored in @ref theOProcessController ).
*
* This class takes care of the actual (UN*X) signal handling.
*/
class OProcessController : public QObject
{
Q_OBJECT
public:
OProcessController();
~OProcessController();
//CC: WARNING! Destructor Not virtual (but you don't derive classes from this anyhow...)
public:
/**
* Only a single instance of this class is allowed at a time,
* and this static variable is used to track the one instance.
*/
static OProcessController *theOProcessController;
/**
* Automatically called upon SIGCHLD.
*
* Normally you do not need to do anything with this function but
* if your application needs to disable SIGCHLD for some time for
* reasons beyond your control, you should call this function afterwards
* to make sure that no SIGCHLDs where missed.
*/
static void theSigCHLDHandler(int signal);
// handler for sigchld
/**
* @internal
*/
static void setupHandlers();
/**
* @internal
*/
static void resetHandlers();
/**
* @internal
*/
void addOProcess( OProcess* );
/**
* @internal
*/
void removeOProcess( OProcess* );
public slots:
/**
* @internal
*/
void slotDoHousekeeping(int socket);
private slots:
void delayedChildrenCleanup();
private:
int fd[2];
QSocketNotifier *notifier;
static struct sigaction oldChildHandlerData;
static bool handlerSet;
QValueList<OProcess*> processList;
QTimer delayedChildrenCleanupTimer;
// Disallow assignment and copy-construction
OProcessController( const OProcessController& );
OProcessController& operator= ( const OProcessController& );
OProcessControllerPrivate *d;
};
+}
+}
+}
#endif
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
@@ -1,171 +1,176 @@
/*
                This file is part of the Opie Project
            Copyright (C) 2002-2004 Holger Freyther <zecke@handhelds.org>
and The Opie Team <opie-devel@handhelds.org>
=. Based on KProcess (C) 1997 Christian Czezatke (e9025461@student.tuwien.ac.at)
.=l.
         .>+-=
_;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
- .   .-<_>     .<> Foundation; either version 2 of the License,
   ._= =}       : or (at your option) any later version.
  .%`+i>       _;_.
  .i_,=:_.      -<s. This program is distributed in the hope that
   +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
  : ..    .:,     . . . without even the implied warranty of
  =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
_.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
:     =  ...= . :.=-
-.   .:....=;==+<; You should have received a copy of the GNU
-_. . .   )=.  = Library General Public License along with
  --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include "oprocctrl.h"
/* OPIE */
#include <opie2/oprocess.h>
/* QT */
#include <qapplication.h>
#include <qdir.h>
#include <qmap.h>
#include <qsocketnotifier.h>
#include <qtextstream.h>
/* STD */
#include <errno.h>
#include <fcntl.h>
#include <pwd.h>
#include <stdlib.h>
#include <signal.h>
#include <stdio.h>
#include <string.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/socket.h>
#include <unistd.h>
#ifdef HAVE_SYS_SELECT_H
#include <sys/select.h>
#endif
#ifdef HAVE_INITGROUPS
#include <grp.h>
#endif
+using namespace Opie::Core::Private;
+
+namespace Opie {
+namespace Core {
+namespace Private {
class OProcessPrivate
{
public:
OProcessPrivate() : useShell( false )
{ }
bool useShell;
QMap<QString, QString> env;
QString wd;
QCString shell;
};
-
+}
OProcess::OProcess( QObject *parent, const char *name )
: QObject( parent, name )
{
init ( );
}
OProcess::OProcess( const QString &arg0, QObject *parent, const char *name )
: QObject( parent, name )
{
init ( );
*this << arg0;
}
OProcess::OProcess( const QStringList &args, QObject *parent, const char *name )
: QObject( parent, name )
{
init ( );
*this << args;
}
void OProcess::init ( )
{
run_mode = NotifyOnExit;
runs = false;
pid_ = 0;
status = 0;
keepPrivs = false;
innot = 0;
outnot = 0;
errnot = 0;
communication = NoCommunication;
input_data = 0;
input_sent = 0;
input_total = 0;
d = 0;
if ( 0 == OProcessController::theOProcessController )
{
( void ) new OProcessController();
CHECK_PTR( OProcessController::theOProcessController );
}
OProcessController::theOProcessController->addOProcess( this );
out[ 0 ] = out[ 1 ] = -1;
in[ 0 ] = in[ 1 ] = -1;
err[ 0 ] = err[ 1 ] = -1;
}
void OProcess::setEnvironment( const QString &name, const QString &value )
{
if ( !d )
d = new OProcessPrivate;
d->env.insert( name, value );
}
void OProcess::setWorkingDirectory( const QString &dir )
{
if ( !d )
d = new OProcessPrivate;
d->wd = dir;
}
void OProcess::setupEnvironment()
{
if ( d )
{
QMap<QString, QString>::Iterator it;
for ( it = d->env.begin(); it != d->env.end(); ++it )
setenv( QFile::encodeName( it.key() ).data(),
QFile::encodeName( it.data() ).data(), 1 );
if ( !d->wd.isEmpty() )
chdir( QFile::encodeName( d->wd ).data() );
}
}
void OProcess::setRunPrivileged( bool keepPrivileges )
{
keepPrivs = keepPrivileges;
}
bool OProcess::runPrivileged() const
{
return keepPrivs;
}
OProcess::~OProcess()
{
// destroying the OProcess instance sends a SIGKILL to the
// child process (if it is running) after removing it from the
// list of valid processes (if the process is not started as
// "DontCare")
OProcessController::theOProcessController->removeOProcess( this );
// this must happen before we kill the child
// TODO: block the signal while removing the current process from the process list
@@ -848,96 +853,99 @@ void OProcess::commClose()
}
void OProcess::setUseShell( bool useShell, const char *shell )
{
if ( !d )
d = new OProcessPrivate;
d->useShell = useShell;
d->shell = shell;
if ( d->shell.isEmpty() )
d->shell = searchShell();
}
QString OProcess::quote( const QString &arg )
{
QString res = arg;
res.replace( QRegExp( QString::fromLatin1( "\'" ) ),
QString::fromLatin1( "'\"'\"'" ) );
res.prepend( '\'' );
res.append( '\'' );
return res;
}
QCString OProcess::searchShell()
{
QCString tmpShell = QCString( getenv( "SHELL" ) ).stripWhiteSpace();
if ( !isExecutable( tmpShell ) )
{
tmpShell = "/bin/sh";
}
return tmpShell;
}
bool OProcess::isExecutable( const QCString &filename )
{
struct stat fileinfo;
if ( filename.isEmpty() )
return false;
// CC: we've got a valid filename, now let's see whether we can execute that file
if ( -1 == stat( filename.data(), &fileinfo ) )
return false;
// CC: return false if the file does not exist
// CC: anyway, we cannot execute directories, block/character devices, fifos or sockets
if ( ( S_ISDIR( fileinfo.st_mode ) ) ||
( S_ISCHR( fileinfo.st_mode ) ) ||
( S_ISBLK( fileinfo.st_mode ) ) ||
#ifdef S_ISSOCK
// CC: SYSVR4 systems don't have that macro
( S_ISSOCK( fileinfo.st_mode ) ) ||
#endif
( S_ISFIFO( fileinfo.st_mode ) ) ||
( S_ISDIR( fileinfo.st_mode ) ) )
{
return false;
}
// CC: now check for permission to execute the file
if ( access( filename.data(), X_OK ) != 0 )
return false;
// CC: we've passed all the tests...
return true;
}
int OProcess::processPID( const QString& process )
{
QString line;
QDir d = QDir( "/proc" );
QStringList dirs = d.entryList( QDir::Dirs );
QStringList::Iterator it;
for ( it = dirs.begin(); it != dirs.end(); ++it )
{
//qDebug( "next entry: %s", (const char*) *it );
QFile file( "/proc/"+*it+"/cmdline" );
file.open( IO_ReadOnly );
if ( !file.isOpen() ) continue;
QTextStream t( &file );
line = t.readLine();
//qDebug( "cmdline = %s", (const char*) line );
if ( line.contains( process ) ) break; //FIXME: That may find also other process, if the name is not long enough ;)
}
if ( line.contains( process ) )
{
//qDebug( "found process id #%d", (*it).toInt() );
return (*it).toInt();
}
else
{
//qDebug( "process '%s' not found", (const char*) process );
return 0;
}
}
+
+}
+}
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,142 +1,148 @@
/*
                This file is part of the Opie Project
            Copyright (C) 2003-2004 Holger Freyther <zecke@handhelds.org>
Copyright (C) The Opie Team <opie-devel@handhelds.org>
=. Based on KProcess (C) 1997 Christian Czezatke (e9025461@student.tuwien.ac.at)
.=l.
         .>+-=
_;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
- .   .-<_>     .<> Foundation; either version 2 of the License,
   ._= =}       : or (at your option) any later version.
  .%`+i>       _;_.
  .i_,=:_.      -<s. This program is distributed in the hope that
   +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
  : ..    .:,     . . . without even the implied warranty of
  =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
_.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
:     =  ...= . :.=-
-.   .:....=;==+<; You should have received a copy of the GNU
-_. . .   )=.  = Library General Public License along with
  --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef OPROCESS_H
#define OPROCESS_H
/* QT */
#include <qcstring.h>
#include <qobject.h>
#include <qvaluelist.h>
/* STD */
#include <sys/types.h> // for pid_t
#include <sys/wait.h>
#include <signal.h>
#include <unistd.h>
class QSocketNotifier;
+
+namespace Opie {
+namespace Core {
+namespace Private {
+class OProcessController;
class OProcessPrivate;
+}
/**
* Child process invocation, monitoring and control.
*
* @sect General usage and features
*
*This class allows a KDE and OPIE application to start child processes without having
*to worry about UN*X signal handling issues and zombie process reaping.
*
*@see KProcIO
*
*Basically, this class distinguishes three different ways of running
*child processes:
*
*@li OProcess::DontCare -- The child process is invoked and both the child
*process and the parent process continue concurrently.
*
*Starting a DontCare child process means that the application is
*not interested in any notification to determine whether the
*child process has already exited or not.
*
*@li OProcess::NotifyOnExit -- The child process is invoked and both the
*child and the parent process run concurrently.
*
*When the child process exits, the OProcess instance
*corresponding to it emits the Qt signal @ref processExited().
*
*Since this signal is @em not emitted from within a UN*X
*signal handler, arbitrary function calls can be made.
*
*Be aware: When the OProcess objects gets destructed, the child
*process will be killed if it is still running!
*This means in particular, that you cannot use a OProcess on the stack
*with OProcess::NotifyOnExit.
*
*@li OProcess::Block -- The child process starts and the parent process
*is suspended until the child process exits. (@em Really not recommended
*for programs with a GUI.)
*
*OProcess also provides several functions for determining the exit status
*and the pid of the child process it represents.
*
*Furthermore it is possible to supply command-line arguments to the process
*in a clean fashion (no null -- terminated stringlists and such...)
*
*A small usage example:
*<pre>
*OProcess *proc = new OProcess;
*
**proc << "my_executable";
**proc << "These" << "are" << "the" << "command" << "line" << "args";
*QApplication::connect(proc, SIGNAL(processExited(OProcess *)),
* pointer_to_my_object, SLOT(my_objects_slot(OProcess *)));
*proc->start();
*</pre>
*
*This will start "my_executable" with the commandline arguments "These"...
*
*When the child process exits, the respective Qt signal will be emitted.
*
*@sect Communication with the child process
*
*OProcess supports communication with the child process through
*stdin/stdout/stderr.
*
*The following functions are provided for getting data from the child
*process or sending data to the child's stdin (For more information,
*have a look at the documentation of each function):
*
*@li bool @ref writeStdin(char *buffer, int buflen);
*@li -- Transmit data to the child process's stdin.
*
*@li bool @ref closeStdin();
*@li -- Closes the child process's stdin (which causes it to see an feof(stdin)).
*Returns false if you try to close stdin for a process that has been started
*without a communication channel to stdin.
*
*@li bool @ref closeStdout();
*@li -- Closes the child process's stdout.
*Returns false if you try to close stdout for a process that has been started
*without a communication channel to stdout.
*
*@li bool @ref closeStderr();
*@li -- Closes the child process's stderr.
*Returns false if you try to close stderr for a process that has been started
*without a communication channel to stderr.
*
*
*@sect QT signals:
*
*@li void @ref receivedStdout(OProcess *proc, char *buffer, int buflen);
*@li void @ref receivedStderr(OProcess *proc, char *buffer, int buflen);
*@li -- Indicates that new data has arrived from either the
*child process's stdout or stderr.
*
*@li void @ref wroteStdin(OProcess *proc);
@@ -304,192 +310,193 @@ public:
* the process has exited, it returns the process id of the last
* child process that was created by this instance of OProcess.
*
* Calling it before any child process has been started by this
* OProcess instance causes pid() to return 0.
**/
pid_t pid() const;
/**
* Suspend processing of data from stdout of the child process.
*/
void suspend();
/**
* Resume processing of data from stdout of the child process.
*/
void resume();
/**
* @return @p true if the process has already finished and has exited
* "voluntarily", ie: it has not been killed by a signal.
*
* Note that you should check @ref OProcess::exitStatus() to determine
* whether the process completed its task successful or not.
*/
bool normalExit() const;
/**
* Returns the exit status of the process.
*
* Please use
* @ref OProcess::normalExit() to check whether the process has exited
* cleanly (i.e., @ref OProcess::normalExit() returns @p true) before calling
* this function because if the process did not exit normally,
* it does not have a valid exit status.
*/
int exitStatus() const;
/**
* Transmit data to the child process's stdin.
*
* OProcess::writeStdin may return false in the following cases:
*
* @li The process is not currently running.
*
* @li Communication to stdin has not been requested in the @ref start() call.
*
* @li Transmission of data to the child process by a previous call to
* @ref writeStdin() is still in progress.
*
* Please note that the data is sent to the client asynchronously,
* so when this function returns, the data might not have been
* processed by the child process.
*
* If all the data has been sent to the client, the signal
* @ref wroteStdin() will be emitted.
*
* Please note that you must not free "buffer" or call @ref writeStdin()
* again until either a @ref wroteStdin() signal indicates that the
* data has been sent or a @ref processHasExited() signal shows that
* the child process is no longer alive...
**/
bool writeStdin( const char *buffer, int buflen );
void flushStdin();
/**
* This causes the stdin file descriptor of the child process to be
* closed indicating an "EOF" to the child.
*
* @return @p false if no communication to the process's stdin
* had been specified in the call to @ref start().
*/
bool closeStdin();
/**
* This causes the stdout file descriptor of the child process to be
* closed.
*
* @return @p false if no communication to the process's stdout
* had been specified in the call to @ref start().
*/
bool closeStdout();
/**
* This causes the stderr file descriptor of the child process to be
* closed.
*
* @return @p false if no communication to the process's stderr
* had been specified in the call to @ref start().
*/
bool closeStderr();
/**
* Lets you see what your arguments are for debugging.
+ * \todo make const
*/
const QValueList<QCString> &args()
{
return arguments;
}
/**
* Controls whether the started process should drop any
* setuid/segid privileges or whether it should keep them
*
* The default is @p false : drop privileges
*/
void setRunPrivileged( bool keepPrivileges );
/**
* Returns whether the started process will drop any
* setuid/segid privileges or whether it will keep them
*/
bool runPrivileged() const;
/**
* Modifies the environment of the process to be started.
* This function must be called before starting the process.
*/
void setEnvironment( const QString &name, const QString &value );
/**
* Changes the current working directory (CWD) of the process
* to be started.
* This function must be called before starting the process.
*/
void setWorkingDirectory( const QString &dir );
/**
* Specify whether to start the command via a shell or directly.
* The default is to start the command directly.
* If @p useShell is true @p shell will be used as shell, or
* if shell is empty, the standard shell is used.
* @p quote A flag indicating whether to quote the arguments.
*
* When using a shell, the caller should make sure that all filenames etc.
* are properly quoted when passed as argument.
* @see quote()
*/
void setUseShell( bool useShell, const char *shell = 0 );
/**
* This function can be used to quote an argument string such that
* the shell processes it properly. This is e. g. necessary for
* user-provided file names which may contain spaces or quotes.
* It also prevents expansion of wild cards and environment variables.
*/
static QString quote( const QString &arg );
/**
* Detaches OProcess from child process. All communication is closed.
* No exit notification is emitted any more for the child process.
* Deleting the OProcess will no longer kill the child process.
* Note that the current process remains the parent process of the
* child process.
*/
void detach();
/**
* @return the PID of @a process, or -1 if the process is not running
*/
static int processPID( const QString& process );
signals:
/**
* Emitted after the process has terminated when
* the process was run in the @p NotifyOnExit (==default option to
* @ref start()) or the @ref Block mode.
**/
void processExited( OProcess *proc );
/**
* Emitted, when output from the child process has
* been received on stdout.
*
* To actually get
* these signals, the respective communication link (stdout/stderr)
* has to be turned on in @ref start().
*
* @param buffer The data received.
* @param buflen The number of bytes that are available.
*
* You should copy the information contained in @p buffer to your private
* data structures before returning from this slot.
**/
void receivedStdout( OProcess *proc, char *buffer, int buflen );
/**
@@ -623,130 +630,132 @@ protected:
/**
* This function is called from "OProcess::start" right before a "fork" takes
* place. According to
* the "comm" parameter this function has to initialize the "in", "out" and
* "err" data member of OProcess.
*
* This function should return 0 if setting the needed communication channels
* was successful.
*
* The default implementation is to create UNIX STREAM sockets for the communication,
* but you could overload this function and establish a TCP/IP communication for
* network communication, for example.
*/
virtual int setupCommunication( Communication comm );
/**
* Called right after a (successful) fork on the parent side. This function
* will usually do some communications cleanup, like closing the reading end
* of the "stdin" communication channel.
*
* Furthermore, it must also create the QSocketNotifiers "innot", "outnot" and
* "errnot" and connect their Qt slots to the respective OProcess member functions.
*
* For a more detailed explanation, it is best to have a look at the default
* implementation of "setupCommunication" in kprocess.cpp.
*/
virtual int commSetupDoneP();
/**
* Called right after a (successful) fork, but before an "exec" on the child
* process' side. It usually just closes the unused communication ends of
* "in", "out" and "err" (like the writing end of the "in" communication
* channel.
*/
virtual int commSetupDoneC();
/**
* Immediately called after a process has exited. This function normally
* calls commClose to close all open communication channels to this
* process and emits the "processExited" signal (if the process was
* not running in the "DontCare" mode).
*/
virtual void processHasExited( int state );
/**
* Should clean up the communication links to the child after it has
* exited. Should be called from "processHasExited".
*/
virtual void commClose();
/**
* the socket descriptors for stdin/stdout/stderr.
*/
int out[ 2 ];
int in[ 2 ];
int err[ 2 ];
/**
* The socket notifiers for the above socket descriptors.
*/
QSocketNotifier *innot;
QSocketNotifier *outnot;
QSocketNotifier *errnot;
/**
* Lists the communication links that are activated for the child
* process. Should not be modified from derived classes.
*/
Communication communication;
/**
* Called by "slotChildOutput" this function copies data arriving from the
* child process's stdout to the respective buffer and emits the signal
* "@ref receivedStderr".
*/
int childOutput( int fdno );
/**
* Called by "slotChildOutput" this function copies data arriving from the
* child process's stdout to the respective buffer and emits the signal
* "@ref receivedStderr"
*/
int childError( int fdno );
// information about the data that has to be sent to the child:
const char *input_data; // the buffer holding the data
int input_sent; // # of bytes already transmitted
int input_total; // total length of input_data
/**
* @ref OProcessController is a friend of OProcess because it has to have
* access to various data members.
*/
- friend class OProcessController;
+ friend class Private::OProcessController;
private:
/**
* Searches for a valid shell.
* Here is the algorithm used for finding an executable shell:
*
* @li Try the executable pointed to by the "SHELL" environment
* variable with white spaces stripped off
*
* @li If your process runs with uid != euid or gid != egid, a shell
* not listed in /etc/shells will not used.
*
* @li If no valid shell could be found, "/bin/sh" is used as a last resort.
*/
QCString searchShell();
/**
* Used by @ref searchShell in order to find out whether the shell found
* is actually executable at all.
*/
bool isExecutable( const QCString &filename );
// Disallow assignment and copy-construction
OProcess( const OProcess& );
OProcess& operator= ( const OProcess& );
private:
void init ( );
- OProcessPrivate *d;
+ Private::OProcessPrivate *d;
};
+}
+}
#endif
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,145 +1,147 @@
// -*- Mode: C++; -*-
/*
This file is part of the Opie Project
Copyright (C) 2004 Rajko Albrecht <alwin@handhelds.org>
Copyright (C) The Opie Team <opie-devel@handhelds.org>
=.
.=l.
.>+-=
_;:, .> :=|. This program is free software; you can
.> <`_, > . <= redistribute it and/or modify it under
:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
.="- .-=="i, .._ License as published by the Free Software
- . .-<_> .<> Foundation; either version 2 of the License,
._= =} : or (at your option) any later version.
.%`+i> _;_.
.i_,=:_. -<s. This program is distributed in the hope that
+ . -:. = it will be useful, but WITHOUT ANY WARRANTY;
: .. .:, . . . without even the implied warranty of
=_ + =;=|` MERCHANTABILITY or FITNESS FOR A
_.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.= = ; Library General Public License for more
++= -. .` .: details.
: = ...= . :.=-
-. .:....=;==+<; You should have received a copy of the GNU
-_. . . )=. = Library General Public License along with
-- :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef _OSmartPointer_h
#define _OSmartPointer_h
/*!
* \file OSmartPointer.h
* \brief smart pointer and reference counter
* \author Rajko Albrecht
*
*/
namespace Opie {
+namespace Core {
//! simple reference counter class
class ORefCount {
protected:
//! reference count member
long m_RefCount;
public:
//! first reference must be added after "new" via Pointer()
ORefCount() : m_RefCount(0)
{}
virtual ~ORefCount() {}
//! add a reference
void Incr() {
++m_RefCount;
}
//! delete a reference
void Decr() {
--m_RefCount;
}
//! is it referenced
bool Shared() { return (m_RefCount > 0); }
};
//! reference counting wrapper class
template<class T> class OSmartPointer {
//! pointer to object
/*!
* this object must contain Incr(), Decr() and Shared()
* methode as public members. The best way is, that it will be a child
* class of RefCount
*/
T *ptr;
public:
//! standart constructor
OSmartPointer() { ptr = NULL; }
//! standart destructor
/*!
* release the reference, if it were the last reference, destroys
* ptr
*/
~OSmartPointer()
{
if (ptr){
ptr->Decr();
if (!ptr->Shared())
delete ptr;
}
}
//! construction
OSmartPointer(T* t) { if (ptr = t) ptr->Incr(); }
//! Pointer copy
OSmartPointer(const OSmartPointer<T>& p)
{ if (ptr = p.ptr) ptr->Incr(); }
//! pointer copy by assignment
OSmartPointer<T>& operator= (const OSmartPointer<T>& p)
{
// already same: nothing to do
if (ptr == p.ptr) return *this;
// decouple reference
if (ptr) { ptr->Decr(); if (!ptr->Shared()) delete ptr; }
// establish new reference
if (ptr = p.ptr) ptr->Incr();
return *this;
}
OSmartPointer<T>& operator= (T*p)
{
if (ptr==p)return *this;
if (ptr) {
ptr->Decr();
if (!ptr->Shared()) delete ptr;
}
if (ptr=p) ptr->Incr();
return *this;
}
//! cast to conventional pointer
operator T* () const { return ptr; }
//! deref: fails for NULL pointer
T& operator* () {return *ptr; }
//! deref: fails for NULL pointer
const T& operator* ()const {return *ptr; }
//! deref with method call
T* operator-> () {return ptr; }
//! deref with const method call
const T* operator-> ()const {return ptr; }
//! supports "if (pointer)"
operator bool () const { return (ptr != NULL); }
//! "if (pointer)" as non const
operator bool () { return ptr != NULL;}
//! support if (!pointer)"
bool operator! () const { return (ptr == NULL); }
//! support if (!pointer)" as non const
bool operator! () { return (ptr == NULL); }
};
}
+}
#endif
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,85 +1,87 @@
/*
                This file is part of the Opie Project
              Copyright (C) 2004 Andreas 'ar' Richter <ar@oszine.de>
=.
.=l.
           .>+-=
 _;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include <opie2/ostorageinfo.h>
+using namespace Opie::Core;
+
OStorageInfo::OStorageInfo( QObject *parent )
: StorageInfo( parent )
{
}
OStorageInfo::~OStorageInfo()
{
}
QString OStorageInfo::cfPath()const
{
QString r = "";
for (QListIterator<FileSystem> i( fileSystems() ); i.current(); ++i)
{
if ( (*i)->disk().left( 8 ) == "/dev/hda" )
{
r = (*i)->path();
break;
}
}
return r;
}
QString OStorageInfo::sdPath()const
{
QString r = "";
for (QListIterator<FileSystem> i( fileSystems() ); i.current(); ++i)
{
if ( (*i)->disk().left( 9 ) == "/dev/mmcd" )
{
r = (*i)->path();
break;
}
}
return r;
}
QString OStorageInfo::mmcPath()const
{
QString r = "";
for (QListIterator<FileSystem> i( fileSystems() ); i.current(); ++i)
{
if ( (*i)->disk().left( 14 ) == "/dev/mmc/part1" )
{
r = (*i)->path();
break;
}
}
return r;
}
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 @@
/*
                This file is part of the Opie Project
              Copyright (C) 2004 Andreas 'ar' Richter <ar@oszine.de>
=.
.=l.
           .>+-=
 _;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef OSTORAGE_H
#define OSTORAGE_H
#include <qpe/storage.h>
+namespace Opie {
+namespace Core {
+
class OStorageInfo : public StorageInfo
{
Q_OBJECT
public:
OStorageInfo( QObject *parent=0 );
~OStorageInfo();
/**
* @returns the mount path of the CF (Compact Flash) card
*
**/
QString cfPath() const;
/**
* @returns the mount path of the SD (Secure Digital) card
*
**/
QString sdPath() const;
/**
* @returns the mount path of the MMC (MultiMedia) card
*
**/
QString mmcPath() const;
+private:
+ class Private;
+ Private *d;
};
+}
+}
#endif // OSTORAGE_H
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 @@
* something like Capabilities of a Driver
- ROWID
- How to declare INTEGER PRIMARY KEY
- Abstract from implementation of some dbs
- provides( Type::What )
+ - emit signals directly on arriving of data
* OSQLDriver DriverVersion - DatabaseVersion
* Better OSQLQueries
- 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 @@
TEMPLATE = lib
CONFIG += qt warn_on debug
DESTDIR = $(OPIEDIR)/lib
HEADERS = osqlbackend.h \
osqldriver.h \
osqlerror.h \
osqlmanager.h \
osqlquery.h \
osqlresult.h \
osqltable.h \
osqlbackendmanager.h \
osqlitedriver.h
SOURCES = osqlbackend.cpp \
osqldriver.cpp \
osqlerror.cpp \
osqlmanager.cpp \
osqlquery.cpp \
osqlresult.cpp \
osqltable.cpp \
osqlbackendmanager.cpp \
osqlitedriver.cpp
INTERFACES =
TARGET = opiedb2
-VERSION = 1.8.2
+VERSION = 1.9.0
INCLUDEPATH = $(OPIEDIR)/include
DEPENDPATH = $(OPIEDIR)/include
LIBS += -lopiecore2 -lqpe -lsqlite
!contains( platform, x11 ) {
include ( $(OPIEDIR)/include.pro )
}
contains( platform, x11 ) {
LIBS += -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib
}
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,73 +1,75 @@
#include "osqlbackend.h"
+using namespace Opie::DB;
+
OSQLBackEnd::OSQLBackEnd( const QString& name,
const QString& vendor,
const QString& license,
const QCString& lib )
: m_name( name), m_vendor( vendor), m_license( license ), m_lib( lib )
{
m_default = false;
m_pref = -1;
}
OSQLBackEnd::OSQLBackEnd( const OSQLBackEnd& back ) {
(*this) = back;
}
OSQLBackEnd::~OSQLBackEnd() {
}
bool OSQLBackEnd::operator==( const OSQLBackEnd& other ) {
if ( m_pref != other.m_pref ) return false;
if ( m_default != other.m_default ) return false;
if ( m_name != other.m_name ) return false;
if ( m_vendor != other.m_vendor ) return false;
if ( m_license != other.m_license ) return false;
if ( m_lib != other.m_lib ) return false;
return true;
}
OSQLBackEnd &OSQLBackEnd::operator=(const OSQLBackEnd& back ) {
m_name = back.m_name;
m_vendor = back.m_vendor;
m_license = back.m_license;
m_lib = back.m_lib;
m_pref = back.m_pref;
m_default = back.m_default;
return *this;
}
QString OSQLBackEnd::name() const {
return m_name;
}
QString OSQLBackEnd::vendor() const {
return m_vendor;
}
QString OSQLBackEnd::license() const {
return m_license;
}
QCString OSQLBackEnd::library() const {
return m_lib;
}
bool OSQLBackEnd::isDefault()const {
return m_default;
}
int OSQLBackEnd::preference()const {
return m_pref;
}
void OSQLBackEnd::setName( const QString& name ) {
m_name = name;
}
void OSQLBackEnd::setVendor( const QString& vendor ) {
m_vendor = vendor;
}
void OSQLBackEnd::setLicense( const QString & license ) {
m_license = license;
}
void OSQLBackEnd::setLibrary( const QCString& lib ) {
m_lib = lib;
}
void OSQLBackEnd::setDefault( bool def) {
m_default = def;
}
void OSQLBackEnd::setPreference( int pref ) {
m_pref = pref;
}
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 @@
#ifndef OSQL_BACKEND_H
#define OSQL_BACKEND_H
#include <qcstring.h>
#include <qstring.h>
#include <qvaluelist.h>
+
+namespace Opie {
+namespace DB {
/**
* OSQLBackEnd represents an available backend
* to the Opie Database Service
* It's used to easily extend OSQL services by
* 3rd party plugins.
* It's used to show
*/
class OSQLBackEnd /*: public QShared */ {
public:
typedef QValueList<OSQLBackEnd> ValueList;
/**
* A basic c'tor
* @param name the user visible name of the service
* @param vendor the vendor of the service
* @param license the license of the service
* @param library what is the name of lib if builtin it's builtin
*/
OSQLBackEnd( const QString& name = QString::null,
const QString& vendor = QString::null,
const QString& license = QString::null,
const QCString& library = QCString() );
OSQLBackEnd( const OSQLBackEnd& );
OSQLBackEnd &operator=( const OSQLBackEnd& );
bool operator==(const OSQLBackEnd& );
~OSQLBackEnd();
/** @return the name */
QString name()const;
/** @return the vendor */
QString vendor()const;
/** @return the license */
QString license()const;
/** @return the name of the library */
QCString library() const;
bool isDefault()const;
int preference()const;
/** @param name the name to set */
void setName( const QString& name );
/** @param vendor the vendor to set */
void setVendor( const QString& vendor );
/** @param license the license applied */
void setLicense( const QString& license );
/** @param the lib to set */
void setLibrary( const QCString& lib );
void setDefault( bool );
void setPreference( int );
private:
QString m_name;
QString m_vendor;
QString m_license;
QCString m_lib;
bool m_default :1;
int m_pref;
+ class Private;
+ Private *d;
};
+}
+}
+
#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,98 +1,106 @@
#include <qdir.h>
#include <qmap.h>
#include "osqlbackendmanager.h"
+/**
+ * \todo FIXME CONFIG!!!
+ */
+
namespace {
class Config {
typedef QMap<QString, QString> List;
public:
Config( const QString& fileName );
/**
* Quite simple layout in nature
* BeginFile
* Key = Value
*/
bool load();
QString value( const QString& key );
private:
List m_list;
QString m_fileName;
};
Config::Config( const QString& fileName )
: m_fileName( fileName ) {
}
bool Config::load() {
if (!QFile::exists( m_fileName ) )
return false;
QFile file( m_fileName );
if (!file.open(IO_ReadOnly ) )
return false;
QStringList list = QStringList::split( '\n', file.readAll() );
QStringList::Iterator it;
QString line;
for (it = list.begin(); it != list.end(); ++it ) {
line = (*it).stripWhiteSpace();
qWarning("Anonymous::Config:" + line );
QStringList test = QStringList::split(' ', line );
m_list.insert( test[0], test[2] );
}
return true;
}
QString Config::value( const QString& key ) {
return m_list[key];
}
};
+
+
+using namespace Opie::DB;
+
OSQLBackEndManager::OSQLBackEndManager( const QStringList& path )
:m_path( path )
{
}
OSQLBackEndManager::~OSQLBackEndManager() {
}
/**
* scan dirs
*/
OSQLBackEnd::ValueList OSQLBackEndManager::scan() {
OSQLBackEnd::ValueList list;
if (!m_path.isEmpty() ) {
QStringList::Iterator it;
for ( it = m_path.begin(); it != m_path.end(); ++it ) {
list += scanDir( (*it) );
}
}
return list;
}
/**
* scan a specified dir for *.osql
*/
OSQLBackEnd::ValueList OSQLBackEndManager::scanDir( const QString& dirName ) {
OSQLBackEnd::ValueList list;
QDir dir( dirName );
if (dir.exists() ) {
QStringList files = dir.entryList( "*.osql" );
QStringList::Iterator it;
for ( it = files.begin(); it != files.end(); ++it ) {
list.append( file2backend( (*it) ) );
}
}
return list;
}
/**
* read a config file and convert it to a OSQLBackEnd
*/
OSQLBackEnd OSQLBackEndManager::file2backend( const QString& file ) {
OSQLBackEnd end;
qWarning("fileName: " + file );
Config cfg( file );
if (cfg.load() ) {
end.setName( cfg.value( "Name") );
end.setVendor( cfg.value("Vendor") );
end.setLicense( cfg.value("License") );
end.setLibrary( cfg.value("Library").local8Bit() );
end.setDefault( cfg.value("Default").toInt() );
end.setPreference( cfg.value("Preference").toInt() );
}
return end;
}
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 @@
#ifndef OSQL_BACKEND_MANAGER_H
#define OSQL_BACKEND_MANAGER_H
#include <qstringlist.h>
#include "osqlbackend.h"
+namespace Opie {
+namespace DB {
+
class OSQLBackEndManager {
public:
OSQLBackEndManager(const QStringList& path );
~OSQLBackEndManager();
OSQLBackEnd::ValueList scan();
private:
OSQLBackEnd::ValueList scanDir( const QString& dir );
OSQLBackEnd file2backend( const QString& file );
class OSQLBackEndManagerPrivate;
OSQLBackEndManagerPrivate* d;
QStringList m_path;
};
+}
+}
+
#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 @@
#include <qpe/qlibrary.h>
#include "osqldriver.h"
+using namespace Opie::DB;
+
OSQLDriver::OSQLDriver( QLibrary* lib )
: QObject(), m_lib(lib) {
}
OSQLDriver::~OSQLDriver() {
delete m_lib;
}
bool OSQLDriver::sync() {
return true;
}
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 @@
#ifndef OSQL_DRIVER_H
#define OSQL_DRIVER_H
#include <qobject.h>
#include <qstring.h>
#include "osqltable.h"
class QLibrary;
+
+namespace Opie {
+namespace DB {
+
class OSQLResult;
class OSQLQuery;
class OSQLError;
/**
* A OSQLDriver implements the communication with
* a database.
* After you queried and loaded a driver you can
* set some informations and finally try to open
* the database
*
*/
class OSQLDriver : public QObject{
Q_OBJECT
public:
enum Capabilities { RowID=0 };
/**
* OSQLDriver constructor. It takes the QLibrary
* as parent.
*
*/
OSQLDriver( QLibrary* lib=0 );
virtual ~OSQLDriver();
/**
* Id returns the identifier of the OSQLDriver
*/
virtual QString id()const = 0;
/**
* set the UserName to the database
*/
virtual void setUserName( const QString& ) = 0;
/**
* set the PassWord to the database
*/
virtual void setPassword( const QString& )= 0;
/**
* set the Url
*/
virtual void setUrl( const QString& ) = 0;
/**
* setOptions
*/
virtual void setOptions( const QStringList& ) = 0;
/**
* tries to open a connection to the database
*/
virtual bool open() = 0;
virtual bool close() = 0;
virtual OSQLError lastError() = 0;
/**
* Query the Database with a OSQLQuery
* OSQLResult holds the result
*/
virtual OSQLResult query( OSQLQuery* ) = 0;
/**
* Get a list of tables
*/
virtual OSQLTable::ValueList tables() const = 0l;
virtual bool sync();
private:
QLibrary* m_lib;
class OSQLDriverPrivate;
OSQLDriverPrivate *d;
};
+}
+}
+
#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 @@
#include "osqlerror.h"
+using namespace Opie::DB;
+
OSQLError::OSQLError( const QString& driverText,
const QString& driverDatabaseText,
int type, int subType )
: m_drvText( driverText ), m_drvDBText( driverDatabaseText ),
m_type( type ), m_number( subType )
{
}
OSQLError::~OSQLError() {
}
QString OSQLError::driverText()const {
return m_drvText;
}
QString OSQLError::databaseText()const {
return m_drvDBText;
}
int OSQLError::type()const {
return m_type;
}
int OSQLError::subNumber()const {
return m_number;
}
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 @@
#ifndef OSQL_ERROR_H
#define OSQL_ERROR_H
#include <qstring.h>
#include <qvaluelist.h>
+
+namespace Opie {
+namespace DB {
/**
* OSQLError is the base class of all errors
*/
class OSQLError {
public:
typedef QValueList<OSQLError> ValueList;
enum Type { None = 0, // NoError
Internal, // Internal Error in OSQL
Unknown, // Unknown Error
Transaction, // Transaction Error
Statement, // Wrong Statement
Connection, // Connection Error( lost )
Driver // Driver Specefic error
};
enum DriverError {
DriverInternal=0, // internal DriverError
Permission, // Permission Problem
Abort, // Abort of the SQL
Busy, // Busy Error
Locked, // Locked
NoMem, // No Memory
ReadOnly, // Database is read only
Interrupt, // Interrupt
IOErr, // IO Error
Corrupt, // Database Corruption
NotFound, // Table not Found
Full, // Full
CantOpen, // Can not open Table/Database
Protocol, // internal protocol error
Schema, // schema changed
TooBig, // Data too big
Mismatch, // Type mismatch
Misuse // misuse
};
OSQLError( const QString& driverText = QString::null,
const QString& driverDatabaseText = QString::null,
int type = None, int subNumber = -1 );
~OSQLError();
QString driverText()const;
QString databaseText()const;
int type()const;
int subNumber()const;
private:
QString m_drvText;
QString m_drvDBText;
int m_type;
int m_number;
class OSQLErrorPrivate;
OSQLErrorPrivate* d;
};
+}
+}
#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,188 +1,191 @@
/*
                This file is part of the Opie Project
=.
.=l.
           .>+-=
 _;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include "osqlquery.h"
#include "osqlitedriver.h"
#include <opie2/odebug.h>
#include <stdlib.h>
// fromLocal8Bit() does not work as expected. Thus it
// is replaced by fromLatin1() (eilers)
#define __BUGGY_LOCAL8BIT_
+using namespace Opie::DB;
+using namespace Opie::DB::Private;
+
namespace {
struct Query {
OSQLError::ValueList errors;
OSQLResultItem::ValueList items;
OSQLiteDriver *driver;
};
}
OSQLiteDriver::OSQLiteDriver( QLibrary *lib )
: OSQLDriver( lib )
{
m_sqlite = 0l;
}
OSQLiteDriver::~OSQLiteDriver() {
close();
}
QString OSQLiteDriver::id()const {
return QString::fromLatin1("SQLite");
}
void OSQLiteDriver::setUserName( const QString& ) {}
void OSQLiteDriver::setPassword( const QString& ) {}
void OSQLiteDriver::setUrl( const QString& url ) {
m_url = url;
}
void OSQLiteDriver::setOptions( const QStringList& ) {
}
/*
* try to open a db specified via setUrl
* and options
*/
bool OSQLiteDriver::open() {
char *error;
- odebug << "OSQLiteDriver::open: about to open" << oendl;
+ qDebug("OSQLiteDriver::open: about to open");
m_sqlite = sqlite_open(m_url.local8Bit(),
0,
&error );
/* failed to open */
if (m_sqlite == 0l ) {
// FIXME set the last error
- owarn << "OSQLiteDriver::open: " << error << oendl;
+ qWarning("OSQLiteDriver::open: %s", error );
free( error );
return false;
}
return true;
}
/* close the db
* sqlite closes them without
* telling failure or success
*/
bool OSQLiteDriver::close() {
if (m_sqlite )
sqlite_close( m_sqlite ), m_sqlite=0l;
return true;
}
/* Query */
OSQLResult OSQLiteDriver::query( OSQLQuery* qu) {
if ( !m_sqlite ) {
// FIXME set error code
OSQLResult result( OSQLResult::Failure );
return result;
}
Query query;
query.driver = this;
char *err;
/* SQLITE_OK 0 if return code > 0 == failure */
if ( sqlite_exec(m_sqlite, qu->query(),&call_back, &query, &err) > 0 ) {
- owarn << "OSQLiteDriver::query: Error while executing" << oendl;
+ qWarning("OSQLiteDriver::query: Error while executing");
free(err );
// FixMe Errors
}
OSQLResult result(OSQLResult::Success,
query.items,
query.errors );
return result;
}
OSQLTable::ValueList OSQLiteDriver::tables() const {
}
OSQLError OSQLiteDriver::lastError() {
OSQLError error;
return error;
};
/* handle a callback add the row to the global
* OSQLResultItem
*/
int OSQLiteDriver::handleCallBack( int, char**, char** ) {
return 0;
}
/* callback_handler add the values to the list*/
int OSQLiteDriver::call_back( void* voi, int argc,
char** argv, char** columns) {
Query* qu = (Query*)voi;
//copy them over to a OSQLResultItem
QMap<QString, QString> tableString;
QMap<int, QString> tableInt;
for (int i = 0; i < argc; i++ ) {
#ifdef __BUGGY_LOCAL8BIT_
tableInt.insert( i, QString::fromLatin1( argv[i] ) );
tableString.insert( QString::fromLatin1( columns[i] ),
QString::fromLatin1( argv[i] ) );
#else
tableInt.insert( i, QString::fromLocal8Bit( argv[i] ) );
tableString.insert( QString::fromLocal8Bit( columns[i] ),
QString::fromLocal8Bit( argv[i] ) );
#endif
}
OSQLResultItem item( tableString, tableInt );
qu->items.append( item );
return ((Query*)voi)->driver->handleCallBack( argc,
argv,
columns );
}
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 @@
#ifndef OSQL_LITE_DRIVER_H
#define OSQL_LITE_DRIVER_H
#include <sqlite.h>
#include "osqldriver.h"
#include "osqlerror.h"
#include "osqlresult.h"
+namespace Opie {
+namespace DB {
+namespace Private {
+
class OSQLiteDriver : public OSQLDriver {
Q_OBJECT
public:
OSQLiteDriver( QLibrary *lib = 0l );
~OSQLiteDriver();
QString id()const;
void setUserName( const QString& );
void setPassword( const QString& );
void setUrl( const QString& url );
void setOptions( const QStringList& );
bool open();
bool close();
OSQLError lastError();
OSQLResult query( OSQLQuery* );
OSQLTable::ValueList tables()const;
private:
OSQLError m_lastE;
OSQLResult m_result;
OSQLResultItem m_items;
int handleCallBack( int, char**, char** );
static int call_back( void*, int, char**, char** );
QString m_url;
sqlite *m_sqlite;
};
+}
+}
+}
+
#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 @@
#include <stdlib.h>
#include "osqlmanager.h"
#include "osqlbackendmanager.h"
#include "osqlitedriver.h"
+using namespace Opie::DB;
+
OSQLManager::OSQLManager() {
}
OSQLBackEnd::ValueList OSQLManager::queryBackEnd() {
m_list.clear();
QString opie = QString::fromLatin1( getenv("OPIEDIR") );
QString qpe = QString::fromLatin1( getenv("QPEDIR") );
if ( !m_path.contains(opie) && !opie.isEmpty() )
m_path << opie;
if ( !m_path.contains(qpe) && !qpe.isEmpty() )
m_path << qpe;
OSQLBackEndManager mng( m_path );
m_list = mng.scan();
m_list += builtIn();
return m_list;
}
/*
* loading dso's is currently not enabled due problems with QLibrary
* beeing in libqpe and not libqte
*/
OSQLDriver* OSQLManager::load( const QString& name ) {
OSQLDriver* driver = 0l;
if ( name == "SQLite" ) {
- driver = new OSQLiteDriver();
+ driver = new Opie::DB::Private::OSQLiteDriver;
}
return driver;
}
/*
* same as above
*/
OSQLDriver* OSQLManager::load( const OSQLBackEnd& end) {
OSQLDriver *driver = 0l;
if ( end.library() == "builtin" &&
end.name() == "SQLite" )
- driver = new OSQLiteDriver();
+ driver = new Opie::DB::Private::OSQLiteDriver;
return driver;
}
/*
* let's find the a default with the highes preference
*/
OSQLDriver* OSQLManager::standard() {
OSQLDriver* driver =0l;
if ( m_list.isEmpty() ) queryBackEnd();
OSQLBackEnd::ValueList::Iterator it;
OSQLBackEnd back;
for ( it = m_list.begin(); it != m_list.end(); ++it ) {
if ( (*it).isDefault() &&
back.preference() < (*it).preference() ) {
back = (*it);
}
}
driver = load( back );
return driver;
}
void OSQLManager::registerPath( const QString& path ) {
m_path << path;
}
bool OSQLManager::unregisterPath( const QString& path ) {
m_path.remove( path );
return true;
}
OSQLBackEnd::ValueList OSQLManager::builtIn()const {
OSQLBackEnd::ValueList list;
// create the OSQLiteBackend
OSQLBackEnd back("SQLite","Opie e.V.","GPL", "builtin" );
back.setDefault( true );
back.setPreference( 50 );
list.append( back );
return list;
}
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 @@
#ifndef OSQL_MANAGER_H
#define OSQL_MANAGER_H
#include <qobject.h>
#include <qstringlist.h>
#include "osqlbackend.h"
+namespace Opie {
+namespace DB {
/**
* OSQLManager is responsible for loading
* and unloading, querying different OSQL
* services
* Load a OSQLDriver and delete it yourself
*
*/
class OSQLDriver;
class OSQLManager : public QObject {
Q_OBJECT
public:
/**
* Empty c'tor
*/
OSQLManager();
/**
* Query the Manager for different backends
*/
OSQLBackEnd::ValueList queryBackEnd();
/**
* Load a backend with it's name from param name
*/
OSQLDriver* load( const QString& name );
/**
* Load a OSQLDevice from const reference of OSQLBackEnd
*/
OSQLDriver* load( const OSQLBackEnd& );
/**
* loads the Opie standard backend
*/
OSQLDriver *standard();
/**
* register path to the search path list
* When querying for services we scan all the
* registered path for backends
*/
void registerPath( const QString& path );
/**
* unregisterPath from the search path list
*/
bool unregisterPath( const QString& path );
private:
OSQLBackEnd::ValueList builtIn()const;
OSQLBackEnd::ValueList m_list;
QStringList m_path;
+ class Private;
+ Private *d;
};
+}
+}
#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 @@
#include "osqlquery.h"
+using namespace Opie::DB;
+
OSQLQuery::OSQLQuery() {
}
OSQLQuery::~OSQLQuery() {
}
OSQLRawQuery::OSQLRawQuery(const QString& query)
: OSQLQuery(), m_query( query ) {
}
OSQLRawQuery::~OSQLRawQuery() {
}
QString OSQLRawQuery::query()const {
return m_query;
}
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 @@
#ifndef OSQL_QUERY_H
#define OSQL_QUERY_H
#include <qmap.h>
#include <qvaluelist.h>
#include <qstring.h>
+namespace Opie {
+namespace DB {
+
/** I'm not happy with them
class OSQLQueryOrder {
public:
typedef QValueList<OSQLQueryOrder> ValueList;
OSQLQueryOrder(const QString& table = QString::null );
OSQLQueryOrder( const OSQLQueryOrder& );
~OSQLQueryOrder();
void setOrderFields( const QStringList& list );
void setValue( const QString& fieldName, const QString& Value );
void setValues( const QMap<QString, QString>& );
QMap<QString, QString> orders() const;
QString orderStatement()const;
OSQLQueryOrder &operator=(const OSQLQueryOrder& );
private:
QMap<QString, QString> m_fields;
class OSQLQueryOrderPrivate;
OSQLQueryOrderPrivate* d;
};
class OSQLWhere {
public:
typedef QValueList<OSQLWhere> ValueList;
enum Vergleiche { Equal = 0, Like, Greater, GreaterEqual,
Smaller, SmallerEqual };
OSQLWhere(const QString& table = QString::null );
~OSQLWhere();
void setExpression(const QString& key, enum Vergleiche, const QString& );
QString statement()const;
private:
int m_vergleich;
const QString& m_left;
const QString& m_right;
};
*/
class OSQLQuery {
public:
OSQLQuery();
virtual ~OSQLQuery();
virtual QString query()const = 0;
+private:
+ class Private;
+ Private *d;
};
class OSQLRawQuery : public OSQLQuery {
public:
OSQLRawQuery( const QString& query );
~OSQLRawQuery();
QString query() const;
private:
class OSQLRawQueryPrivate;
OSQLRawQueryPrivate* d;
QString m_query;
};
/* I'm not happy with them again
class OSQLSelectQuery : public OSQLQuery {
public:
OSQLSelectQuery();
~OSQLSelectQuery();
void setTables( const QStringList& allTablesToQuery );
void setValues( const QString& table, const QStringList& columns );
void setOrder( const OSQLSelectQuery& );
void setOrderList( const OSQLQueryOrder::ValueList& );
void setWhereList( const OSQLWhere& );
void setWhereList( const OSQLWhere::ValueList& );
QString query()const;
private:
QStringList m_tables;
QMap<QString, QStringList> m_values;
OSQLQueryOrder::ValueList m_order;
OSQLWhere::ValueList m_where;
class OSQLSelectQueryPrivate;
OSQLSelectQueryPrivate* d;
};
class OSQLInsertQuery : public OSQLQuery {
public:
OSQLInsertQuery(const QString& table);
~OSQLInsertQuery();
void setInserFields( const QStringList& );
void setValue( const QString& field, const QString& value );
void setValues(const QMap<QString, QString>& );
QString query()const;
private:
QString m_table;
QStringList m_fields;
QMap<QString, QString> m_values;
};
class OSQLDeleteQuery : public OSQLQuery {
public:
OSQLDeleteQuery(const QString& table);
~OSQLDeleteQuery();
void setWhere( const OSQLWhere& );
void setWheres( const OSQLWhere::ValueList& );
QString query()const;
private:
QString m_table;
OSQLWhere::ValueList m_where;
};
class OSQLUpdateQuery : public OSQLQuery {
public:
OSQLUpdateQuery( const QString& table );
~OSQLUpdateQuery();
void setWhere( const OSQLWhere& );
void setWheres( const OSQLWhere::ValueList& );
*/
/* replaces all previous set Values */
/*
void setValue( const QString& field, const QString& value );
void setValue( const QMap<QString, QString> &fields );
QString query() const;
};
*/
+}
+}
#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,99 +1,101 @@
#include "osqlresult.h"
+using namespace Opie::DB;
+
OSQLResultItem::OSQLResultItem( const TableString& string,
const TableInt& Int)
: m_string( string ), m_int( Int )
{
}
OSQLResultItem::~OSQLResultItem() {
}
OSQLResultItem::OSQLResultItem( const OSQLResultItem& item) {
*this = item;
}
OSQLResultItem &OSQLResultItem::operator=( const OSQLResultItem& other) {
m_string = other.m_string;
m_int = other.m_int;
return *this;
}
OSQLResultItem::TableString OSQLResultItem::tableString()const{
return m_string;
}
OSQLResultItem::TableInt OSQLResultItem::tableInt()const {
return m_int;
}
QString OSQLResultItem::data( const QString& columnName, bool *ok ) {
TableString::Iterator it = m_string.find( columnName );
/* if found */
if ( it != m_string.end() ) {
if ( ok ) *ok = true;
return it.data();
}else{
if ( ok ) *ok = false;
return QString::null;
}
}
QString OSQLResultItem::data( int column, bool *ok ) {
TableInt::Iterator it = m_int.find( column );
/* if found */
if ( it != m_int.end() ) {
if ( ok ) *ok = true;
return it.data();
}else{
if ( ok ) *ok = false;
return QString::null;
}
}
/*
* DateFormat is 'YYYY-MM-DD'
*/
QDate OSQLResultItem::dataToDate( const QString& column, bool *ok ) {
QDate date = QDate::currentDate();
QString str = data( column, ok );
if (!str.isEmpty() ) {
;// convert
}
return date;
}
QDate OSQLResultItem::dataToDate( int column, bool *ok ) {
QDate date = QDate::currentDate();
QString str = data( column, ok );
if (!str.isEmpty() ) {
;// convert
}
return date;
}
QDateTime OSQLResultItem::dataToDateTime( const QString& column, bool *ok ) {
QDateTime time = QDateTime::currentDateTime();
return time;
}
QDateTime OSQLResultItem::dataToDateTime( int column, bool *ok ) {
QDateTime time = QDateTime::currentDateTime();
return time;
}
OSQLResult::OSQLResult( enum State state,
const OSQLResultItem::ValueList& list,
const OSQLError::ValueList& error )
: m_state( state ), m_list( list ), m_error( error )
{
}
OSQLResult::~OSQLResult() {
}
OSQLResult::State OSQLResult::state()const {
return m_state;
}
void OSQLResult::setState( OSQLResult::State state ) {
m_state = state;
}
OSQLError::ValueList OSQLResult::errors()const {
return m_error;
}
void OSQLResult::setErrors( const OSQLError::ValueList& err ) {
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,112 +1,120 @@
#ifndef OSQL_RESULT_H
#define OSQL_RESULT_H
#include <qdatetime.h>
#include <qmap.h>
#include <qvaluelist.h>
#include "osqlerror.h"
+
+namespace Opie {
+namespace DB {
+
/**
* ResultItem represents one row of the resulting answer
*/
class OSQLResultItem {
public:
typedef QValueList<OSQLResultItem> ValueList;
/**
* TableString is used to establish the relations
* between the column name and the real item
*/
typedef QMap<QString, QString> TableString;
/**
* TableInt is used to establish a relation between a
* position of a column and the row value
*/
typedef QMap<int, QString> TableInt;
/**
* Default c'tor. It has a TableString and a TableInt
*/
OSQLResultItem(const TableString& = TableString(),
const TableInt& = TableInt() );
OSQLResultItem( const OSQLResultItem& );
~OSQLResultItem();
OSQLResultItem &operator=( const OSQLResultItem& );
/**
* returns the TableString
*/
TableString tableString()const;
/**
* returns the TableInt
*/
TableInt tableInt() const;
/**
* retrieves the Data from columnName
*
*/
QString data( const QString& columnName, bool *ok = 0);
/**
* QString for column number
*/
QString data(int columnNumber, bool *ok = 0);
/**
* Date conversion from columnName
*/
QDate dataToDate( const QString& columnName, bool *ok = 0 );
/**
* Date conversion from column-number
*/
QDate dataToDate( int columnNumber, bool *ok = 0 );
QDateTime dataToDateTime( const QString& columName, bool *ok = 0 );
QDateTime dataToDateTime( int columnNumber, bool *ok = 0 );
private:
TableString m_string;
TableInt m_int;
};
/**
* the OSQLResult
* either a SQL statement failed or succeeded
*/
class OSQLResult {
public:
/** The State of a Result */
enum State{ Success = 0, Failure,Undefined };
/**
* default c'tor
* @param state The State of the Result
* @param r ResultItems
* @prarm errors the Errors a OSQLResult created
*/
OSQLResult( enum State state = Undefined,
const OSQLResultItem::ValueList& r= OSQLResultItem::ValueList(),
const OSQLError::ValueList& errors = OSQLError::ValueList() );
~OSQLResult();
State state()const;
OSQLError::ValueList errors()const;
OSQLResultItem::ValueList results()const;
void setState( enum State state );
void setErrors( const OSQLError::ValueList& error );
void setResults( const OSQLResultItem::ValueList& result );
OSQLResultItem first();
OSQLResultItem next();
bool atEnd();
OSQLResultItem::ValueList::ConstIterator iterator()const;
private:
enum State m_state;
OSQLResultItem::ValueList m_list;
OSQLError::ValueList m_error;
OSQLResultItem::ValueList::Iterator it;
+ class Private;
+ Private *d;
};
+}
+}
#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 @@
#include "osqltable.h"
+using namespace Opie::DB;
+
OSQLTableItem::OSQLTableItem() {}
OSQLTableItem::OSQLTableItem( enum Type type,
const QString& field,
const QVariant& var)
: m_type( type ), m_field( field ), m_var( var )
{
}
OSQLTableItem::~OSQLTableItem() {}
OSQLTableItem::OSQLTableItem( const OSQLTableItem& item) {
*this = item;
}
OSQLTableItem &OSQLTableItem::operator=(const OSQLTableItem& other) {
m_var = other.m_var;
m_field = other.m_field;
m_type = other.m_type;
return *this;
}
QString OSQLTableItem::fieldName()const{
return m_field;
}
OSQLTableItem::Type OSQLTableItem::type()const {
return m_type;
}
QVariant OSQLTableItem::more()const {
return m_var;
}
OSQLTable::OSQLTable( const QString& tableName )
: m_table( tableName )
{
}
OSQLTable::~OSQLTable() {
}
void OSQLTable::setColumns( const OSQLTableItem::ValueList& list) {
m_list = list;
}
OSQLTableItem::ValueList OSQLTable::columns()const {
return m_list;
}
QString OSQLTable::tableName()const {
return m_table;
}
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 @@
#ifndef OSQL_TABLE_H
#define OSQL_TABLE_H
#include <qstring.h>
#include <qvaluelist.h>
#include <qvariant.h>
+namespace Opie {
+namespace DB {
/**
* OSQLTableItem saves one column of a complete
* table
*/
class OSQLTableItem {
public:
typedef QValueList<OSQLTableItem> ValueList;
/**
* Type kinds ( to be extended )
*/
enum Type { Undefined=-1, Integer=0, BigInteger =1,
Float = 2, VarChar = 4 };
/**
* A constructor
* @param type the Type of the Column
* @param fieldName the Name of the Column
* @param var a Variant
*/
OSQLTableItem();
OSQLTableItem( enum Type type,
const QString& fieldName,
const QVariant& var= QVariant() );
/**
* copy c'tor
*/
OSQLTableItem( const OSQLTableItem& );
/**
* d'tor
*/
~OSQLTableItem();
OSQLTableItem& operator=( const OSQLTableItem& );
/**
* the fieldName
*/
QString fieldName() const;
/**
* the field Type
*/
Type type() const;
QVariant more() const;
private:
class OSQLTableItemPrivate;
OSQLTableItemPrivate* d;
Type m_type;
QString m_field;
QVariant m_var;
};
/**
* A OSQLTable consists of OSQLTableItems
*/
class OSQLTable {
public:
typedef QValueList<OSQLTable> ValueList;
/**
* @param tableName the Name of the Table
*/
OSQLTable(const QString& tableName);
/**
* d'tor
*/
~OSQLTable();
/**
* setColumns sets the Columns of the Table
*/
void setColumns( const OSQLTableItem::ValueList& );
/**
* returns all columns of the table
*/
OSQLTableItem::ValueList columns() const;
QString tableName()const;
private:
QString m_table;
OSQLTableItem::ValueList m_list;
+ class Private;
+ Private *d;
};
+}
+}
+
#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 @@
TEMPLATE = lib
CONFIG += qt warn_on debug
DESTDIR = $(OPIEDIR)/lib
HEADERS = osoundsystem.h
SOURCES = osoundsystem.cpp
INTERFACES =
TARGET = opiemm2
-VERSION = 1.8.2
+VERSION = 1.9.0
INCLUDEPATH += $(OPIEDIR)/include
DEPENDPATH += $(OPIEDIR)/include
!contains( platform, x11 ) {
include ( $(OPIEDIR)/include.pro )
}
contains( platform, x11 ) {
LIBS = -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib
}
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,139 +1,141 @@
/*
                This file is part of the Opie Project
              (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
=.
.=l.
           .>+-=
 _;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include <opie2/osoundsystem.h>
#include <opie2/odebug.h>
#include <errno.h>
#include <fcntl.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/soundcard.h>
#include <sys/stat.h>
+using namespace Opie::Core;
+using namespace Opie::MM;
/*======================================================================================
* OSoundSystem
*======================================================================================*/
OSoundSystem* OSoundSystem::_instance = 0;
OSoundSystem::OSoundSystem()
{
odebug << "OSoundSystem::OSoundSystem()" << oendl;
synchronize();
}
void OSoundSystem::synchronize()
{
// gather available interfaces by inspecting /dev
//FIXME: we could use SIOCGIFCONF here, but we aren't interested in virtual (e.g. eth0:0) devices
//FIXME: Use SIOCGIFCONF anway, because we can disable listing of aliased devices
_interfaces.clear();
_interfaces.insert( "soundcard", new OSoundCard( this, "soundcard" ) );
/*
QString str;
QFile f( "/dev/sound" );
bool hasFile = f.open( IO_ReadOnly );
if ( !hasFile )
{
odebug << "OSoundSystem: /dev/sound not existing. No sound devices available" << oendl;
return;
}
QTextStream s( &f );
s.readLine();
s.readLine();
while ( !s.atEnd() )
{
s >> str;
str.truncate( str.find( ':' ) );
qDebug( "OSoundSystem: found interface '%s'", (const char*) str );
OAudioInterface* iface;
iface = new OAudioInterface( this, (const char*) str );
_interfaces.insert( str, iface );
s.readLine();
}
*/
}
int OSoundSystem::count() const
{
return _interfaces.count();
}
OSoundCard* OSoundSystem::card( const QString& iface ) const
{
return _interfaces[iface];
}
OSoundSystem* OSoundSystem::instance()
{
if ( !_instance ) _instance = new OSoundSystem();
return _instance;
}
OSoundSystem::CardIterator OSoundSystem::iterator() const
{
return OSoundSystem::CardIterator( _interfaces );
}
/*======================================================================================
* OSoundCard
*======================================================================================*/
OSoundCard::OSoundCard( QObject* parent, const char* name )
:QObject( parent, name ), _audio( 0 ), _mixer( 0 )
{
odebug << "OSoundCard::OSoundCard()" << oendl;
init();
}
OSoundCard::~OSoundCard()
{
}
void OSoundCard::init()
{
_audio = new OAudioInterface( this, "/dev/dsp" );
_mixer = new OMixerInterface( this, "/dev/mixer" );
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 @@
/*
                This file is part of the Opie Project
              (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
=.
.=l.
           .>+-=
 _;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef OSOUNDSYSTEM_H
#define OSOUNDSYSTEM_H
#include <qobject.h>
#include <qdict.h>
#include <qmap.h>
+namespace Opie {
+namespace MM {
+
class OAudioInterface;
class OMixerInterface;
class OSoundCard;
/*======================================================================================
* OSoundSystem
*======================================================================================*/
/**
* @brief A container class for all audio interfaces
*
* This class provides access to all available audio/midi/sequencer interfaces of your computer.
*
* @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
*/
class OSoundSystem : public QObject
{
Q_OBJECT
public:
typedef QDict<OSoundCard> CardMap;
typedef QDictIterator<OSoundCard> CardIterator;
public:
/**
* @returns the number of available interfaces
*/
int count() const;
/**
* @returns a pointer to the (one and only) @ref ONetwork instance.
*/
static OSoundSystem* instance();
/**
* @returns an iterator usable for iterating through all network interfaces.
*/
CardIterator iterator() const;
/**
* @returns a pointer to the @ref OAudioInterface object for the specified @a interface or 0, if not found
* @see OAudioInterface
*/
OSoundCard* card( const QString& interface ) const;
/**
* @internal Rebuild the internal interface database
* @note Sometimes it might be useful to call this from client code,
* e.g. after issuing a cardctl insert
*/
void synchronize();
protected:
OSoundSystem();
private:
static OSoundSystem* _instance;
CardMap _interfaces;
+ class Private;
+ Private *d;
};
/*======================================================================================
* OSoundCard
*======================================================================================*/
class OSoundCard : public QObject
{
Q_OBJECT
public:
/**
* Constructor. Normally you don't create @ref OSoundCard objects yourself,
* but access them via @ref OSoundSystem::card().
*/
OSoundCard( QObject* parent, const char* name );
/**
* Destructor.
*/
virtual ~OSoundCard();
bool hasMixer() const { return _audio; };
bool hasAudio() const { return _mixer; };
OAudioInterface* audio() const { return _audio; };
OMixerInterface* mixer() const { return _mixer; };
protected:
OAudioInterface* _audio;
OMixerInterface* _mixer;
private:
void init();
+ private:
+ class Private;
+ Private *d;
};
/*======================================================================================
* OAudioInterface
*======================================================================================*/
class OAudioInterface : public QObject
{
Q_OBJECT
public:
/**
* Constructor. Normally you don't create @ref OAudioInterface objects yourself,
* but access them via the @ref OSoundCard interface.
*/
OAudioInterface( QObject* parent, const char* name );
/**
* Destructor.
*/
virtual ~OAudioInterface();
protected:
const int _sfd;
private:
void init();
+ private:
+ class Private;
+ Private *d;
};
/*======================================================================================
* OMixerInterface
*======================================================================================*/
class OMixerInterface : public QObject
{
Q_OBJECT
public:
typedef QMap<QString,int>::ConstIterator ChannelIterator;
/**
* Constructor. Normally you don't create @ref OMixerInterface objects yourself,
* but access them via the @ref OSoundCard interface.
*/
OMixerInterface( QObject* parent, const char* name );
/**
* Destructor.
*/
virtual ~OMixerInterface();
/**
* @returns all available channels.
*/
QStringList allChannels() const;
/**
* @returns recordable channels.
*/
QStringList recChannels() const;
/**
* @returns playable channels.
*/
QStringList playChannels() const;
/**
* @returns true, if @a channel exists.
*/
bool hasChannel( const QString& channel );
/**
* Set the @a left and @a right volumes for @a channel.
* If no value for right is given, the value for left is taken for that.
*/
void setVolume( const QString& channel, int left, int right = -1 );
/**
* @returns the volume of @a channel or -1, if the channel doesn't exist.
* @note You might want to use @ref hasChannel() to check if a channel exists.
*/
int volume( const QString& channel ) const;
protected:
int _fd;
QMap<QString, int> _channels;
private:
void init();
+ private:
+ class Private;
+ Private *d;
};
+}
+}
+
#endif // OSOUNDSYSTEM_H
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
@@ -362,97 +362,98 @@ struct ieee_802_11_mgmt_body {
// u_int16_t auth_trans_seq_num;
// struct challenge_t challenge;
u_int16_t capability_info;
// struct ssid_t ssid;
// struct rates_t rates;
// struct ds_t ds;
// struct cf_t cf;
// struct fh_t fh;
// struct tim_t tim;
};
/* a 802.11 value */
struct val_80211 {
unsigned int did;
unsigned short status, len;
unsigned int data;
};
/* header attached during prism monitor mode */
struct prism_hdr {
unsigned int msgcode, msglen;
char devname[16];
struct val_80211 hosttime, mactime, channel, rssi, sq, signal,
noise, rate, istx, frmlen;
};
struct ieee_802_11_data_body {
//FIXME
};
struct ieee_802_11_control_body {
//FIXME
};
struct ctrl_rts_t {
u_int16_t fc;
u_int16_t duration;
u_int8_t ra[6];
u_int8_t ta[6];
u_int8_t fcs[4];
};
#define CTRL_RTS_LEN (2+2+6+6+4)
struct ctrl_cts_t {
u_int16_t fc;
u_int16_t duration;
u_int8_t ra[6];
u_int8_t fcs[4];
};
#define CTRL_CTS_LEN (2+2+6+4)
struct ctrl_ack_t {
u_int16_t fc;
u_int16_t duration;
u_int8_t ra[6];
u_int8_t fcs[4];
};
#define CTRL_ACK_LEN (2+2+6+4)
struct ctrl_ps_poll_t {
u_int16_t fc;
u_int16_t aid;
u_int8_t bssid[6];
u_int8_t ta[6];
u_int8_t fcs[4];
};
#define CTRL_PS_POLL_LEN (2+2+6+6+4)
struct ctrl_end_t {
u_int16_t fc;
u_int16_t duration;
u_int8_t ra[6];
u_int8_t bssid[6];
u_int8_t fcs[4];
};
#define CTRL_END_LEN (2+2+6+6+4)
struct ctrl_end_ack_t {
u_int16_t fc;
u_int16_t duration;
u_int8_t ra[6];
u_int8_t bssid[6];
u_int8_t fcs[4];
};
#define CTRL_END_ACK_LEN (2+2+6+6+4)
#define IV_IV(iv) ((iv) & 0xFFFFFF)
#define IV_PAD(iv) (((iv) >> 24) & 0x3F)
#define IV_KEYID(iv) (((iv) >> 30) & 0x03)
+
#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,201 +1,203 @@
/* dhcp.h
Protocol structures... */
/*
* Copyright (c) 1995-2001 The Internet Software Consortium.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of The Internet Software Consortium nor the names
* of its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INTERNET SOFTWARE CONSORTIUM AND
* CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE INTERNET SOFTWARE CONSORTIUM OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* This software has been written for the Internet Software Consortium
* by Ted Lemon in cooperation with Vixie Enterprises. To learn more
* about the Internet Software Consortium, see ``http://www.isc.org''.
* To learn more about Vixie Enterprises, see ``http://www.vix.com''.
*/
#ifndef DHCP_H
#define DHCP_H
+
#define DHCP_UDP_OVERHEAD (14 + /* Ethernet header */ \
20 + /* IP header */ \
8) /* UDP header */
#define DHCP_SNAME_LEN 64
#define DHCP_FILE_LEN 128
#define DHCP_FIXED_NON_UDP 236
#define DHCP_FIXED_LEN (DHCP_FIXED_NON_UDP + DHCP_UDP_OVERHEAD)
/* Everything but options. */
#define DHCP_MTU_MAX 1500
#define DHCP_OPTION_LEN (DHCP_MTU_MAX - DHCP_FIXED_LEN)
#define BOOTP_MIN_LEN 300
#define DHCP_MIN_LEN 548
struct dhcp_packet {
u_int8_t op; /* 0: Message opcode/type */
u_int8_t htype; /* 1: Hardware addr type (net/if_types.h) */
u_int8_t hlen; /* 2: Hardware addr length */
u_int8_t hops; /* 3: Number of relay agent hops from client */
u_int32_t xid; /* 4: Transaction ID */
u_int16_t secs; /* 8: Seconds since client started looking */
u_int16_t flags; /* 10: Flag bits */
struct in_addr ciaddr; /* 12: Client IP address (if already in use) */
struct in_addr yiaddr; /* 16: Client IP address */
struct in_addr siaddr; /* 18: IP address of next server to talk to */
struct in_addr giaddr; /* 20: DHCP relay agent IP address */
unsigned char chaddr [16]; /* 24: Client hardware address */
char sname [DHCP_SNAME_LEN]; /* 40: Server name */
char file [DHCP_FILE_LEN]; /* 104: Boot filename */
unsigned char options [DHCP_OPTION_LEN];
/* 212: Optional parameters
(actual length dependent on MTU). */
};
/* BOOTP (rfc951) message types */
#define BOOTREQUEST 1
#define BOOTREPLY 2
/* Possible values for flags field... */
#define BOOTP_BROADCAST 32768L
/* Possible values for hardware type (htype) field... */
#define HTYPE_ETHER 1 /* Ethernet 10Mbps */
#define HTYPE_IEEE802 6 /* IEEE 802.2 Token Ring... */
#define HTYPE_FDDI 8 /* FDDI... */
/* Magic cookie validating dhcp options field (and bootp vendor
extensions field). */
#define DHCP_OPTIONS_COOKIE "\143\202\123\143"
/* DHCP Option codes: */
#define DHO_PAD 0
#define DHO_SUBNET_MASK 1
#define DHO_TIME_OFFSET 2
#define DHO_ROUTERS 3
#define DHO_TIME_SERVERS 4
#define DHO_NAME_SERVERS 5
#define DHO_DOMAIN_NAME_SERVERS 6
#define DHO_LOG_SERVERS 7
#define DHO_COOKIE_SERVERS 8
#define DHO_LPR_SERVERS 9
#define DHO_IMPRESS_SERVERS 10
#define DHO_RESOURCE_LOCATION_SERVERS 11
#define DHO_HOST_NAME 12
#define DHO_BOOT_SIZE 13
#define DHO_MERIT_DUMP 14
#define DHO_DOMAIN_NAME 15
#define DHO_SWAP_SERVER 16
#define DHO_ROOT_PATH 17
#define DHO_EXTENSIONS_PATH 18
#define DHO_IP_FORWARDING 19
#define DHO_NON_LOCAL_SOURCE_ROUTING 20
#define DHO_POLICY_FILTER 21
#define DHO_MAX_DGRAM_REASSEMBLY 22
#define DHO_DEFAULT_IP_TTL 23
#define DHO_PATH_MTU_AGING_TIMEOUT 24
#define DHO_PATH_MTU_PLATEAU_TABLE 25
#define DHO_INTERFACE_MTU 26
#define DHO_ALL_SUBNETS_LOCAL 27
#define DHO_BROADCAST_ADDRESS 28
#define DHO_PERFORM_MASK_DISCOVERY 29
#define DHO_MASK_SUPPLIER 30
#define DHO_ROUTER_DISCOVERY 31
#define DHO_ROUTER_SOLICITATION_ADDRESS 32
#define DHO_STATIC_ROUTES 33
#define DHO_TRAILER_ENCAPSULATION 34
#define DHO_ARP_CACHE_TIMEOUT 35
#define DHO_IEEE802_3_ENCAPSULATION 36
#define DHO_DEFAULT_TCP_TTL 37
#define DHO_TCP_KEEPALIVE_INTERVAL 38
#define DHO_TCP_KEEPALIVE_GARBAGE 39
#define DHO_NIS_DOMAIN 40
#define DHO_NIS_SERVERS 41
#define DHO_NTP_SERVERS 42
#define DHO_VENDOR_ENCAPSULATED_OPTIONS 43
#define DHO_NETBIOS_NAME_SERVERS 44
#define DHO_NETBIOS_DD_SERVER 45
#define DHO_NETBIOS_NODE_TYPE 46
#define DHO_NETBIOS_SCOPE 47
#define DHO_FONT_SERVERS 48
#define DHO_X_DISPLAY_MANAGER 49
#define DHO_DHCP_REQUESTED_ADDRESS 50
#define DHO_DHCP_LEASE_TIME 51
#define DHO_DHCP_OPTION_OVERLOAD 52
#define DHO_DHCP_MESSAGE_TYPE 53
#define DHO_DHCP_SERVER_IDENTIFIER 54
#define DHO_DHCP_PARAMETER_REQUEST_LIST 55
#define DHO_DHCP_MESSAGE 56
#define DHO_DHCP_MAX_MESSAGE_SIZE 57
#define DHO_DHCP_RENEWAL_TIME 58
#define DHO_DHCP_REBINDING_TIME 59
#define DHO_VENDOR_CLASS_IDENTIFIER 60
#define DHO_DHCP_CLIENT_IDENTIFIER 61
#define DHO_NWIP_DOMAIN_NAME 62
#define DHO_NWIP_SUBOPTIONS 63
#define DHO_USER_CLASS 77
#define DHO_FQDN 81
#define DHO_DHCP_AGENT_OPTIONS 82
#define DHO_SUBNET_SELECTION 118 /* RFC3011! */
/* The DHO_AUTHENTICATE option is not a standard yet, so I've
allocated an option out of the "local" option space for it on a
temporary basis. Once an option code number is assigned, I will
immediately and shamelessly break this, so don't count on it
continuing to work. */
#define DHO_AUTHENTICATE 210
#define DHO_END 255
/* DHCP message types. */
#define DHCPDISCOVER 1
#define DHCPOFFER 2
#define DHCPREQUEST 3
#define DHCPDECLINE 4
#define DHCPACK 5
#define DHCPNAK 6
#define DHCPRELEASE 7
#define DHCPINFORM 8
/* Relay Agent Information option subtypes: */
#define RAI_CIRCUIT_ID 1
#define RAI_REMOTE_ID 2
#define RAI_AGENT_ID 3
/* FQDN suboptions: */
#define FQDN_NO_CLIENT_UPDATE 1
#define FQDN_SERVER_UPDATE 2
#define FQDN_ENCODED 3
#define FQDN_RCODE1 4
#define FQDN_RCODE2 5
#define FQDN_HOSTNAME 6
#define FQDN_DOMAINNAME 7
#define FQDN_FQDN 8
#define FQDN_SUBOPTION_COUNT 8
+
#endif
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,105 +1,111 @@
/*
* debug value mapper - generated by regen.py - (C) Michael 'Mickey' Lauer <mickey@vanille.de>
*/
#include <opie2/odebug.h>
#include "odebugmapper.h"
+using namespace Opie::Core;
+
+namespace Opie {
+namespace Net {
+namespace Private {
+
DebugMapper::DebugMapper()
{
odebug << "DebugMapper::DebugMapper()" << oendl;
_map.insert( 0x8902, new QString("SIOCSPGRP") );
_map.insert( 0x8904, new QString("SIOCGPGRP") );
_map.insert( 0x8905, new QString("SIOCATMARK") );
_map.insert( 0x8906, new QString("SIOCGSTAMP") );
_map.insert( 0x890B, new QString("SIOCADDRT") );
_map.insert( 0x890C, new QString("SIOCDELRT") );
_map.insert( 0x890D, new QString("SIOCRTMSG") );
_map.insert( 0x8910, new QString("SIOCGIFNAME") );
_map.insert( 0x8911, new QString("SIOCSIFLINK") );
_map.insert( 0x8912, new QString("SIOCGIFCONF") );
_map.insert( 0x8913, new QString("SIOCGIFFLAGS") );
_map.insert( 0x8914, new QString("SIOCSIFFLAGS") );
_map.insert( 0x8915, new QString("SIOCGIFADDR") );
_map.insert( 0x8916, new QString("SIOCSIFADDR") );
_map.insert( 0x8917, new QString("SIOCGIFDSTADDR") );
_map.insert( 0x8918, new QString("SIOCSIFDSTADDR") );
_map.insert( 0x8919, new QString("SIOCGIFBRDADDR") );
_map.insert( 0x891a, new QString("SIOCSIFBRDADDR") );
_map.insert( 0x891b, new QString("SIOCGIFNETMASK") );
_map.insert( 0x891c, new QString("SIOCSIFNETMASK") );
_map.insert( 0x891d, new QString("SIOCGIFMETRIC") );
_map.insert( 0x891e, new QString("SIOCSIFMETRIC") );
_map.insert( 0x891f, new QString("SIOCGIFMEM") );
_map.insert( 0x8920, new QString("SIOCSIFMEM") );
_map.insert( 0x8921, new QString("SIOCGIFMTU") );
_map.insert( 0x8922, new QString("SIOCSIFMTU") );
_map.insert( 0x8923, new QString("SIOCSIFNAME") );
_map.insert( 0x8924, new QString("SIOCSIFHWADDR") );
_map.insert( 0x8925, new QString("SIOCGIFENCAP") );
_map.insert( 0x8926, new QString("SIOCSIFENCAP") );
_map.insert( 0x8927, new QString("SIOCGIFHWADDR") );
_map.insert( 0x8929, new QString("SIOCGIFSLAVE") );
_map.insert( 0x8930, new QString("SIOCSIFSLAVE") );
_map.insert( 0x8931, new QString("SIOCADDMULTI") );
_map.insert( 0x8932, new QString("SIOCDELMULTI") );
_map.insert( 0x8933, new QString("SIOCGIFINDEX") );
_map.insert( 0x8934, new QString("SIOCSIFPFLAGS") );
_map.insert( 0x8935, new QString("SIOCGIFPFLAGS") );
_map.insert( 0x8936, new QString("SIOCDIFADDR") );
_map.insert( 0x8937, new QString("SIOCSIFHWBROADCAST") );
_map.insert( 0x8938, new QString("SIOCGIFCOUNT") );
_map.insert( 0x8940, new QString("SIOCGIFBR") );
_map.insert( 0x8941, new QString("SIOCSIFBR") );
_map.insert( 0x8942, new QString("SIOCGIFTXQLEN") );
_map.insert( 0x8943, new QString("SIOCSIFTXQLEN") );
_map.insert( 0x8953, new QString("SIOCDARP") );
_map.insert( 0x8954, new QString("SIOCGARP") );
_map.insert( 0x8955, new QString("SIOCSARP") );
_map.insert( 0x8960, new QString("SIOCDRARP") );
_map.insert( 0x8961, new QString("SIOCGRARP") );
_map.insert( 0x8962, new QString("SIOCSRARP") );
_map.insert( 0x8970, new QString("SIOCGIFMAP") );
_map.insert( 0x8971, new QString("SIOCSIFMAP") );
_map.insert( 0x8980, new QString("SIOCADDDLCI") );
_map.insert( 0x8981, new QString("SIOCDELDLCI") );
_map.insert( 0x89F0, new QString("SIOCDEVPRIVATE") );
_map.insert( 0x89E0, new QString("SIOCPROTOPRIVATE") );
_map.insert( 0x1fff, new QString("SIOCPARM_MASK") );
_map.insert( 0x00000000, new QString("SIOC_VOID") );
_map.insert( 0x20000000, new QString("SIOC_OUT") );
_map.insert( 0x40000000, new QString("SIOC_IN") );
_map.insert( 0x8B00, new QString("SIOCSIWCOMMIT") );
_map.insert( 0x8B01, new QString("SIOCGIWNAME") );
_map.insert( 0x8B02, new QString("SIOCSIWNWID") );
_map.insert( 0x8B03, new QString("SIOCGIWNWID") );
_map.insert( 0x8B04, new QString("SIOCSIWFREQ") );
_map.insert( 0x8B05, new QString("SIOCGIWFREQ") );
_map.insert( 0x8B06, new QString("SIOCSIWMODE") );
_map.insert( 0x8B07, new QString("SIOCGIWMODE") );
_map.insert( 0x8B08, new QString("SIOCSIWSENS") );
_map.insert( 0x8B09, new QString("SIOCGIWSENS") );
_map.insert( 0x8B0A, new QString("SIOCSIWRANGE") );
_map.insert( 0x8B0B, new QString("SIOCGIWRANGE") );
_map.insert( 0x8B0C, new QString("SIOCSIWPRIV") );
_map.insert( 0x8B0D, new QString("SIOCGIWPRIV") );
_map.insert( 0x8B0E, new QString("SIOCSIWSTATS") );
_map.insert( 0x8B0F, new QString("SIOCGIWSTATS") );
_map.insert( 0x8B10, new QString("SIOCSIWSPY") );
_map.insert( 0x8B11, new QString("SIOCGIWSPY") );
_map.insert( 0x8B14, new QString("SIOCSIWAP") );
_map.insert( 0x8B15, new QString("SIOCGIWAP") );
_map.insert( 0x8B17, new QString("SIOCGIWAPLIST") );
_map.insert( 0x8B18, new QString("SIOCSIWSCAN") );
_map.insert( 0x8B19, new QString("SIOCGIWSCAN") );
_map.insert( 0x8B1A, new QString("SIOCSIWESSID") );
_map.insert( 0x8B1B, new QString("SIOCGIWESSID") );
_map.insert( 0x8B1C, new QString("SIOCSIWNICKN") );
_map.insert( 0x8B1D, new QString("SIOCGIWNICKN") );
_map.insert( 0x8B20, new QString("SIOCSIWRATE") );
_map.insert( 0x8B21, new QString("SIOCGIWRATE") );
_map.insert( 0x8B22, new QString("SIOCSIWRTS") );
@@ -119,97 +125,99 @@ DebugMapper::DebugMapper()
_map.insert( 0x8B00, new QString("SIOCIWFIRST") );
_map.insert( 0x5000, new QString("SIOCGBPQETHPARAM") );
_map.insert( 0x5001, new QString("SIOCSBPQETHPARAM") );
_map.insert( 0x890B, new QString("SIOCADDRT") );
_map.insert( 0x890C, new QString("SIOCDELRT") );
_map.insert( 0x890D, new QString("SIOCRTMSG") );
_map.insert( 0x8910, new QString("SIOCGIFNAME") );
_map.insert( 0x8911, new QString("SIOCSIFLINK") );
_map.insert( 0x8912, new QString("SIOCGIFCONF") );
_map.insert( 0x8913, new QString("SIOCGIFFLAGS") );
_map.insert( 0x8914, new QString("SIOCSIFFLAGS") );
_map.insert( 0x8915, new QString("SIOCGIFADDR") );
_map.insert( 0x8916, new QString("SIOCSIFADDR") );
_map.insert( 0x8917, new QString("SIOCGIFDSTADDR") );
_map.insert( 0x8918, new QString("SIOCSIFDSTADDR") );
_map.insert( 0x8919, new QString("SIOCGIFBRDADDR") );
_map.insert( 0x891a, new QString("SIOCSIFBRDADDR") );
_map.insert( 0x891b, new QString("SIOCGIFNETMASK") );
_map.insert( 0x891c, new QString("SIOCSIFNETMASK") );
_map.insert( 0x891d, new QString("SIOCGIFMETRIC") );
_map.insert( 0x891e, new QString("SIOCSIFMETRIC") );
_map.insert( 0x891f, new QString("SIOCGIFMEM") );
_map.insert( 0x8920, new QString("SIOCSIFMEM") );
_map.insert( 0x8921, new QString("SIOCGIFMTU") );
_map.insert( 0x8922, new QString("SIOCSIFMTU") );
_map.insert( 0x8923, new QString("SIOCSIFNAME") );
_map.insert( 0x8924, new QString("SIOCSIFHWADDR") );
_map.insert( 0x8925, new QString("SIOCGIFENCAP") );
_map.insert( 0x8926, new QString("SIOCSIFENCAP") );
_map.insert( 0x8927, new QString("SIOCGIFHWADDR") );
_map.insert( 0x8929, new QString("SIOCGIFSLAVE") );
_map.insert( 0x8930, new QString("SIOCSIFSLAVE") );
_map.insert( 0x8931, new QString("SIOCADDMULTI") );
_map.insert( 0x8932, new QString("SIOCDELMULTI") );
_map.insert( 0x8933, new QString("SIOCGIFINDEX") );
_map.insert( 0x8934, new QString("SIOCSIFPFLAGS") );
_map.insert( 0x8935, new QString("SIOCGIFPFLAGS") );
_map.insert( 0x8936, new QString("SIOCDIFADDR") );
_map.insert( 0x8937, new QString("SIOCSIFHWBROADCAST") );
_map.insert( 0x8938, new QString("SIOCGIFCOUNT") );
_map.insert( 0x8940, new QString("SIOCGIFBR") );
_map.insert( 0x8941, new QString("SIOCSIFBR") );
_map.insert( 0x8942, new QString("SIOCGIFTXQLEN") );
_map.insert( 0x8943, new QString("SIOCSIFTXQLEN") );
_map.insert( 0x8944, new QString("SIOCGIFDIVERT") );
_map.insert( 0x8945, new QString("SIOCSIFDIVERT") );
_map.insert( 0x8946, new QString("SIOCETHTOOL") );
_map.insert( 0x8947, new QString("SIOCGMIIPHY") );
_map.insert( 0x8948, new QString("SIOCGMIIREG") );
_map.insert( 0x8949, new QString("SIOCSMIIREG") );
_map.insert( 0x894A, new QString("SIOCWANDEV") );
_map.insert( 0x8953, new QString("SIOCDARP") );
_map.insert( 0x8954, new QString("SIOCGARP") );
_map.insert( 0x8955, new QString("SIOCSARP") );
_map.insert( 0x8960, new QString("SIOCDRARP") );
_map.insert( 0x8961, new QString("SIOCGRARP") );
_map.insert( 0x8962, new QString("SIOCSRARP") );
_map.insert( 0x8970, new QString("SIOCGIFMAP") );
_map.insert( 0x8971, new QString("SIOCSIFMAP") );
_map.insert( 0x8980, new QString("SIOCADDDLCI") );
_map.insert( 0x8981, new QString("SIOCDELDLCI") );
_map.insert( 0x8982, new QString("SIOCGIFVLAN") );
_map.insert( 0x8983, new QString("SIOCSIFVLAN") );
_map.insert( 0x8990, new QString("SIOCBONDENSLAVE") );
_map.insert( 0x8991, new QString("SIOCBONDRELEASE") );
_map.insert( 0x8992, new QString("SIOCBONDSETHWADDR") );
_map.insert( 0x8993, new QString("SIOCBONDSLAVEINFOQUERY") );
_map.insert( 0x8994, new QString("SIOCBONDINFOQUERY") );
_map.insert( 0x8995, new QString("SIOCBONDCHANGEACTIVE") );
_map.insert( 0x89F0, new QString("SIOCDEVPRIVATE") );
_map.insert( 0x89E0, new QString("SIOCPROTOPRIVATE") );
};
DebugMapper::~DebugMapper()
{
odebug << "DebugMapper::~DebugMapper()" << oendl;
}
const QString& DebugMapper::map( int value ) const
{
QString* result = _map[ value ];
if ( !result )
{
owarn << "DebugMapper::map() - value " << value << " is not found." << oendl;
return QString::null;
}
else
{
return *result;
}
}
-
+}
+}
+}
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 @@
/*
* debug value mapper - generated by regen.py - (C) Michael 'Mickey' Lauer <mickey@vanille.de>
*/
#ifndef DEBUGMAPPER_H
#define DEBUGMAPPER_H
#include <qstring.h>
#include <qintdict.h>
+namespace Opie {
+namespace Net {
+namespace Private {
+
typedef QIntDict<QString> IntStringMap;
class DebugMapper
{
public:
DebugMapper();
~DebugMapper();
const QString& map( int value ) const;
private:
IntStringMap _map;
+ class Private;
+ Private *d;
};
+}
+}
+}
+
#endif
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 @@
/*
                This file is part of the Opie Project
              (C) 2003 Michael 'Mickey' Lauer <mickey@Vanille.de>
=.
.=l.
           .>+-=
 _;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include "omanufacturerdb.h"
#define OPIE_IMPROVE_GUI_LATENCY 1
/* OPIE */
#include <opie2/odebug.h>
#ifdef OPIE_IMPROVE_GUI_LATENCY
#include <qpe/global.h>
#endif
/* QT */
#include <qapplication.h>
#include <qfile.h>
#include <qtextstream.h>
+using namespace Opie::Core;
+namespace Opie {
+namespace Net {
+
OManufacturerDB* OManufacturerDB::_instance = 0;
OManufacturerDB* OManufacturerDB::instance()
{
if ( !OManufacturerDB::_instance )
{
odebug << "OManufacturerDB::instance(): creating OManufacturerDB..." << oendl;
_instance = new OManufacturerDB();
}
return _instance;
}
OManufacturerDB::OManufacturerDB()
{
#ifdef OPIE_IMPROVE_GUI_LATENCY
Global::statusMessage( "Reading Manufacturers..." );
#endif
QString filename( "/etc/manufacturers" );
odebug << "OManufacturerDB: trying to read " << filename << oendl;
if ( !QFile::exists( filename ) )
{
filename = "/opt/QtPalmtop/etc/manufacturers";
odebug << "OManufacturerDB: trying to read " << filename << oendl;
if ( !QFile::exists( filename ) )
{
filename = "/usr/share/wellenreiter/manufacturers";
odebug << "OManufacturerDB: trying to read " << filename << oendl;
}
}
QFile file( filename );
bool hasFile = file.open( IO_ReadOnly );
if (!hasFile)
{
owarn << "OManufacturerDB: no valid manufacturer list found." << oendl;
}
else
{
odebug << "OManufacturerDB: found manufacturer list in " << filename << oendl;
QTextStream s( &file );
QString addr;
QString manu;
QString extManu;
#ifdef OPIE_IMPROVE_GUI_LATENCY
int counter = 0;
#endif
while (!s.atEnd())
{
s >> addr;
s >> manu;
s >> extManu;
manufacturers.insert( addr, manu );
manufacturersExt.insert( addr, extManu );
// odebug << "OmanufacturerDB: parse '" << addr << "' as '" << manu << "' (" << extManu << ")" << oendl;
#ifdef OPIE_IMPROVE_GUI_LATENCY
counter++;
if ( counter == 50 )
{
qApp->processEvents();
counter = 0;
}
#endif
}
odebug << "OManufacturerDB: manufacturer list completed." << oendl;
#ifdef OPIE_IMPROVE_GUI_LATENCY
Global::statusMessage( "Manufacturers Complete..." );
#endif
}
}
OManufacturerDB::~OManufacturerDB()
{
}
const QString& OManufacturerDB::lookup( const QString& macaddr ) const
{
return manufacturers[macaddr.upper().left(8)];
}
const QString& OManufacturerDB::lookupExt( const QString& macaddr ) const
{
QMap<QString,QString>::ConstIterator it = manufacturersExt.find( macaddr.upper().left(8) );
return it == manufacturersExt.end() ? lookup( macaddr ) : *it;
}
+}
+}
+
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 @@
/*
                This file is part of the Opie Project
              (C) 2003 Michael 'Mickey' Lauer <mickey@Vanille.de>
=.
.=l.
           .>+-=
 _;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef OMANUFACTURERDB_H
#define OMANUFACTURERDB_H
#include <qmap.h>
+namespace Opie {
+namespace Net {
+
/**
* @brief A Ethernet card vendor database.
*
* This class encapsulates the lookup of Ethernet vendor given a
* certain Mac Address. Only the first three bytes define the vendor.
*/
class OManufacturerDB
{
public:
/**
* @returns the one-and-only @ref OManufacturerDB instance.
*/
static OManufacturerDB* instance();
/**
* @returns the short manufacturer string given a @a macaddr.
*/
const QString& lookup( const QString& macaddr ) const;
/**
* @returns the enhanced manufacturer string given a @a macaddr.
*/
const QString& lookupExt( const QString& macaddr ) const;
protected:
OManufacturerDB();
virtual ~OManufacturerDB();
private:
QMap<QString, QString> manufacturers;
QMap<QString, QString> manufacturersExt;
static OManufacturerDB* _instance;
+ class Private;
+ Private *d;
};
+}
+}
+
#endif
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,232 +1,241 @@
/*
                This file is part of the Opie Project
              (C) 2003 Michael 'Mickey' Lauer <mickey@Vanille.de>
=.
.=l.
           .>+-=
 _;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include <opie2/onetutils.h>
#include <opie2/onetwork.h>
#include <opie2/omanufacturerdb.h>
#include <net/if.h>
#include <assert.h>
#include <stdio.h>
+namespace Opie {
+namespace Net {
+
/*======================================================================================
* OMacAddress
*======================================================================================*/
// static initializer for broadcast and unknown MAC Adresses
const unsigned char __broadcast[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
const OMacAddress& OMacAddress::broadcast = OMacAddress( __broadcast );
const unsigned char __unknown[6] = { 0x44, 0x44, 0x44, 0x44, 0x44, 0x44 };
const OMacAddress& OMacAddress::unknown = OMacAddress( __unknown );
//TODO: Incorporate Ethernet Manufacturer database here! (inline or so)
OMacAddress::OMacAddress()
{
memcpy( _bytes, __unknown, 6 );
}
OMacAddress::OMacAddress( unsigned char* p )
{
memcpy( _bytes, p, 6 );
}
OMacAddress::OMacAddress( const unsigned char* p )
{
memcpy( _bytes, p, 6 );
}
OMacAddress::OMacAddress( struct ifreq& ifr )
{
memcpy( _bytes, ifr.ifr_hwaddr.sa_data, 6 );
}
OMacAddress::~OMacAddress()
{
}
//#ifdef QT_NO_DEBUG
//inline
//#endif
const unsigned char* OMacAddress::native() const
{
return (const unsigned char*) &_bytes;
}
OMacAddress OMacAddress::fromString( const QString& str )
{
QString addr( str );
unsigned char buf[6];
bool ok = true;
int index = 14;
for ( int i = 5; i >= 0; --i )
{
buf[i] = addr.right( 2 ).toUShort( &ok, 16 );
if ( !ok ) return OMacAddress::unknown;
addr.truncate( index );
index -= 3;
}
return (const unsigned char*) &buf;
}
QString OMacAddress::toString( bool substitute ) const
{
QString manu;
manu.sprintf( "%.2X:%.2X:%.2X", _bytes[0]&0xff, _bytes[1]&0xff, _bytes[2]&0xff );
QString serial;
serial.sprintf( ":%.2X:%.2X:%.2X", _bytes[3]&0xff, _bytes[4]&0xff, _bytes[5]&0xff );
if ( !substitute ) return manu+serial;
// fallback - if no vendor is found, just use the number
QString textmanu = OManufacturerDB::instance()->lookup( manu );
return textmanu.isNull() ? manu+serial : textmanu+serial;
}
QString OMacAddress::manufacturer() const
{
return OManufacturerDB::instance()->lookupExt( toString() );
}
bool operator==( const OMacAddress &m1, const OMacAddress &m2 )
{
return memcmp( &m1._bytes, &m2._bytes, 6 ) == 0;
}
/*======================================================================================
* OHostAddress
*======================================================================================*/
/*======================================================================================
* OPrivateIOCTL
*======================================================================================*/
OPrivateIOCTL::OPrivateIOCTL( QObject* parent, const char* name, int cmd, int getargs, int setargs )
:QObject( parent, name ), _ioctl( cmd ), _getargs( getargs ), _setargs( setargs )
{
}
OPrivateIOCTL::~OPrivateIOCTL()
{
}
int OPrivateIOCTL::numberGetArgs() const
{
return _getargs & IW_PRIV_SIZE_MASK;
}
int OPrivateIOCTL::typeGetArgs() const
{
return _getargs & IW_PRIV_TYPE_MASK >> 12;
}
int OPrivateIOCTL::numberSetArgs() const
{
return _setargs & IW_PRIV_SIZE_MASK;
}
int OPrivateIOCTL::typeSetArgs() const
{
return _setargs & IW_PRIV_TYPE_MASK >> 12;
}
void OPrivateIOCTL::invoke() const
{
( (OWirelessNetworkInterface*) parent() )->wioctl( _ioctl );
}
void OPrivateIOCTL::setParameter( int num, u_int32_t value )
{
u_int32_t* arglist = (u_int32_t*) &( (OWirelessNetworkInterface*) parent() )->_iwr.u.name;
arglist[num] = value;
}
+
+
+namespace Private {
/*======================================================================================
* assorted functions
*======================================================================================*/
void dumpBytes( const unsigned char* data, int num )
{
printf( "Dumping %d bytes @ %0x", num, data );
printf( "-------------------------------------------\n" );
for ( int i = 0; i < num; ++i )
{
printf( "%02x ", data[i] );
if ( !((i+1) % 32) ) printf( "\n" );
}
printf( "\n\n" );
}
int stringToMode( const QString& mode )
{
if ( mode == "auto" ) return IW_MODE_AUTO;
else if ( mode == "adhoc" ) return IW_MODE_ADHOC;
else if ( mode == "managed" ) return IW_MODE_INFRA;
else if ( mode == "master" ) return IW_MODE_MASTER;
else if ( mode == "repeater" ) return IW_MODE_REPEAT;
else if ( mode == "secondary" ) return IW_MODE_SECOND;
else if ( mode == "monitor" ) return IW_MODE_MONITOR;
else assert( 0 );
}
QString modeToString( int mode )
{
switch ( mode )
{
case IW_MODE_AUTO: return "auto";
case IW_MODE_ADHOC: return "adhoc";
case IW_MODE_INFRA: return "managed";
case IW_MODE_MASTER: return "master";
case IW_MODE_REPEAT: return "repeater";
case IW_MODE_SECOND: return "second";
case IW_MODE_MONITOR: return "monitor";
default: assert( 0 );
}
}
+}
+}
+}
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,181 +1,196 @@
/*
                This file is part of the Opie Project
              (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
=.
.=l.
           .>+-=
 _;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef ONETUTILS_H
#define ONETUTILS_H
#include <qdict.h>
#include <qmap.h>
#include <qstring.h>
#include <qhostaddress.h>
#include <qobject.h>
#include <sys/types.h>
struct ifreq;
+
+namespace Opie {
+namespace Net {
+
class OWirelessNetworkInterface;
/*======================================================================================
* OMacAddress
*======================================================================================*/
class OMacAddress
{
public:
// QString c'tor? -zecke
OMacAddress();
OMacAddress( unsigned char* );
OMacAddress( const unsigned char* );
OMacAddress( struct ifreq& );
~OMacAddress();
QString manufacturer() const;
QString toString( bool substitute = false ) const;
const unsigned char* native() const;
// no c'tor but this one why not make it a c'tor. it could also replace the others or is this the problem?
static OMacAddress fromString( const QString& );
public:
static const OMacAddress& broadcast; // ff:ff:ff:ff:ff:ff
static const OMacAddress& unknown; // 44:44:44:44:44:44
private:
unsigned char _bytes[6];
friend bool operator==( const OMacAddress &m1, const OMacAddress &m2 );
+ class Private;
+ Private *d;
};
bool operator==( const OMacAddress &m1, const OMacAddress &m2 );
/*======================================================================================
* OHostAddress
*======================================================================================*/
class OHostAddress : public QHostAddress
{
/*public:
OHostAddress();
~OHostAddress();
*/
+ private:
+ class Private;
+ Private *d;
};
/*======================================================================================
* OPrivateIOCTL
*======================================================================================*/
class OPrivateIOCTL : public QObject
{
public:
OPrivateIOCTL( QObject* parent, const char* name, int cmd, int getargs, int setargs );
~OPrivateIOCTL();
int numberGetArgs() const;
int typeGetArgs() const;
int numberSetArgs() const;
int typeSetArgs() const;
// FIXME return int? as ::ioctl does? -zecke
void invoke() const;
void setParameter( int, u_int32_t );
private:
u_int32_t _ioctl;
u_int16_t _getargs;
u_int16_t _setargs;
+ class Private;
+ Private *d;
};
/*======================================================================================
* Miscellaneous
*======================================================================================*/
+namespace Private {
void dumpBytes( const unsigned char* data, int num );
QString modeToString( int );
int stringToMode( const QString& );
+}
+}
+}
#define IW_PRIV_TYPE_MASK 0x7000
#define IW_PRIV_TYPE_NONE 0x0000
#define IW_PRIV_TYPE_BYTE 0x1000
#define IW_PRIV_TYPE_CHAR 0x2000
#define IW_PRIV_TYPE_INT 0x4000
#define IW_PRIV_TYPE_FLOAT 0x5000
#define IW_PRIV_TYPE_ADDR 0x6000
#define IW_PRIV_SIZE_FIXED 0x0800
#define IW_PRIV_SIZE_MASK 0x07FF
#ifndef ARPHRD_IEEE80211
#define ARPHRD_IEEE80211 801
#endif
#ifndef ARPHRD_IEEE80211_PRISM
#define ARPHRD_IEEE80211_PRISM 802
#endif
/* Network to host order macros */
#ifdef LBL_ALIGN
#define EXTRACT_16BITS(p) \
((u_int16_t)((u_int16_t)*((const u_int8_t *)(p) + 0) << 8 | \
(u_int16_t)*((const u_int8_t *)(p) + 1)))
#define EXTRACT_32BITS(p) \
((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 0) << 24 | \
(u_int32_t)*((const u_int8_t *)(p) + 1) << 16 | \
(u_int32_t)*((const u_int8_t *)(p) + 2) << 8 | \
(u_int32_t)*((const u_int8_t *)(p) + 3)))
#else
#define EXTRACT_16BITS(p) \
((u_int16_t)ntohs(*(const u_int16_t *)(p)))
#define EXTRACT_32BITS(p) \
((u_int32_t)ntohl(*(const u_int32_t *)(p)))
#endif
#define EXTRACT_24BITS(p) \
((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 0) << 16 | \
(u_int32_t)*((const u_int8_t *)(p) + 1) << 8 | \
(u_int32_t)*((const u_int8_t *)(p) + 2)))
/* Little endian protocol host order macros */
#define EXTRACT_LE_8BITS(p) (*(p))
#define EXTRACT_LE_16BITS(p) \
((u_int16_t)((u_int16_t)*((const u_int8_t *)(p) + 1) << 8 | \
(u_int16_t)*((const u_int8_t *)(p) + 0)))
#define EXTRACT_LE_32BITS(p) \
((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 3) << 24 | \
(u_int32_t)*((const u_int8_t *)(p) + 2) << 16 | \
(u_int32_t)*((const u_int8_t *)(p) + 1) << 8 | \
(u_int32_t)*((const u_int8_t *)(p) + 0)))
#endif // ONETUTILS_H
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
@@ -1,162 +1,168 @@
/*
                This file is part of the Opie Project
              Copyright (C) 2003-2004 by Michael 'Mickey' Lauer
=. <mickey@Vanille.de>
.=l.
           .>+-=
 _;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
/* OPIE */
#include <opie2/onetwork.h>
#include <opie2/ostation.h>
#include <opie2/odebug.h>
/* QT */
#include <qfile.h>
#include <qtextstream.h>
/* UNIX */
#include <assert.h>
#include <arpa/inet.h>
#include <errno.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <unistd.h>
#include <linux/sockios.h>
#include <net/if_arp.h>
#include <stdarg.h>
#ifndef NODEBUG
#include <opie2/odebugmapper.h>
+
+
+using namespace Opie::Core;
+using namespace Opie::Net::Private;
DebugMapper* debugmapper = new DebugMapper();
#endif
/*======================================================================================
* ONetwork
*======================================================================================*/
+namespace Opie {
+namespace Net {
ONetwork* ONetwork::_instance = 0;
ONetwork::ONetwork()
{
odebug << "ONetwork::ONetwork()" << oendl;
odebug << "ONetwork: This code has been compiled against Wireless Extensions V" << WIRELESS_EXT << oendl;
synchronize();
}
void ONetwork::synchronize()
{
// gather available interfaces by inspecting /proc/net/dev
//FIXME: we could use SIOCGIFCONF here, but we aren't interested in virtual (e.g. eth0:0) devices
//FIXME: Use SIOCGIFCONF anway, because we can disable listing of aliased devices
//FIXME: Best is use SIOCGIFCONF and if this doesn't work (result=-1), then fallback to parsing /proc/net/dev
_interfaces.clear();
QString str;
QFile f( "/proc/net/dev" );
bool hasFile = f.open( IO_ReadOnly );
if ( !hasFile )
{
odebug << "ONetwork: /proc/net/dev not existing. No network devices available" << oendl;
return;
}
QTextStream s( &f );
s.readLine();
s.readLine();
while ( !s.atEnd() )
{
s >> str;
str.truncate( str.find( ':' ) );
odebug << "ONetwork: found interface '" << str << "'" << oendl;
ONetworkInterface* iface;
if ( isWirelessInterface( str ) )
{
iface = new OWirelessNetworkInterface( this, (const char*) str );
odebug << "ONetwork: interface '" << str << "' has Wireless Extensions" << oendl;
}
else
{
iface = new ONetworkInterface( this, (const char*) str );
}
_interfaces.insert( str, iface );
s.readLine();
}
}
short ONetwork::wirelessExtensionVersion()
{
return WIRELESS_EXT;
}
int ONetwork::count() const
{
return _interfaces.count();
}
ONetworkInterface* ONetwork::interface( const QString& iface ) const
{
return _interfaces[iface];
}
ONetwork* ONetwork::instance()
{
if ( !_instance ) _instance = new ONetwork();
return _instance;
}
ONetwork::InterfaceIterator ONetwork::iterator() const
{
return ONetwork::InterfaceIterator( _interfaces );
}
bool ONetwork::isPresent( const char* name ) const
{
int sfd = socket( AF_INET, SOCK_STREAM, 0 );
struct ifreq ifr;
memset( &ifr, 0, sizeof( struct ifreq ) );
strcpy( (char*) &ifr.ifr_name, name );
int result = ::ioctl( sfd, SIOCGIFFLAGS, &ifr );
return result != -1;
}
bool ONetwork::isWirelessInterface( const char* name ) const
{
int sfd = socket( AF_INET, SOCK_STREAM, 0 );
struct iwreq iwr;
memset( &iwr, 0, sizeof( struct iwreq ) );
@@ -1144,96 +1150,99 @@ QString OWlanNGMonitoringInterface::name() const
void OWlanNGMonitoringInterface::setChannel( int c )
{
//NOTE: Older wlan-ng drivers automatically hopped channels while lnxreq_wlansniff=true. Newer ones don't.
QString enable = "true"; //_if->monitorMode() ? "true" : "false";
QString prism = _prismHeader ? "true" : "false";
QString cmd;
cmd.sprintf( "$(which wlanctl-ng) %s lnxreq_wlansniff channel=%d enable=%s prismheader=%s",
(const char*) _if->name(), c, (const char*) enable, (const char*) prism );
system( cmd );
}
/*======================================================================================
* OHostAPMonitoringInterface
*======================================================================================*/
OHostAPMonitoringInterface::OHostAPMonitoringInterface( ONetworkInterface* iface, bool prismHeader )
:OMonitoringInterface( iface, prismHeader )
{
iface->setMonitoring( this );
}
OHostAPMonitoringInterface::~OHostAPMonitoringInterface()
{
}
void OHostAPMonitoringInterface::setEnabled( bool b )
{
int monitorCode = _prismHeader ? 1 : 2;
if ( b )
{
_if->setPrivate( "monitor", 1, monitorCode );
}
else
{
_if->setPrivate( "monitor", 1, 0 );
}
}
QString OHostAPMonitoringInterface::name() const
{
return "hostap";
}
/*======================================================================================
* OOrinocoNetworkInterface
*======================================================================================*/
OOrinocoMonitoringInterface::OOrinocoMonitoringInterface( ONetworkInterface* iface, bool prismHeader )
:OMonitoringInterface( iface, prismHeader )
{
iface->setMonitoring( this );
}
OOrinocoMonitoringInterface::~OOrinocoMonitoringInterface()
{
}
void OOrinocoMonitoringInterface::setChannel( int c )
{
if ( !_if->hasPrivate( "monitor" ) )
{
this->OMonitoringInterface::setChannel( c );
}
else
{
int monitorCode = _prismHeader ? 1 : 2;
_if->setPrivate( "monitor", 2, monitorCode, c );
}
}
void OOrinocoMonitoringInterface::setEnabled( bool b )
{
if ( b )
{
setChannel( 1 );
}
else
{
_if->setPrivate( "monitor", 2, 0, 0 );
}
}
QString OOrinocoMonitoringInterface::name() const
{
return "orinoco";
}
+
+}
+}
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
@@ -1,559 +1,590 @@
/*
                This file is part of the Opie Project
              Copyright (C) 2003-2004 by Michael 'Mickey' Lauer
=. <mickey@Vanille.de>
.=l.
           .>+-=
 _;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef ONETWORK_H
#define ONETWORK_H
#if !defined( OPIE_WE_VERSION )
#error Need to define a wireless extension version to build against!
#endif
#if OPIE_WE_VERSION == 15
#include "wireless.15.h"
#endif
#if OPIE_WE_VERSION == 16
#include "wireless.16.h"
#endif
/* OPIE */
#include <opie2/onetutils.h>
#include <opie2/ostation.h>
/* QT */
#include <qvaluelist.h>
#include <qdict.h>
#include <qmap.h>
#include <qobject.h>
#include <qhostaddress.h>
+namespace Opie {
+namespace Net {
+
class ONetworkInterface;
class OWirelessNetworkInterface;
class OChannelHopper;
class OMonitoringInterface;
/*======================================================================================
* ONetwork
*======================================================================================*/
/**
* @brief A container class for all network interfaces
*
* This class provides access to all available network interfaces of your computer.
*
* @author Michael 'Mickey' Lauer <mickey@vanille.de>
*/
class ONetwork : public QObject
{
Q_OBJECT
public:
typedef QDict<ONetworkInterface> InterfaceMap;
typedef QDictIterator<ONetworkInterface> InterfaceIterator;
public:
/**
* @returns the number of available interfaces
*/
int count() const;
/**
* @returns a pointer to the (one and only) @ref ONetwork instance.
*/
static ONetwork* instance();
/**
* @returns an iterator usable for iterating through all network interfaces.
*/
InterfaceIterator iterator() const;
/**
* @returns true, if the @a interface is present.
*/
bool isPresent( const char* interface ) const;
/**
* @returns true, if the @a interface supports the wireless extension protocol.
*/
bool isWirelessInterface( const char* interface ) const;
/**
* @returns a pointer to the @ref ONetworkInterface object for the specified @a interface or 0, if not found.
* @see ONetworkInterface
*/
ONetworkInterface* interface( const QString& interface ) const;
/**
* @internal Rebuild the internal interface database
* @note Sometimes it might be useful to call this from client code,
* e.g. after issuing a cardctl insert
*/
void synchronize();
/**
* @returns the wireless extension version used at compile time.
**/
static short wirelessExtensionVersion();
protected:
ONetwork();
private:
static ONetwork* _instance;
InterfaceMap _interfaces;
+ class Private;
+ Private *d;
};
/*======================================================================================
* ONetworkInterface
*======================================================================================*/
/**
* @brief A network interface wrapper.
*
* This class provides a wrapper for a network interface. All the cumbersume details of
* Linux ioctls are hidden under a convenient high-level interface.
* @warning Most of the setting methods contained in this class require the appropriate
* process permissions to work.
*
* @author Michael 'Mickey' Lauer <mickey@vanille.de>
*/
class ONetworkInterface : public QObject
{
friend class OMonitoringInterface;
friend class OCiscoMonitoringInterface;
friend class OWlanNGMonitoringInterface;
friend class OHostAPMonitoringInterface;
friend class OOrinocoMonitoringInterface;
public:
/**
* Constructor. Normally you don't create @ref ONetworkInterface objects yourself,
* but access them via @ref ONetwork::interface().
*/
ONetworkInterface( QObject* parent, const char* name );
/**
* Destructor.
*/
virtual ~ONetworkInterface();
/**
* Associates a @a monitoring interface with this network interface.
* @note This is currently only useful with @ref OWirelessNetworkInterface objects.
*/
void setMonitoring( OMonitoringInterface* monitoring );
/**
* @returns the currently associated monitoring interface or 0, if no monitoring is associated.
*/
OMonitoringInterface* monitoring() const;
/**
* Setting an interface to promiscuous mode enables the device to receive
* all packets on the shared medium - as opposed to packets which are addressed to this interface.
*/
bool setPromiscuousMode( bool );
/**
* @returns true if the interface is set to promiscuous mode.
*/
bool promiscuousMode() const;
/**
* Setting an interface to up enables it to receive packets.
*/
bool setUp( bool );
/**
* @returns true if the interface is up.
*/
bool isUp() const;
/**
* @returns true if the interface is a loopback interface.
*/
bool isLoopback() const;
/**
* @returns true if the interface is featuring supports the wireless extension protocol.
*/
bool isWireless() const;
/**
* Associate the IP address @ addr with the interface.
*/
void setIPV4Address( const QHostAddress& addr );
/**
* @returns the IPv4 address associated with the interface.
*/
QString ipV4Address() const; //TODO: make this return an OHostAddress
/**
* Associate the MAC address @a addr with the interface.
* @note It can be necessary to shut down the interface prior to calling this method.
* @warning This is not supported by all drivers.
*/
void setMacAddress( const OMacAddress& addr );
/**
* @returns the MAC address associated with the interface.
*/
OMacAddress macAddress() const;
/**
* Associate the IPv4 @a netmask with the interface.
*/
void setIPV4Netmask( const QHostAddress& netmask );
/**
* @returns the IPv4 netmask associated with the interface.
*/
QString ipV4Netmask() const; //TODO: make this return an OHostAddress
/**
* @returns the data link type currently associated with the interface.
* @see #include <net/if_arp.h> for possible values.
*/
int dataLinkType() const;
protected:
const int _sfd;
mutable ifreq _ifr;
OMonitoringInterface* _mon;
protected:
struct ifreq& ifr() const;
virtual void init();
bool ioctl( int call ) const;
bool ioctl( int call, struct ifreq& ) const;
+ private:
+ class Private;
+ Private *d;
};
/*======================================================================================
* OChannelHopper
*======================================================================================*/
/**
* @brief A radio frequency channel hopper.
*
* This class provides a channel hopper for radio frequencies. A channel hopper frequently
* changes the radio frequency channel of its associated @ref OWirelessNetworkInterface.
* This is necessary when in monitoring mode and scanning for other devices, because
* the radio frequency hardware can only detect packets sent on the same frequency.
*
* @author Michael 'Mickey' Lauer <mickey@vanille.de>
*/
class OChannelHopper : public QObject
{
Q_OBJECT
public:
/**
* Constructor.
*/
OChannelHopper( OWirelessNetworkInterface* );
/**
* Destructor.
*/
virtual ~OChannelHopper();
/**
* @returns true, if the channel hopper is hopping channels
*/
bool isActive() const;
/**
* @returns the last hopped channel
*/
int channel() const;
/**
* Set the channel hopping @a interval.
* An interval of 0 deactivates the channel hopper.
*/
void setInterval( int interval );
/**
* @returns the channel hopping interval
*/
int interval() const;
signals:
/**
* This signal is emitted right after the channel hopper performed a hop
*/
void hopped( int );
protected:
virtual void timerEvent( QTimerEvent* );
private:
OWirelessNetworkInterface* _iface;
int _interval;
int _tid;
QValueList<int> _channels;
QValueList<int>::Iterator _channel;
+ class Private;
+ Private *d;
};
/*======================================================================================
* OWirelessNetworkInterface
*======================================================================================*/
/**
* @brief A network interface wrapper for interfaces supporting the wireless extensions protocol.
*
* This class provides a high-level encapsulation of the Linux wireless extension API.
*
* @author Michael 'Mickey' Lauer <mickey@vanille.de>
*/
class OWirelessNetworkInterface : public ONetworkInterface
{
friend class OMonitoringInterface;
friend class OCiscoMonitoringInterface;
friend class OWlanNGMonitoringInterface;
friend class OHostAPMonitoringInterface;
friend class OOrinocoMonitoringInterface;
friend class OPrivateIOCTL;
public:
/**
* Constructor.
*/
OWirelessNetworkInterface( QObject* parent, const char* name );
/**
* Destructor.
*/
virtual ~OWirelessNetworkInterface();
/**
* Setting the @a channel of the interface changes the radio frequency (RF)
* of the corresponding wireless network device.
* @note Common channel range is within [1-14]. A value of 0 is not allowed.
* @see channels()
*/
virtual void setChannel( int channel ) const;
/**
* @returns the channel index of the current radio frequency.
*/
virtual int channel() const;
/**
* @returns the current radio frequency (in MHz).
*/
virtual double frequency() const;
/**
* @returns the number of radio frequency channels for the
* corresponding wireless network device.
* @note European devices usually have 14 channels, while American typically feature 11 channels.
*/
virtual int channels() const;
/**
* Set the IEEE 802.11 operation @a mode.
* Valid values are <ul><li>adhoc<li>managed<li>monitor<li>master
* @warning Not all drivers support the all modes.
* @note You might have to change the SSID to get the operation mode change into effect.
*/
virtual void setMode( const QString& mode );
/**
* @returns the current IEEE 802.11 operation mode.
* Possible values are <ul><li>adhoc<li>managed<li>monitor<li>master or <li>unknown
*
* @note: Important note concerning the 'monitor' mode:
* Setting the monitor mode on a wireless network interface enables
* listening to IEEE 802.11 data and management frames which normally
* are handled by the device firmware. This can be used to detect
* other wireless network devices, e.g. Access Points or Ad-hoc stations.
* @warning Standard wireless network drives don't support the monitor mode.
* @warning You need a patched driver for this to work.
* @note Enabling the monitor mode is highly driver dependent and requires
* the proper @ref OMonitoringInterface to be associated with the interface.
* @see OMonitoringInterface
*/
virtual QString mode() const;
/**
* Set the channel hopping @a interval. An @a interval of 0 disables channel hopping.
* @see OChannelHopper
*/
virtual void setChannelHopping( int interval = 0 );
/**
* @returns the channel hopping interval or 0, if channel hopping is disabled.
*/
virtual int channelHopping() const;
/**
* @returns the @ref OChannelHopper of this interface or 0, if channel hopping has not been activated before
*/
virtual OChannelHopper* channelHopper() const;
/**
* Set the station @a nickname.
*/
virtual void setNickName( const QString& nickname );
/**
* @returns the current station nickname.
*/
virtual QString nickName() const;
/**
* Invoke the private IOCTL @a command with a @number of parameters on the network interface.
* @see OPrivateIOCTL
*/
virtual void setPrivate( const QString& command, int number, ... );
/**
* @returns true if the interface is featuring the private IOCTL @command.
*/
virtual bool hasPrivate( const QString& command );
virtual void getPrivate( const QString& command ); //FIXME: Implement and document this
/**
* @returns true if the interface is associated to an access point
* @note: This information is only valid if the interface is in managed mode.
*/
virtual bool isAssociated() const;
/**
* @returns the MAC address of the Access Point if the device is in infrastructure mode.
* @returns a (more or less random) cell ID address if the device is in adhoc mode.
*/
virtual OMacAddress associatedAP() const;
/**
* Set the @a ssid (Service Set ID) string. This is used to decide
* which network to associate with (use "any" to let the driver decide).
*/
virtual void setSSID( const QString& ssid );
/**
* @returns the current SSID (Service Set ID).
*/
virtual QString SSID() const;
/**
* Perform scanning the wireless network neighbourhood.
* @note: UNSTABLE API - UNDER CONSTRUCTION - DON'T USE!
*/
virtual OStationList* scanNetwork();
/**
* @return signal strength to associated neighbour (in percent).
* In infrastructure mode, this is the signal strength of the Access Point.
* In other modes the result is driver dependent.
*/
virtual int signalStrength() const;
/** @internal commit pending changes to the driver
*
*/
void commit() const;
protected:
void buildInformation();
void buildPrivateList();
void dumpInformation() const;
virtual void init();
struct iwreq& iwr() const;
bool wioctl( int call ) const;
bool wioctl( int call, struct iwreq& ) const;
protected:
mutable struct iwreq _iwr;
QMap<int,int> _channels;
struct iw_range _range;
private:
OChannelHopper* _hopper;
+ class Private;
+ Private *d;
};
/*======================================================================================
* OMonitoringInterface
*======================================================================================*/
class OMonitoringInterface
{
public:
OMonitoringInterface();
OMonitoringInterface( ONetworkInterface*, bool _prismHeader );
virtual ~OMonitoringInterface();
public:
virtual void setEnabled( bool );
virtual void setChannel( int );
virtual QString name() const = 0;
protected:
OWirelessNetworkInterface* _if;
bool _prismHeader;
+ private:
+ class Private;
+ Private *d;
};
/*======================================================================================
* OCiscoMonitoring
*======================================================================================*/
class OCiscoMonitoringInterface : public OMonitoringInterface
{
public:
OCiscoMonitoringInterface( ONetworkInterface*, bool _prismHeader );
virtual ~OCiscoMonitoringInterface();
virtual void setEnabled( bool );
virtual QString name() const;
virtual void setChannel( int );
+ private:
+ class Private;
+ Private *d;
};
/*======================================================================================
* OWlanNGMonitoringInterface
*======================================================================================*/
class OWlanNGMonitoringInterface : public OMonitoringInterface
{
public:
OWlanNGMonitoringInterface( ONetworkInterface*, bool _prismHeader );
virtual ~OWlanNGMonitoringInterface();
public:
virtual void setEnabled( bool );
virtual QString name() const;
virtual void setChannel( int );
+ private:
+ class Private;
+ Private *d;
};
/*======================================================================================
* OHostAPMonitoringInterface
*======================================================================================*/
class OHostAPMonitoringInterface : public OMonitoringInterface
{
public:
OHostAPMonitoringInterface( ONetworkInterface*, bool _prismHeader );
virtual ~OHostAPMonitoringInterface();
public:
virtual void setEnabled( bool );
virtual QString name() const;
+
+ private:
+ class Private;
+ Private *d;
};
/*======================================================================================
* OOrinocoMonitoringInterface
*======================================================================================*/
class OOrinocoMonitoringInterface : public OMonitoringInterface
{
public:
OOrinocoMonitoringInterface( ONetworkInterface*, bool _prismHeader );
virtual ~OOrinocoMonitoringInterface();
public:
virtual void setChannel( int );
virtual void setEnabled( bool );
virtual QString name() const;
+ private:
+ class Private;
+ Private *d;
};
+}
+}
+
#endif // ONETWORK_H
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,143 +1,148 @@
/*
                This file is part of the Opie Project
              Copyright (C) 2003 by Michael 'Mickey' Lauer <mickey@Vanille.de>
=.
.=l.
           .>+-=
 _;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
/* OPIE */
#include <opie2/opcap.h>
#include <opie2/odebug.h>
/* QT */
#include <qapplication.h> // don't use oapplication here (will decrease reusability in other projects)
#include <qsocketnotifier.h>
#include <qobjectlist.h>
/* SYSTEM */
#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>
/* LOCAL */
#include "udp_ports.h"
+using namespace Opie::Core;
+
+namespace Opie {
+namespace Net {
+
/*======================================================================================
* OPacket
*======================================================================================*/
OPacket::OPacket( int datalink, packetheaderstruct header, const unsigned char* data, QObject* parent )
:QObject( parent, "Generic" ), _hdr( header ), _data( data )
{
//qDebug( "OPacket::OPacket(): (Len %d, CapLen %d)" /*, ctime((const time_t*) header.ts.tv_sec)*/, header.len, header.caplen );
_end = (unsigned char*) data + header.len;
//qDebug( "OPacket::data @ %0x, end @ %0x", data, _end );
switch ( datalink )
{
case DLT_EN10MB:
odebug << "OPacket::OPacket(): Received Packet. Datalink = ETHERNET" << oendl;
new OEthernetPacket( _end, (const struct ether_header*) data, this );
break;
case DLT_IEEE802_11:
odebug << "OPacket::OPacket(): Received Packet. Datalink = IEEE802.11" << oendl;
new OWaveLanPacket( _end, (const struct ieee_802_11_header*) data, this );
break;
case DLT_PRISM_HEADER:
odebug << "OPacket::OPacket(): Received Packet. Datalink = PRISM_HEADER" << oendl;
new OPrismHeaderPacket( _end, (const struct prism_hdr*) (unsigned char*) data, this );
break;
default:
owarn << "OPacket::OPacket(): Received Packet over unsupported datalink, type " << datalink << "!" << oendl;
}
}
OPacket::~OPacket()
{
}
timevalstruct OPacket::timeval() const
{
return _hdr.ts;
}
int OPacket::caplen() const
{
return _hdr.caplen;
}
void OPacket::updateStats( QMap<QString,int>& stats, QObjectList* l )
{
if (!l) return;
QObject* o = l->first();
while ( o )
{
stats[o->name()]++;
updateStats( stats, const_cast<QObjectList*>( o->children() ) );
o = l->next();
}
}
QString OPacket::dumpStructure() const
{
return "[ |" + _dumpStructure( const_cast<QObjectList*>( this->children() ) ) + " ]";
}
QString OPacket::_dumpStructure( QObjectList* l ) const
{
if (!l) return QString::null;
QObject* o = l->first();
QString str(" ");
while ( o )
{
str.append( o->name() );
str.append( " |" );
str += _dumpStructure( const_cast<QObjectList*>( o->children() ) );
o = l->next();
}
return str;
}
QString OPacket::dump( int bpl ) const
{
static int index = 0;
index++;
int len = _hdr.caplen;
QString str;
str.sprintf( "\n<----- Packet #%04d Len = 0x%X (%d) ----->\n\n", index, len, len );
str.append( "0000: " );
QString tmp;
@@ -1251,97 +1256,98 @@ bool OPacketCapturer::openDumpFile( const QString& filename )
if ( !dump )
{
owarn << "OPacketCapturer::open(): can't open dump with '" << filename << "': " << _errbuf << oendl;
return false;
}
odebug << "OPacketCapturer::open(): dump [" << filename << "] opened successfully." << oendl;
_pcd = dump;
return true;
}
bool OPacketCapturer::open( const QFile& file )
{
QString name = file.name();
if ( _open )
{
close();
if ( name == _name ) // ignore opening an already openend device
{
return true;
}
else // close the last opened device
{
close();
}
}
_name = name;
pcap_t* handle = pcap_open_offline( const_cast<char*>( (const char*) name ), &_errbuf[0] );
if ( handle )
{
odebug << "OPacketCapturer::open(): libpcap opened successfully." << oendl;
_pch = handle;
_open = true;
// in case we have an application object, create a socket notifier
if ( qApp )
{
_sn = new QSocketNotifier( fileno(), QSocketNotifier::Read );
connect( _sn, SIGNAL( activated(int) ), this, SLOT( readyToReceive() ) );
}
return true;
}
else
{
odebug << "OPacketCapturer::open(): can't open libpcap with '" << name << "': " << _errbuf << oendl;
return false;
}
}
bool OPacketCapturer::isOpen() const
{
return _open;
}
void OPacketCapturer::readyToReceive()
{
odebug << "OPacketCapturer::readyToReceive(): about to emit 'receivePacket(p)'" << oendl;
OPacket* p = next();
emit receivedPacket( p );
// emit is synchronous - packet has been dealt with, now it's safe to delete
delete p;
}
const QMap<QString,int>& OPacketCapturer::statistics() const
{
return _stats;
}
int OPacketCapturer::snapShot() const
{
return pcap_snapshot( _pch );
}
bool OPacketCapturer::swapped() const
{
return pcap_is_swapped( _pch );
}
QString OPacketCapturer::version() const
{
return QString().sprintf( "%d.%d", pcap_major_version( _pch ), pcap_minor_version( _pch ) );
}
-
+}
+}
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
@@ -1,671 +1,721 @@
/*
                This file is part of the Opie Project
              Copyright (C) 2003 by Michael 'Mickey' Lauer <mickey@Vanille.de>
=.
.=l.
           .>+-=
 _;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef OPCAP_H
#define OPCAP_H
/* OPIE */
#include <opie2/onetutils.h>
/* QT */
#include <qevent.h>
#include <qfile.h>
#include <qhostaddress.h>
#include <qobject.h>
#include <qstring.h>
#include <qtextstream.h>
#include <qmap.h>
/* STD */
extern "C" // work around a bpf/pcap conflict in recent headers
{
#include <pcap.h>
}
#include <netinet/ether.h>
#include <netinet/ip.h>
#include <netinet/udp.h>
#include <netinet/tcp.h>
#include <time.h>
/* Custom Network Includes (must go here, don't reorder!) */
#include "802_11_user.h"
#include "dhcp.h"
/* TYPEDEFS */
typedef struct timeval timevalstruct;
typedef struct pcap_pkthdr packetheaderstruct;
/* FORWARDS */
-class OPacketCapturer;
class QSocketNotifier;
+namespace Opie {
+namespace Net {
+class OPacketCapturer;
/*======================================================================================
* OPacket - A frame on the wire
*======================================================================================*/
/** @brief A class representing a data frame on the wire.
*
* The whole family of the packet classes are used when capturing frames from a network.
* Most standard network protocols in use share a common architecture, which mostly is
* a packet header and then the packet payload. In layered architectures, each lower layer
* encapsulates data from its upper layer - that is it
* treats the data from its upper layer as payload and prepends an own header to the packet,
* which - again - is treated as the payload for the layer below. The figure below is an
* example for how such a data frame is composed out of packets, e.g. when sending a mail.
*
* <pre>
* | User Data | == Mail Data
* | SMTP Header | User Data | == SMTP
* | TCP Header | SMTP Header | User Data | == TCP
* | IP Header | TCP Header | SMTP Header | User Data | == IP
* | MAC Header | IP Header | TCP Header | SMTP Header | User Data | == MAC
*
* </pre>
*
* The example is trimmed for simplicity, because the MAC (Medium Access Control) layer
* also contains a few more levels of encapsulation.
* Since the type of the payload is more or less independent from the encapsulating protocol,
* the header must be inspected before attempting to decode the payload. Hence, the
* encapsulation level varies and can't be deduced without actually looking into the packets.
*
* For actually working with captured frames, it's useful to identify the packets via names and
* insert them into a parent/child - relationship based on the encapsulation. This is why
* all packet classes derive from QObject. The amount of overhead caused by the QObject is
* not a problem in this case, because we're talking about a theoratical maximum of about
* 10 packets per captured frame. We need to stuff them into a searchable list anyway and the
* QObject also cares about destroying the sub-, (child-) packets.
*
* This enables us to perform a simple look for packets of a certain type:
* @code
* OPacketCapturer* pcap = new OPacketCapturer();
* pcap->open( "eth0" );
* OPacket* p = pcap->next();
* OIPPacket* ip = (OIPPacket*) p->child( "IP" ); // returns 0, if no such child exists
* odebug << "got ip packet from " << ip->fromIPAddress().toString() << " to " << ip->toIPAddress().toString() << oendl;
*
*/
class OPacket : public QObject
{
Q_OBJECT
friend class OPacketCapturer;
friend QTextStream& operator<<( QTextStream& s, const OPacket& p );
public:
OPacket( int datalink, packetheaderstruct, const unsigned char*, QObject* parent );
virtual ~OPacket();
timevalstruct timeval() const;
int caplen() const;
int len() const;
QString dump( int = 32 ) const;
void updateStats( QMap<QString,int>&, QObjectList* );
private:
QString dumpStructure() const;
QString _dumpStructure( QObjectList* ) const;
private:
const packetheaderstruct _hdr; // pcap packet header
const unsigned char* _data; // pcap packet data
const unsigned char* _end; // end of pcap packet data
+ private:
+ class Private;
+ Private *d;
};
QTextStream& operator<<( QTextStream& s, const OPacket& p );
/*======================================================================================
* OEthernetPacket - DLT_EN10MB frame
*======================================================================================*/
class OEthernetPacket : public QObject
{
Q_OBJECT
public:
OEthernetPacket( const unsigned char*, const struct ether_header*, QObject* parent = 0 );
virtual ~OEthernetPacket();
OMacAddress sourceAddress() const;
OMacAddress destinationAddress() const;
int type() const;
private:
const struct ether_header* _ether;
+ private:
+ class Private;
+ Private *d;
};
/*======================================================================================
* OPrismHeaderPacket - DLT_PRISM_HEADER frame
*======================================================================================*/
class OPrismHeaderPacket : public QObject
{
Q_OBJECT
public:
OPrismHeaderPacket( const unsigned char*, const struct prism_hdr*, QObject* parent = 0 );
virtual ~OPrismHeaderPacket();
unsigned int signalStrength() const;
private:
const struct prism_hdr* _header;
+ class Private;
+ Private *d;
};
/*======================================================================================
* OWaveLanPacket - DLT_IEEE802_11 frame
*======================================================================================*/
class OWaveLanPacket : public QObject
{
Q_OBJECT
public:
OWaveLanPacket( const unsigned char*, const struct ieee_802_11_header*, QObject* parent = 0 );
virtual ~OWaveLanPacket();
int duration() const;
bool fromDS() const;
bool toDS() const;
virtual OMacAddress macAddress1() const;
virtual OMacAddress macAddress2() const;
virtual OMacAddress macAddress3() const;
virtual OMacAddress macAddress4() const;
bool usesPowerManagement() const;
int type() const;
int subType() const;
int version() const;
bool usesWep() const;
private:
const struct ieee_802_11_header* _wlanhdr;
+ class Private;
+ Private *d;
};
/*======================================================================================
* OWaveLanManagementPacket - type: management (T_MGMT)
*======================================================================================*/
class OWaveLanManagementPacket : public QObject
{
Q_OBJECT
public:
OWaveLanManagementPacket( const unsigned char*, const struct ieee_802_11_mgmt_header*, OWaveLanPacket* parent = 0 );
virtual ~OWaveLanManagementPacket();
QString managementType() const;
int beaconInterval() const;
int capabilities() const; // generic
bool canESS() const;
bool canIBSS() const;
bool canCFP() const;
bool canCFP_REQ() const;
bool canPrivacy() const;
private:
const struct ieee_802_11_mgmt_header* _header;
const struct ieee_802_11_mgmt_body* _body;
+ class Private;
+ Private *d;
};
/*======================================================================================
* OWaveLanManagementSSID
*======================================================================================*/
class OWaveLanManagementSSID : public QObject
{
Q_OBJECT
public:
OWaveLanManagementSSID( const unsigned char*, const struct ssid_t*, QObject* parent = 0 );
virtual ~OWaveLanManagementSSID();
QString ID( bool decloak = false ) const;
private:
const struct ssid_t* _data;
+ class Private;
+ Private *d;
};
/*======================================================================================
* OWaveLanManagementRates
*======================================================================================*/
class OWaveLanManagementRates : public QObject
{
Q_OBJECT
public:
OWaveLanManagementRates( const unsigned char*, const struct rates_t*, QObject* parent = 0 );
virtual ~OWaveLanManagementRates();
private:
const struct rates_t* _data;
+ class Private;
+ Private *d;
};
/*======================================================================================
* OWaveLanManagementCF
*======================================================================================*/
class OWaveLanManagementCF : public QObject
{
Q_OBJECT
public:
OWaveLanManagementCF( const unsigned char*, const struct cf_t*, QObject* parent = 0 );
virtual ~OWaveLanManagementCF();
private:
const struct cf_t* _data;
+ class Private;
+ Private *d;
};
/*======================================================================================
* OWaveLanManagementFH
*======================================================================================*/
class OWaveLanManagementFH : public QObject
{
Q_OBJECT
public:
OWaveLanManagementFH( const unsigned char*, const struct fh_t*, QObject* parent = 0 );
virtual ~OWaveLanManagementFH();
private:
const struct fh_t* _data;
+ class Private;
+ Private *d;
};
/*======================================================================================
* OWaveLanManagementDS
*======================================================================================*/
class OWaveLanManagementDS : public QObject
{
Q_OBJECT
public:
OWaveLanManagementDS( const unsigned char*, const struct ds_t*, QObject* parent = 0 );
virtual ~OWaveLanManagementDS();
int channel() const;
private:
const struct ds_t* _data;
+ class Private;
+ Private *d;
};
/*======================================================================================
* OWaveLanManagementTim
*======================================================================================*/
class OWaveLanManagementTim : public QObject
{
Q_OBJECT
public:
OWaveLanManagementTim( const unsigned char*, const struct tim_t*, QObject* parent = 0 );
virtual ~OWaveLanManagementTim();
private:
const struct tim_t* _data;
+ class Private;
+ Private *d;
};
/*======================================================================================
* OWaveLanManagementIBSS
*======================================================================================*/
class OWaveLanManagementIBSS : public QObject
{
Q_OBJECT
public:
OWaveLanManagementIBSS( const unsigned char*, const struct ibss_t*, QObject* parent = 0 );
virtual ~OWaveLanManagementIBSS();
private:
const struct ibss_t* _data;
+ class Private;
+ Private *d;
};
/*======================================================================================
* OWaveLanManagementChallenge
*======================================================================================*/
class OWaveLanManagementChallenge : public QObject
{
Q_OBJECT
public:
OWaveLanManagementChallenge( const unsigned char*, const struct challenge_t*, QObject* parent = 0 );
virtual ~OWaveLanManagementChallenge();
private:
const struct challenge_t* _data;
+ class Private;
+ Private *d;
};
/*======================================================================================
* OWaveLanDataPacket - type: data (T_DATA)
*======================================================================================*/
class OWaveLanDataPacket : public QObject
{
Q_OBJECT
public:
OWaveLanDataPacket( const unsigned char*, const struct ieee_802_11_data_header*, OWaveLanPacket* parent = 0 );
virtual ~OWaveLanDataPacket();
private:
const struct ieee_802_11_data_header* _header;
+ class Private;
+ Private *d;
};
/*======================================================================================
* OWaveLanControlPacket - type: control (T_CTRL)
*======================================================================================*/
class OWaveLanControlPacket : public QObject
{
Q_OBJECT
public:
OWaveLanControlPacket( const unsigned char*, const struct ieee_802_11_control_header*, OWaveLanPacket* parent = 0 );
virtual ~OWaveLanControlPacket();
QString controlType() const;
private:
const struct ieee_802_11_control_header* _header;
+ class Private;
+ Private *d;
};
/*======================================================================================
* OLLCPacket - IEEE 802.2 Link Level Control
*======================================================================================*/
class OLLCPacket : public QObject
{
Q_OBJECT
public:
OLLCPacket( const unsigned char*, const struct ieee_802_11_802_2_header* data, QObject* parent = 0 );
virtual ~OLLCPacket();
private:
const struct ieee_802_11_802_2_header* _header;
+ class Private;
+ Private *d;
};
/*======================================================================================
* OIPPacket
*======================================================================================*/
class OIPPacket : public QObject
{
Q_OBJECT
public:
OIPPacket( const unsigned char*, const struct iphdr*, QObject* parent = 0 );
virtual ~OIPPacket();
QHostAddress fromIPAddress() const;
QHostAddress toIPAddress() const;
int tos() const;
int len() const;
int id() const;
int offset() const;
int ttl() const;
int protocol() const;
int checksum() const;
private:
const struct iphdr* _iphdr;
+ class Private;
+ Private *d;
};
/*======================================================================================
* OARPPacket
*======================================================================================*/
class OARPPacket : public QObject
{
Q_OBJECT
public:
OARPPacket( const unsigned char*, const struct myarphdr*, QObject* parent = 0 );
virtual ~OARPPacket();
QHostAddress senderIPV4Address() const;
OMacAddress senderMacAddress() const;
QHostAddress targetIPV4Address() const;
OMacAddress targetMacAddress() const;
//int type() const;
QString type() const;
private:
const struct myarphdr* _arphdr;
+ class Private;
+ Private *d;
};
/*======================================================================================
* OUDPPacket
*======================================================================================*/
class OUDPPacket : public QObject
{
Q_OBJECT
public:
OUDPPacket( const unsigned char*, const struct udphdr*, QObject* parent = 0 );
virtual ~OUDPPacket();
int fromPort() const;
int toPort() const;
int length() const;
int checksum() const;
private:
const struct udphdr* _udphdr;
+ class Private;
+ Private *d;
};
/*======================================================================================
* ODHCPPacket
*======================================================================================*/
class ODHCPPacket : public QObject
{
Q_OBJECT
public:
ODHCPPacket( const unsigned char*, const struct dhcp_packet*, QObject* parent = 0 );
virtual ~ODHCPPacket();
QHostAddress clientAddress() const;
QHostAddress yourAddress() const;
QHostAddress serverAddress() const;
QHostAddress relayAddress() const;
OMacAddress clientMacAddress() const;
bool isRequest() const;
bool isReply() const;
QString type() const;
private:
const struct dhcp_packet* _dhcphdr;
unsigned char _type;
+ class Private;
+ Private *d;
};
/*======================================================================================
* OTCPPacket
*======================================================================================*/
class OTCPPacket : public QObject
{
Q_OBJECT
public:
OTCPPacket( const unsigned char*, const struct tcphdr*, QObject* parent = 0 );
virtual ~OTCPPacket();
int fromPort() const;
int toPort() const;
int seq() const;
int ack() const;
int window() const;
int checksum() const;
private:
const struct tcphdr* _tcphdr;
+ class Private;
+ Private *d;
};
/*======================================================================================
* OPacketCapturer
*======================================================================================*/
/**
* @brief A class based wrapper for network packet capturing.
*
* This class is the base of a high-level interface to the well known packet capturing
* library libpcap.
* @see http://tcpdump.org
*/
class OPacketCapturer : public QObject
{
Q_OBJECT
public:
/**
* Constructor.
*/
OPacketCapturer( QObject* parent = 0, const char* name = 0 );
/**
* Destructor.
*/
~OPacketCapturer();
/**
* Set the packet capturer to use blocking or non-blocking IO. This can be useful when
* not using the socket notifier, e.g. without an application object.
*/
void setBlocking( bool );
/**
* @returns true if the packet capturer uses blocking IO calls.
*/
bool blocking() const;
/**
* Close the packet capturer. This is automatically done in the destructor.
*/
void close();
/**
* Close the output capture file.
*/
void closeDumpFile();
/**
* @returns the data link type.
* @see <pcap.h> for possible values.
*/
int dataLink() const;
/**
* Dump a packet to the output capture file.
*/
void dump( OPacket* );
/**
* @returns the file descriptor of the packet capturer. This is only useful, if
* not using the socket notifier, e.g. without an application object.
*/
int fileno() const;
/**
* @returns the next @ref OPacket from the packet capturer.
* @note If blocking mode is true then this call might block.
*/
OPacket* next();
/**
* @returns the next @ref OPacket from the packet capturer, if
* one arrives within @a time milliseconds.
*/
OPacket* next( int time );
/**
* Open the packet capturer to capture packets in live-mode from @a interface.
*/
bool open( const QString& interface );
/**
* Open the packet capturer to capture packets in offline-mode from @a file.
*/
bool open( const QFile& file );
/**
* Open a prerecorded tcpdump compatible capture file for use with @ref dump()
*/
bool openDumpFile( const QString& filename );
/**
* @returns true if the packet capturer is open
*/
bool isOpen() const;
/**
* @returns the snapshot length of this packet capturer
*/
int snapShot() const;
/**
* @returns true if the input capture file has a different byte-order
* than the byte-order of the running system.
*/
bool swapped() const;
/**
* @returns the libpcap version string used to write the input capture file.
*/
QString version() const;
/**
* @returns the packet statistic database.
* @see QMap
*/
const QMap<QString,int>& statistics() const;
signals:
/**
* This signal is emitted, when a packet has been received.
*/
void receivedPacket( OPacket* );
protected slots:
void readyToReceive();
protected:
QString _name; // devicename
bool _open; // check this before doing pcap calls
pcap_t* _pch; // pcap library handle
pcap_dumper_t* _pcd; // pcap dumper handle
QSocketNotifier* _sn; // socket notifier for main loop
mutable char _errbuf[PCAP_ERRBUF_SIZE]; // holds error strings from libpcap
QMap<QString, int> _stats; // statistics;
+ class Private; // Private Forward declaration
+ Private *d; // if we need to add data
};
+}
+}
#endif // OPCAP_H
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 @@
/*
                This file is part of the Opie Project
              Copyright (C) 2003 by Michael 'Mickey' Lauer <mickey@Vanille.de>
=.
.=l.
           .>+-=
 _;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include <opie2/ostation.h>
#include <opie2/odebug.h>
+
+using namespace Opie::Core;
+
+namespace Opie {
+namespace Net {
/*======================================================================================
* OStation
*======================================================================================*/
OStation::OStation()
{
odebug << "OStation::OStation()" << oendl;
type = "<unknown>";
macAddress = OMacAddress::unknown;
ssid = "<unknown>";
channel = 0;
apAddress = OMacAddress::unknown;
}
OStation::~OStation()
{
odebug << "OStation::~OStation()" << oendl;
}
void OStation::dump()
{
odebug << "------- OStation::dump() ------------" << oendl;
qDebug( "type: %s", (const char*) type );
qDebug( "mac: %s", (const char*) macAddress.toString() );
qDebug( "ap: %s", (const char*) apAddress.toString() );
qDebug( "ip: %s", (const char*) ipAddress.toString() );
}
+
+}
+} \ 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 @@
/*
                This file is part of the Opie Project
              Copyright (C) 2003 by Michael 'Mickey' Lauer <mickey@Vanille.de>
=.
.=l.
           .>+-=
 _;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef OSTATION_H
#define OSTATION_H
#include <opie2/onetutils.h>
#include <qlist.h>
#include <qstring.h>
#include <qhostaddress.h>
#include <qobject.h>
#include <sys/types.h>
+namespace Opie {
+namespace Net {
+
class OStation;
+
typedef QList<OStation> OStationList;
/*======================================================================================
* OStation
*======================================================================================*/
class OStation
{
public:
OStation();
~OStation();
void dump();
/* Ethernet */
QString type;
OMacAddress macAddress;
QHostAddress ipAddress;
/* WaveLan */
QString ssid;
OMacAddress apAddress;
int channel;
bool encrypted;
+ private:
+ class Private;
+ Private *d;
};
+}
+}
#endif // OSTATION_H
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 @@
SOURCES += core/backends/ocontactaccessbackend_sql.cpp \
core/backends/ocontactaccessbackend_vcard.cpp \
core/backends/ocontactaccessbackend_xml.cpp \
core/backends/ocontactaccess.cpp \
core/backends/odatebookaccessbackend.cpp \
core/backends/odatebookaccessbackend_xml.cpp \
core/backends/otodoaccessbackend.cpp \
core/backends/otodoaccess.cpp \
core/backends/otodoaccesssql.cpp \
core/backends/otodoaccessvcal.cpp \
core/backends/otodoaccessxml.cpp \
core/backends/odatebookaccess.cpp \
- core/backends/odatebookaccessbackend_sql.cpp
+ core/backends/odatebookaccessbackend_sql.cpp \
+ core/backends/private/xmltree.cc
HEADERS += core/backends/obackendfactory.h \
core/backends/ocontactaccessbackend.h \
core/backends/ocontactaccessbackend_sql.h \
core/backends/ocontactaccessbackend_vcard.h \
core/backends/ocontactaccessbackend_xml.h \
core/backends/ocontactaccess.h \
core/backends/odatebookaccessbackend.h \
core/backends/odatebookaccessbackend_sql.h \
core/backends/odatebookaccessbackend_xml.h \
core/backends/opimaccessbackend.h \
core/backends/opimaccesstemplate.h \
core/backends/otodoaccessbackend.h \
core/backends/otodoaccess.h \
core/backends/otodoaccesssql.h \
core/backends/otodoaccessvcal.h \
core/backends/otodoaccessxml.h \
- core/backends/odatebookaccess.h
+ core/backends/odatebookaccess.h \
+ 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,145 +1,145 @@
/*
This file is part of the Opie Project
Copyright (C) The Main Author <main-author@whereever.org>
=. Copyright (C) The Opie Team <opie-devel@handhelds.org>
.=l.
.>+-=
_;:, .> :=|. This program is free software; you can
.> <`_, > . <= redistribute it and/or modify it under
:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
.="- .-=="i, .._ License as published by the Free Software
- . .-<_> .<> Foundation; either version 2 of the License,
._= =} : or (at your option) any later version.
.%`+i> _;_.
.i_,=:_. -<s. This program is distributed in the hope that
+ . -:. = it will be useful, but WITHOUT ANY WARRANTY;
: .. .:, . . . without even the implied warranty of
=_ + =;=|` MERCHANTABILITY or FITNESS FOR A
_.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.= = ; Library General Public License for more
++= -. .` .: details.
: = ...= . :.=-
-. .:....=;==+<; You should have received a copy of the GNU
-_. . . )=. = Library General Public License along with
-- :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
/*
* SQL Backend for the OPIE-Contact Database.
*/
#include "ocontactaccessbackend_sql.h"
#include <qarray.h>
#include <qdatetime.h>
#include <qstringlist.h>
#include <qpe/global.h>
#include <qpe/recordfields.h>
#include <opie2/opimcontactfields.h>
#include <opie2/opimdateconversion.h>
#include <opie2/osqldriver.h>
#include <opie2/osqlresult.h>
#include <opie2/osqlmanager.h>
#include <opie2/osqlquery.h>
-
+using namespace Opie::DB;
// If defined, we use a horizontal table ( uid, attr1, attr2, attr3, ..., attrn ) instead
// vertical like "uid, type, value".
// DON'T DEACTIVATE THIS DEFINE IN PRODUCTIVE ENVIRONMENTS !!
#define __STORE_HORIZONTAL_
// Distinct loading is not very fast. If I expect that every person has just
// one (and always one) 'Last Name', I can request all uid's for existing lastnames,
// which is faster..
// But this may not be true for all entries, like company contacts..
// The current AddressBook application handles this problem, but other may not.. (eilers)
#define __USE_SUPERFAST_LOADQUERY
/*
* Implementation of used query types
* CREATE query
* LOAD query
* INSERT
* REMOVE
* CLEAR
*/
namespace Opie {
/**
* CreateQuery for the Todolist Table
*/
class CreateQuery : public OSQLQuery {
public:
CreateQuery();
~CreateQuery();
QString query()const;
};
/**
* Clears (delete) a Table
*/
class ClearQuery : public OSQLQuery {
public:
ClearQuery();
~ClearQuery();
QString query()const;
};
/**
* LoadQuery
* this one queries for all uids
*/
class LoadQuery : public OSQLQuery {
public:
LoadQuery();
~LoadQuery();
QString query()const;
};
/**
* inserts/adds a OPimContact to the table
*/
class InsertQuery : public OSQLQuery {
public:
InsertQuery(const OPimContact& );
~InsertQuery();
QString query()const;
private:
OPimContact m_contact;
};
/**
* removes one from the table
*/
class RemoveQuery : public OSQLQuery {
public:
RemoveQuery(int uid );
~RemoveQuery();
QString query()const;
private:
int m_uid;
};
/**
* a find query for noncustom elements
*/
class FindQuery : public OSQLQuery {
public:
FindQuery(int uid);
FindQuery(const QArray<int>& );
~FindQuery();
QString query()const;
private:
QString single()const;
QString multi()const;
QArray<int> m_uids;
int m_uid;
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 @@
/*
This file is part of the Opie Project
Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de)
=. Copyright (C) The Opie Team <opie-devel@handhelds.org>
.=l.
.>+-=
_;:, .> :=|. This program is free software; you can
.> <`_, > . <= redistribute it and/or modify it under
:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
.="- .-=="i, .._ License as published by the Free Software
- . .-<_> .<> Foundation; either version 2 of the License,
._= =} : or (at your option) any later version.
.%`+i> _;_.
.i_,=:_. -<s. This program is distributed in the hope that
+ . -:. = it will be useful, but WITHOUT ANY WARRANTY;
: .. .:, . . . without even the implied warranty of
=_ + =;=|` MERCHANTABILITY or FITNESS FOR A
_.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.= = ; Library General Public License for more
++= -. .` .: details.
: = ...= . :.=-
-. .:....=;==+<; You should have received a copy of the GNU
-_. . . )=. = Library General Public License along with
-- :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
/*
* SQL Backend for the OPIE-Contact Database.
*/
#ifndef _OPimContactAccessBackend_SQL_
#define _OPimContactAccessBackend_SQL_
#include <opie2/ocontactaccessbackend.h>
#include <opie2/ocontactaccess.h>
#include <qlist.h>
#include <qdict.h>
/* aren't in namespace Opie yet - alwin */
+namespace Opie {
+namespace DB {
class OSQLDriver;
class OSQLResult;
class OSQLResultItem;
+}
+}
namespace Opie {
/* the default xml implementation */
/**
* This class is the SQL implementation of a Contact backend
* it does implement everything available for OPimContact.
* @see OPimAccessBackend for more information of available methods
*/
class OPimContactAccessBackend_SQL : public OPimContactAccessBackend {
public:
OPimContactAccessBackend_SQL ( const QString& appname, const QString& filename = QString::null );
~OPimContactAccessBackend_SQL ();
bool save();
bool load ();
void clear ();
bool wasChangedExternally();
QArray<int> allRecords() const;
OPimContact find ( int uid ) const;
// FIXME: Add lookahead-cache support !
//OPimContact find(int uid, const QArray<int>&, uint cur, Frontend::CacheDirection )const;
QArray<int> queryByExample ( const OPimContact &query, int settings,
const QDateTime& d );
QArray<int> matchRegexp( const QRegExp &r ) const;
const uint querySettings();
bool hasQuerySettings (uint querySettings) const;
// Currently only asc implemented..
QArray<int> sorted( bool asc, int , int , int );
bool add ( const OPimContact &newcontact );
bool replace ( const OPimContact &contact );
bool remove ( int uid );
bool reload();
private:
- QArray<int> extractUids( OSQLResult& res ) const;
+ QArray<int> extractUids( Opie::DB::OSQLResult& res ) const;
QMap<int, QString> requestNonCustom( int uid ) const;
QMap<QString, QString> requestCustom( int uid ) const;
void update();
protected:
bool m_changed;
QString m_fileName;
QArray<int> m_uids;
- OSQLDriver* m_driver;
+ Opie::DB::OSQLDriver* m_driver;
};
}
#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,147 +1,148 @@
/*
This file is part of the Opie Project
Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de)
=. Copyright (C) The Opie Team <opie-devel@handhelds.org>
.=l.
.>+-=
_;:, .> :=|. This program is free software; you can
.> <`_, > . <= redistribute it and/or modify it under
:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
.="- .-=="i, .._ License as published by the Free Software
- . .-<_> .<> Foundation; either version 2 of the License,
._= =} : or (at your option) any later version.
.%`+i> _;_.
.i_,=:_. -<s. This program is distributed in the hope that
+ . -:. = it will be useful, but WITHOUT ANY WARRANTY;
: .. .:, . . . without even the implied warranty of
=_ + =;=|` MERCHANTABILITY or FITNESS FOR A
_.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.= = ; Library General Public License for more
++= -. .` .: details.
: = ...= . :.=-
-. .:....=;==+<; You should have received a copy of the GNU
-_. . . )=. = Library General Public License along with
-- :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
/*
* XML Backend for the OPIE-Contact Database.
*/
#include <opie2/ocontactaccessbackend_xml.h>
#include <qasciidict.h>
#include <qfile.h>
#include <qfileinfo.h>
#include <qregexp.h>
#include <qarray.h>
#include <qmap.h>
#include <qpe/global.h>
-#include <opie2/xmltree.h>
+#include "private/xmltree.h"
#include <opie2/ocontactaccessbackend.h>
#include <opie2/ocontactaccess.h>
#include <stdlib.h>
#include <errno.h>
using namespace Opie;
+using namespace Opie::Pim::Private;
namespace Opie {
OPimContactAccessBackend_XML::OPimContactAccessBackend_XML ( const QString& appname, const QString& filename ):
m_changed( false )
{
// Just m_contactlist should call delete if an entry
// is removed.
m_contactList.setAutoDelete( true );
m_uidToContact.setAutoDelete( false );
m_appName = appname;
/* Set journalfile name ... */
m_journalName = getenv("HOME");
m_journalName +="/.abjournal" + appname;
/* Expecting to access the default filename if nothing else is set */
if ( filename.isEmpty() ){
m_fileName = Global::applicationFileName( "addressbook","addressbook.xml" );
} else
m_fileName = filename;
/* Load Database now */
load ();
}
bool OPimContactAccessBackend_XML::save()
{
if ( !m_changed )
return true;
QString strNewFile = m_fileName + ".new";
QFile f( strNewFile );
if ( !f.open( IO_WriteOnly|IO_Raw ) )
return false;
int total_written;
int idx_offset = 0;
QString out;
// Write Header
out = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><!DOCTYPE Addressbook ><AddressBook>\n"
" <Groups>\n"
" </Groups>\n"
" <Contacts>\n";
QCString cstr = out.utf8();
f.writeBlock( cstr.data(), cstr.length() );
idx_offset += cstr.length();
out = "";
// Write all contacts
QListIterator<OPimContact> it( m_contactList );
for ( ; it.current(); ++it ) {
// qWarning(" Uid %d at Offset: %x", (*it)->uid(), idx_offset );
out += "<Contact ";
(*it)->save( out );
out += "/>\n";
cstr = out.utf8();
total_written = f.writeBlock( cstr.data(), cstr.length() );
idx_offset += cstr.length();
if ( total_written != int(cstr.length()) ) {
f.close();
QFile::remove( strNewFile );
return false;
}
out = "";
}
out += " </Contacts>\n</AddressBook>\n";
// Write Footer
cstr = out.utf8();
total_written = f.writeBlock( cstr.data(), cstr.length() );
if ( total_written != int( cstr.length() ) ) {
f.close();
QFile::remove( strNewFile );
return false;
}
f.close();
// move the file over, I'm just going to use the system call
// because, I don't feel like using QDir.
if ( ::rename( strNewFile.latin1(), m_fileName.latin1() ) < 0 ) {
qWarning( "problem renaming file %s to %s, errno: %d",
strNewFile.latin1(), m_journalName.latin1(), errno );
// remove the tmp file...
QFile::remove( strNewFile );
}
/* The journalfile should be removed now... */
removeJournal();
m_changed = false;
return true;
}
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,144 +1,146 @@
/*
This file is part of the Opie Project
Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de)
=. Copyright (C) The Opie Team <opie-devel@handhelds.org>
.=l.
.>+-=
_;:, .> :=|. This program is free software; you can
.> <`_, > . <= redistribute it and/or modify it under
:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
.="- .-=="i, .._ License as published by the Free Software
- . .-<_> .<> Foundation; either version 2 of the License,
._= =} : or (at your option) any later version.
.%`+i> _;_.
.i_,=:_. -<s. This program is distributed in the hope that
+ . -:. = it will be useful, but WITHOUT ANY WARRANTY;
: .. .:, . . . without even the implied warranty of
=_ + =;=|` MERCHANTABILITY or FITNESS FOR A
_.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.= = ; Library General Public License for more
++= -. .` .: details.
: = ...= . :.=-
-. .:....=;==+<; You should have received a copy of the GNU
-_. . . )=. = Library General Public License along with
-- :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
/*
* SQL Backend for the OPIE-Calender Database.
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <qarray.h>
#include <qstringlist.h>
#include <qpe/global.h>
#include <opie2/osqldriver.h>
#include <opie2/osqlmanager.h>
#include <opie2/osqlquery.h>
#include <opie2/opimrecurrence.h>
#include <opie2/odatebookaccessbackend_sql.h>
+using namespace Opie::DB;
+
namespace Opie {
ODateBookAccessBackend_SQL::ODateBookAccessBackend_SQL( const QString& ,
const QString& fileName )
: ODateBookAccessBackend(), m_driver( NULL )
{
m_fileName = fileName.isEmpty() ? Global::applicationFileName( "datebook", "datebook.db" ) : fileName;
// Get the standart sql-driver from the OSQLManager..
OSQLManager man;
m_driver = man.standard();
m_driver->setUrl( m_fileName );
initFields();
load();
}
ODateBookAccessBackend_SQL::~ODateBookAccessBackend_SQL() {
if( m_driver )
delete m_driver;
}
void ODateBookAccessBackend_SQL::initFields()
{
// This map contains the translation of the fieldtype id's to
// the names of the table columns
m_fieldMap.insert( OPimEvent::FUid, "uid" );
m_fieldMap.insert( OPimEvent::FCategories, "Categories" );
m_fieldMap.insert( OPimEvent::FDescription, "Description" );
m_fieldMap.insert( OPimEvent::FLocation, "Location" );
m_fieldMap.insert( OPimEvent::FType, "Type" );
m_fieldMap.insert( OPimEvent::FAlarm, "Alarm" );
m_fieldMap.insert( OPimEvent::FSound, "Sound" );
m_fieldMap.insert( OPimEvent::FRType, "RType" );
m_fieldMap.insert( OPimEvent::FRWeekdays, "RWeekdays" );
m_fieldMap.insert( OPimEvent::FRPosition, "RPosition" );
m_fieldMap.insert( OPimEvent::FRFreq, "RFreq" );
m_fieldMap.insert( OPimEvent::FRHasEndDate, "RHasEndDate" );
m_fieldMap.insert( OPimEvent::FREndDate, "REndDate" );
m_fieldMap.insert( OPimEvent::FRCreated, "RCreated" );
m_fieldMap.insert( OPimEvent::FRExceptions, "RExceptions" );
m_fieldMap.insert( OPimEvent::FStart, "Start" );
m_fieldMap.insert( OPimEvent::FEnd, "End" );
m_fieldMap.insert( OPimEvent::FNote, "Note" );
m_fieldMap.insert( OPimEvent::FTimeZone, "TimeZone" );
m_fieldMap.insert( OPimEvent::FRecParent, "RecParent" );
m_fieldMap.insert( OPimEvent::FRecChildren, "Recchildren" );
// Create a map that maps the column name to the id
QMapConstIterator<int, QString> it;
for ( it = ++m_fieldMap.begin(); it != m_fieldMap.end(); ++it ){
m_reverseFieldMap.insert( it.data(), it.key() );
}
}
bool ODateBookAccessBackend_SQL::load()
{
if (!m_driver->open() )
return false;
// Don't expect that the database exists.
// It is save here to create the table, even if it
// do exist. ( Is that correct for all databases ?? )
QString qu = "create table datebook( uid INTEGER PRIMARY KEY ";
QMap<int, QString>::Iterator it;
for ( it = ++m_fieldMap.begin(); it != m_fieldMap.end(); ++it ){
qu += QString( ",%1 VARCHAR(10)" ).arg( it.data() );
}
qu += " );";
qu += "create table custom_data( uid INTEGER, id INTEGER, type VARCHAR, priority INTEGER, value VARCHAR, PRIMARY KEY /* identifier */ (uid, id) );";
qWarning( "command: %s", qu.latin1() );
OSQLRawQuery raw( qu );
OSQLResult res = m_driver->query( &raw );
if ( res.state() != OSQLResult::Success )
return false;
update();
return true;
}
void ODateBookAccessBackend_SQL::update()
{
QString qu = "select uid from datebook";
OSQLRawQuery raw( qu );
OSQLResult res = m_driver->query( &raw );
if ( res.state() != OSQLResult::Success ){
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 @@
/*
This file is part of the Opie Project
Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de)
=. Copyright (C) The Opie Team <opie-devel@handhelds.org>
.=l.
.>+-=
_;:, .> :=|. This program is free software; you can
.> <`_, > . <= redistribute it and/or modify it under
:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
.="- .-=="i, .._ License as published by the Free Software
- . .-<_> .<> Foundation; either version 2 of the License,
._= =} : or (at your option) any later version.
.%`+i> _;_.
.i_,=:_. -<s. This program is distributed in the hope that
+ . -:. = it will be useful, but WITHOUT ANY WARRANTY;
: .. .:, . . . without even the implied warranty of
=_ + =;=|` MERCHANTABILITY or FITNESS FOR A
_.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.= = ; Library General Public License for more
++= -. .` .: details.
: = ...= . :.=-
-. .:....=;==+<; You should have received a copy of the GNU
-_. . . )=. = Library General Public License along with
-- :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef OPIE_DATE_BOOK_ACCESS_BACKEND_SQL__H
#define OPIE_DATE_BOOK_ACCESS_BACKEND_SQL__H
#include <qmap.h>
#include <opie2/osqlresult.h>
#include <opie2/odatebookaccessbackend.h>
+namespace Opie {
+namespace DB {
class OSQLDriver;
+}
+}
namespace Opie {
/**
* This is the default SQL implementation for DateBoook SQL storage
* It fully implements the interface
* @see ODateBookAccessBackend
* @see OPimAccessBackend
*/
class ODateBookAccessBackend_SQL : public ODateBookAccessBackend {
public:
ODateBookAccessBackend_SQL( const QString& appName,
const QString& fileName = QString::null);
~ODateBookAccessBackend_SQL();
bool load();
bool reload();
bool save();
QArray<int> allRecords()const;
QArray<int> matchRegexp(const QRegExp &r) const;
QArray<int> queryByExample( const OPimEvent&, int, const QDateTime& d = QDateTime() );
OPimEvent find( int uid )const;
void clear();
bool add( const OPimEvent& ev );
bool remove( int uid );
bool replace( const OPimEvent& ev );
QArray<UID> rawEvents()const;
QArray<UID> rawRepeats()const;
QArray<UID> nonRepeats()const;
OPimEvent::ValueList directNonRepeats();
OPimEvent::ValueList directRawRepeats();
private:
bool loadFile();
QString m_fileName;
QArray<int> m_uids;
QMap<int, QString> m_fieldMap;
QMap<QString, int> m_reverseFieldMap;
- OSQLDriver* m_driver;
+ Opie::DB::OSQLDriver* m_driver;
class Private;
Private *d;
void initFields();
void update();
- QArray<int> extractUids( OSQLResult& res ) const;
+ QArray<int> extractUids( Opie::DB::OSQLResult& res ) const;
};
}
#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,139 +1,141 @@
/*
This file is part of the Opie Project
Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de)
=. Copyright (C) The Opie Team <opie-devel@handhelds.org>
.=l.
.>+-=
_;:, .> :=|. This program is free software; you can
.> <`_, > . <= redistribute it and/or modify it under
:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
.="- .-=="i, .._ License as published by the Free Software
- . .-<_> .<> Foundation; either version 2 of the License,
._= =} : or (at your option) any later version.
.%`+i> _;_.
.i_,=:_. -<s. This program is distributed in the hope that
+ . -:. = it will be useful, but WITHOUT ANY WARRANTY;
: .. .:, . . . without even the implied warranty of
=_ + =;=|` MERCHANTABILITY or FITNESS FOR A
_.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.= = ; Library General Public License for more
++= -. .` .: details.
: = ...= . :.=-
-. .:....=;==+<; You should have received a copy of the GNU
-_. . . )=. = Library General Public License along with
-- :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include <qdatetime.h>
#include <qpe/global.h>
#include <opie2/osqldriver.h>
#include <opie2/osqlresult.h>
#include <opie2/osqlmanager.h>
#include <opie2/osqlquery.h>
#include <opie2/otodoaccesssql.h>
#include <opie2/opimstate.h>
#include <opie2/opimnotifymanager.h>
#include <opie2/opimrecurrence.h>
+using namespace Opie::DB;
+
using namespace Opie;
/*
* first some query
* CREATE query
* LOAD query
* INSERT
* REMOVE
* CLEAR
*/
namespace {
/**
* CreateQuery for the Todolist Table
*/
class CreateQuery : public OSQLQuery {
public:
CreateQuery();
~CreateQuery();
QString query()const;
};
/**
* LoadQuery
* this one queries for all uids
*/
class LoadQuery : public OSQLQuery {
public:
LoadQuery();
~LoadQuery();
QString query()const;
};
/**
* inserts/adds a OPimTodo to the table
*/
class InsertQuery : public OSQLQuery {
public:
InsertQuery(const OPimTodo& );
~InsertQuery();
QString query()const;
private:
OPimTodo m_todo;
};
/**
* removes one from the table
*/
class RemoveQuery : public OSQLQuery {
public:
RemoveQuery(int uid );
~RemoveQuery();
QString query()const;
private:
int m_uid;
};
/**
* Clears (delete) a Table
*/
class ClearQuery : public OSQLQuery {
public:
ClearQuery();
~ClearQuery();
QString query()const;
};
/**
* a find query
*/
class FindQuery : public OSQLQuery {
public:
FindQuery(int uid);
FindQuery(const QArray<int>& );
~FindQuery();
QString query()const;
private:
QString single()const;
QString multi()const;
QArray<int> m_uids;
int m_uid;
};
/**
* overdue query
*/
class OverDueQuery : public OSQLQuery {
public:
OverDueQuery();
~OverDueQuery();
QString query()const;
};
class EffQuery : public OSQLQuery {
public:
EffQuery( const QDate&, const QDate&, bool inc );
~EffQuery();
QString query()const;
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 @@
/*
This file is part of the Opie Project
Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de)
=. Copyright (C) The Opie Team <opie-devel@handhelds.org>
.=l.
.>+-=
_;:, .> :=|. This program is free software; you can
.> <`_, > . <= redistribute it and/or modify it under
:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
.="- .-=="i, .._ License as published by the Free Software
- . .-<_> .<> Foundation; either version 2 of the License,
._= =} : or (at your option) any later version.
.%`+i> _;_.
.i_,=:_. -<s. This program is distributed in the hope that
+ . -:. = it will be useful, but WITHOUT ANY WARRANTY;
: .. .:, . . . without even the implied warranty of
=_ + =;=|` MERCHANTABILITY or FITNESS FOR A
_.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.= = ; Library General Public License for more
++= -. .` .: details.
: = ...= . :.=-
-. .:....=;==+<; You should have received a copy of the GNU
-_. . . )=. = Library General Public License along with
-- :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef OPIE_PIM_ACCESS_SQL_H
#define OPIE_PIM_ACCESS_SQL_H
#include <qasciidict.h>
#include <opie2/otodoaccessbackend.h>
+namespace Opie {
+namespace DB {
class OSQLDriver;
class OSQLResult;
class OSQLResultItem;
+}
+}
namespace Opie {
class OPimTodoAccessBackendSQL : public OPimTodoAccessBackend {
public:
OPimTodoAccessBackendSQL( const QString& file );
~OPimTodoAccessBackendSQL();
bool load();
bool reload();
bool save();
QArray<int> allRecords()const;
QArray<int> queryByExample( const OPimTodo& t, int settings, const QDateTime& d = QDateTime() );
OPimTodo find(int uid)const;
OPimTodo find(int uid, const QArray<int>&, uint cur, Frontend::CacheDirection )const;
void clear();
bool add( const OPimTodo& t );
bool remove( int uid );
bool replace( const OPimTodo& t );
QArray<int> overDue();
QArray<int> effectiveToDos( const QDate& start,
const QDate& end, bool includeNoDates );
QArray<int> sorted(bool asc, int sortOrder, int sortFilter, int cat );
QBitArray supports()const;
QArray<int> matchRegexp( const QRegExp &r ) const;
void removeAllCompleted();
private:
void update()const;
void fillDict();
inline bool date( QDate& date, const QString& )const;
- inline OPimTodo todo( const OSQLResult& )const;
- inline OPimTodo todo( OSQLResultItem& )const;
- inline QArray<int> uids( const OSQLResult& )const;
+ inline OPimTodo todo( const Opie::DB::OSQLResult& )const;
+ inline OPimTodo todo( Opie::DB::OSQLResultItem& )const;
+ inline QArray<int> uids( const Opie::DB::OSQLResult& )const;
OPimTodo todo( int uid )const;
QBitArray sup() const;
QAsciiDict<int> m_dict;
- OSQLDriver* m_driver;
+ Opie::DB::OSQLDriver* m_driver;
QArray<int> m_uids;
bool m_dirty : 1;
};
}
#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,124 +1,124 @@
/* This file is part of the KDE project
Copyright (C) 2001 Simon Hausmann <hausmann@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
-#include <opie2/xmltree.h>
+#include "xmltree.h"
#include <qpe/stringutil.h>
#include <qxml.h>
#include <assert.h>
-using namespace Opie;
+using namespace Opie::Pim::Private;
XMLElement::XMLElement()
: m_parent( 0 ), m_next( 0 ), m_prev( 0 ), m_first( 0 ), m_last( 0 )
{
}
XMLElement::~XMLElement()
{
XMLElement *n = m_first;
while ( n )
{
XMLElement *tmp = n;
n = n->m_next;
delete tmp;
}
}
void XMLElement::appendChild( XMLElement *child )
{
if ( child->m_parent )
child->m_parent->removeChild( child );
child->m_parent = this;
if ( m_last )
m_last->m_next = child;
child->m_prev = m_last;
if ( !m_first )
m_first = child;
m_last = child;
}
void XMLElement::insertAfter( XMLElement *newChild, XMLElement *refChild )
{
assert( newChild != refChild );
if ( refChild == m_last )
{
appendChild( newChild );
return;
}
assert( refChild );
assert( refChild->m_parent );
assert( refChild->m_parent == this );
if ( newChild->m_parent && newChild != refChild )
newChild->m_parent->removeChild( newChild );
newChild->m_parent = this;
XMLElement *next = refChild->m_next;
refChild->m_next = newChild;
newChild->m_prev = refChild;
newChild->m_next = next;
if ( next )
next->m_prev = newChild;
}
QString XMLElement::attribute( const QString &attr ) const
{
AttributeMap::ConstIterator it = m_attributes.find( attr );
if ( it == m_attributes.end() )
return QString::null;
return it.data();
}
void XMLElement::setAttribute( const QString &attr, const QString &value )
{
m_attributes.replace( attr, value );
}
void XMLElement::insertBefore( XMLElement *newChild, XMLElement *refChild )
{
assert( refChild );
assert( refChild->m_parent );
assert( refChild->m_parent == this );
assert( newChild != refChild );
if ( newChild->m_parent && newChild != refChild )
newChild->m_parent->removeChild( newChild );
newChild->m_parent = this;
XMLElement *prev = refChild->m_prev;
refChild->m_prev = newChild;
newChild->m_prev = prev;
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 @@
/* This file is part of the KDE project
Copyright (C) 2000,2001 Simon Hausmann <hausmann@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef __bookmarks_h__
#define __bookmarks_h__
#include <qstring.h>
#include <qmap.h>
#include <qtextstream.h>
-namespace Opie
-{
+namespace Opie {
+namespace Pim {
+namespace Private{
/**
* A small xml lib written by Simon Hausmann.
*/
class XMLElement
{
public:
typedef QMap<QString, QString> AttributeMap;
/**
* The constructor of XMLElement
*/
XMLElement();
~XMLElement();
/** appendChild appends a child to the XMLElement behind the last element.
* The ownership of the child get's transfered to the
* this XMLElement.
* If child is already the child of another parent
* it's get removed from the other parent first.
*/
void appendChild( XMLElement *child );
/** inserts newChild after refChild. If newChild is the child
* of another parent the child will get removed.
* The ownership of child gets transfered.
*
*/
void insertAfter( XMLElement *newChild, XMLElement *refChild );
/** same as insertAfter but the element get's inserted before refChild.
*
*/
void insertBefore( XMLElement *newChild, XMLElement *refChild );
/** removeChild removes the child from the XMLElement.
* The ownership gets dropped. You need to delete the
* child yourself.
*/
void removeChild( XMLElement *child );
/** parent() returns the parent of this XMLElement
* If there is no parent 0l gets returned
*/
XMLElement *parent() const { return m_parent; }
XMLElement *firstChild() const { return m_first; }
XMLElement *nextChild() const { return m_next; }
XMLElement *prevChild() const { return m_prev; }
XMLElement *lastChild() const { return m_last; }
void setTagName( const QString &tag ) { m_tag = tag; }
QString tagName() const { return m_tag; }
void setValue( const QString &val ) { m_value = val; }
QString value() const { return m_value; }
void setAttributes( const AttributeMap &attrs ) { m_attributes = attrs; }
AttributeMap attributes() const { return m_attributes; }
AttributeMap &attributes() { return m_attributes; }
QString attribute( const QString & ) const;
void setAttribute( const QString &attr, const QString &value );
void save( QTextStream &stream, uint indent = 0 );
XMLElement *namedItem( const QString &name );
XMLElement *clone() const;
static XMLElement *load( const QString &fileName );
private:
QString m_tag;
QString m_value;
AttributeMap m_attributes;
XMLElement *m_parent;
XMLElement *m_next;
XMLElement *m_prev;
XMLElement *m_first;
XMLElement *m_last;
XMLElement( const XMLElement &rhs );
XMLElement &operator=( const XMLElement &rhs );
class Private;
Private* d;
};
+}
+}
} // namespace Opie
#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 @@
#ifndef OPIE_BIG_SCREEN_PRIVATE
#define OPIE_BIG_SCREEN_PRIVATE
/* QT */
#include <qstring.h>
class QWidget;
-namespace Opie
-{
+namespace Opie {
+namespace Ui {
+namespace Private{
struct OSplitterContainer
{
bool operator==( const OSplitterContainer& o) const
{
if (widget != o.widget ) return false;
if (icon != o.icon ) return false;
if (name != o.name ) return false;
return true;
}
QWidget* widget;
QString icon;
QString name;
};
-};
+}
+}
+}
#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,638 +1,639 @@
/*
               =. This file is part of the OPIE Project
             .=l. Copyright (c) 2003 hOlgAr <zecke@handhelds.org>
           .>+-=
 _;:,     .>    :=|. This library is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This library is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include "osplitter.h"
/* OPIE */
#include <opie2/otabwidget.h>
/* QT */
#include <qvaluelist.h>
#include <qvbox.h>
-using namespace Opie;
+using namespace Opie::Ui;
+using namespace Opie::Ui::Private;
/**
*
* This is the constructor of OSplitter
* You might want to call setSizeChange to tell
* OSplitter to change its layout when a specefic
* mark was crossed. OSplitter sets a default value.
*
* You cann add widget with addWidget to the OSplitter.
* OSplitter supports also grouping of Splitters where they
* can share one OTabBar in small screen mode. This can be used
* for email clients like vies but see the example.
*
* @param orient The orientation wether to layout horizontal or vertical
* @param parent The parent of this widget
* @param name The name passed on to QObject
* @param fl Additional widgets flags passed to QWidget
*
* @short single c'tor of the OSplitter
*/
OSplitter::OSplitter( Orientation orient, QWidget* parent, const char* name, WFlags fl )
: QFrame( parent, name, fl )
{
m_orient = orient;
m_hbox = 0;
m_size_policy = 330;
setFontPropagation( AllChildren );
setPalettePropagation( AllChildren );
/* start by default with the tab widget */
m_tabWidget = 0;
m_parentTab = 0;
changeTab();
}
/**
* Destructor destructs this object and cleans up. All child
* widgets will be deleted
* @see addWidget
*/
OSplitter::~OSplitter()
{
qWarning("Deleted Splitter");
m_splitter.setAutoDelete( true );
m_splitter.clear();
delete m_hbox;
delete m_tabWidget;
}
/**
* Sets the label for the Splitter. This label will be used
* if a parent splitter is arranged as TabWidget but
* this splitter is in fullscreen mode. Then a tab with OSplitter::label()
* and iconName() gets added.
*
* @param name The name of the Label
*/
void OSplitter::setLabel( const QString& name )
{
m_name = name;
}
/**
* @see setLabel but this is for the icon retrieved by Resource
*
* @param name The name of the icon in example ( "zoom" )
*/
void OSplitter::setIconName( const QString& name )
{
m_icon = name;
}
/**
* returns the iconName
* @see setIconName
*/
QString OSplitter::iconName()const
{
return m_icon;
}
/**
* returns the label set with setLabel
* @see setLabel
*/
QString OSplitter::label()const
{
return m_name;
}
/**
* This function sets the size change policy of the splitter.
* If this size marked is crossed the splitter will relayout.
* Note: that depending on the set Orientation it'll either look
* at the width or height.
* Note: If you want to from side to side view to tabbed view you need
* to make sure that the size you supply is not smaller than the minimum
* size of your added widgets. Note that if you use widgets like QComboBoxes
* you need to teach them to accept smaller sizes as well @see QWidget::setSizePolicy
*
* @param width_height The mark that will be watched. Interpreted depending on the Orientation of the Splitter.
* @return void
*/
void OSplitter::setSizeChange( int width_height )
{
m_size_policy = width_height;
QSize sz(width(), height() );
QResizeEvent ev(sz, sz );
resizeEvent(&ev);
}
/**
* This functions allows to add another OSplitter and to share
* the OTabBar in small screen mode. The ownerships gets transfered.
* OSplitters are always added after normal widget items
*/
void OSplitter::addWidget( OSplitter* split )
{
m_splitter.append( split );
/*
* set tab widget
*/
if (m_tabWidget )
setTabWidget( m_parentTab );
else
{
- Opie::OSplitterContainer con;
+ OSplitterContainer con;
con.widget =split;
addToBox( con );
}
}
/*
* If in a tab it should be removed
* and if in a hbox the reparent kills it too
*/
/**
* This removes the splitter again. You currently need to call this
* before you delete or otherwise you can get mem corruption
* or other weird behaviour.
* Owner ship gets transfered back to you it's current parent
* is 0
*/
void OSplitter::removeWidget( OSplitter* split)
{
split->setTabWidget( 0 );
split->reparent( 0, 0, QPoint(0, 0) );
}
/**
* Adds a widget to the Splitter. The widgets gets inserted
* at the end of either the Box or TabWidget.
* Ownership gets transfered and the widgets gets reparented.
* Note: icon and label is only available on small screensizes
* if size is smaller than the mark
* Warning: No null checking of the widget is done. Only on debug
* a message will be outputtet
*
* @param wid The widget which will be added
* @param icon The icon of the possible Tab
* @param label The label of the possible Tab
*/
void OSplitter::addWidget( QWidget* wid, const QString& icon, const QString& label )
{
#ifdef DEBUG
if (!wid )
{
qWarning("Widget is not valid!");
return;
}
#endif
- Opie::OSplitterContainer cont;
+ OSplitterContainer cont;
cont.widget = wid;
cont.icon =icon;
cont.name = label;
m_container.append( cont );
/*
*
*/
if (!m_splitter.isEmpty() && (m_tabWidget || m_parentTab ) )
setTabWidget( m_parentTab );
else
{
if (m_hbox )
addToBox( cont );
else
addToTab( cont );
}
}
/**
* Removes the widget from the tab widgets if necessary.
* OSplitter drops ownership of this widget and the widget
* will be reparented i tto 0.
* The widget will not be deleted.
*
* @param w The widget to be removed
*/
void OSplitter::removeWidget( QWidget* w)
{
ContainerList::Iterator it;
for ( it = m_container.begin(); it != m_container.end(); ++it )
if ( (*it).widget == w )
break;
if (it == m_container.end() )
return;
/* only tab needs to be removed.. box recognizes it */
if ( !m_hbox )
removeFromTab( w );
/* Find reparent it and remove it from our list */
w->reparent( 0, 0, QPoint(0, 0));
it = m_container.remove( it );
}
/**
* This method will give focus to the widget. If in a tabwidget
* the tabbar will be changed
*
* @param w The widget which will be set the current one
*/
void OSplitter::setCurrentWidget( QWidget* w)
{
if (m_tabWidget )
m_tabWidget->setCurrentTab( w );
// else
// m_hbox->setFocus( w );
}
/**
* This is an overloaded member function and only differs in the
* argument it takes.
* Searches list of widgets for label. It'll pick the first label it finds
*
* @param label Label to look for. First match will be taken
*/
void OSplitter::setCurrentWidget( const QString& label )
{
ContainerList::Iterator it;
for (it = m_container.begin(); it != m_container.end(); ++it )
{
if ( (*it).name == label )
{
setCurrentWidget( (*it).widget );
break;
}
}
}
/**
* This will only work when the TabWidget is active
* If everything is visible this signal is kindly ignored
* @see OTabWidget::setCurrentTab(int)
*
* @param tab The tab to make current
*/
void OSplitter::setCurrentWidget( int tab )
{
if (m_tabWidget )
m_tabWidget->setCurrentTab( tab );
}
/**
* return the currently activated widget if in tab widget mode
* or null because all widgets are visible
*/
QWidget* OSplitter::currentWidget() const
{
if (m_tabWidget)
return m_tabWidget->currentWidget();
else if (m_parentTab )
return m_parentTab->currentWidget();
return 0l;
}
/* wrong */
#if 0
/**
* @reimplented for internal reasons
* returns the sizeHint of one of its sub widgets
*/
QSize OSplitter::sizeHint()const
{
if (m_parentTab )
return QFrame::sizeHint();
if (m_hbox )
return m_hbox->sizeHint();
else
return m_tabWidget->sizeHint();
}
QSize OSplitter::minimumSizeHint()const
{
if (m_parentTab )
return QFrame::minimumSizeHint();
if (m_hbox)
return m_hbox->sizeHint();
else
return m_tabWidget->sizeHint();
}
#endif
/**
* @reimplemented for internal reasons
*/
void OSplitter::resizeEvent( QResizeEvent* res )
{
QFrame::resizeEvent( res );
/*
*
*/
// qWarning("Old size was width = %d height = %d", res->oldSize().width(), res->oldSize().height() );
bool mode = true;
qWarning("New size is width = %d height = %d %s", res->size().width(), res->size().height(), name() );
if ( res->size().width() > m_size_policy &&
m_orient == Horizontal )
{
changeHBox();
mode = false;
}
else if ( (res->size().width() <= m_size_policy &&
m_orient == Horizontal ) ||
(res->size().height() <= m_size_policy &&
m_orient == Vertical ) )
{
changeTab();
}
else if ( res->size().height() > m_size_policy &&
m_orient == Vertical )
{
qWarning("Changng to vbox %s", name() );
changeVBox();
mode = false;
}
emit sizeChanged(mode, m_orient );
}
/*
* Adds a container to a tab either the parent tab
* or our own
*/
-void OSplitter::addToTab( const Opie::OSplitterContainer& con )
+void OSplitter::addToTab( const Opie::Ui::Private::OSplitterContainer& con )
{
QWidget *wid = con.widget;
// not needed widgetstack will reparent as well wid.reparent(m_tabWidget, wid->getWFlags(), QPoint(0, 0) );
if (m_parentTab )
m_parentTab->addTab( wid, con.icon, con.name );
else
m_tabWidget->addTab( wid, con.icon, con.name );
}
/*
* adds a container to the box
*/
-void OSplitter::addToBox( const Opie::OSplitterContainer& con )
+void OSplitter::addToBox( const Opie::Ui::Private::OSplitterContainer& con )
{
QWidget* wid = con.widget;
wid->reparent(m_hbox, 0, QPoint(0, 0) );
}
/*
* Removes a widget from the tab
*/
void OSplitter::removeFromTab( QWidget* wid )
{
if (m_parentTab )
m_parentTab->removePage( wid );
else
m_tabWidget->removePage( wid );
}
/*
* switches over to a OTabWidget layout
* it is recursive
*/
void OSplitter::changeTab()
{
/* if we're the owner of the tab widget */
if (m_tabWidget )
{
raise();
show();
m_tabWidget->setGeometry( frameRect() );
return;
}
qWarning(" New Tab Widget %s", name() );
/*
* and add all widgets this will reparent them
* delete m_hbox set it to 0
*
*/
OTabWidget *tab;
if ( m_parentTab )
{
hide();
tab = m_parentTab;
/* expensive but needed cause we're called from setTabWidget and resizeEvent*/
if (!m_container.isEmpty() )
{
ContainerList::Iterator it = m_container.begin();
for (; it != m_container.end(); ++it )
m_parentTab->removePage( (*it).widget );
}
}
else
tab = m_tabWidget = new OTabWidget( this );
connect(tab, SIGNAL(currentChanged(QWidget*) ),
this, SIGNAL(currentChanged(QWidget*) ) );
for ( ContainerList::Iterator it = m_container.begin(); it != m_container.end(); ++it )
{
qWarning("Widget is %s", (*it).name.latin1() );
addToTab( (*it) );
}
for ( OSplitter* split = m_splitter.first(); split; split = m_splitter.next() )
{
split->reparent(this, 0, QPoint(0, 0) );
split->setTabWidget( tab );
}
delete m_hbox;
m_hbox = 0;
if (!m_tabWidget )
return;
m_tabWidget->setGeometry( frameRect() );
m_tabWidget->show();
}
/*
* changes over to a box
* this is recursive as well
*/
void OSplitter::changeHBox()
{
if (m_hbox )
{
m_hbox->setGeometry( frameRect() );
return;
}
qWarning("new HBox %s", name() );
m_hbox = new QHBox( this );
commonChangeBox();
}
void OSplitter::changeVBox()
{
if (m_hbox )
{
m_hbox->setGeometry( frameRect() );
return;
}
qWarning("New VBOX %s", name() );
m_hbox = new QVBox( this );
commonChangeBox();
}
/*
* common box code
* first remove and add children
* the other splitters
* it is recursive as well due the call to setTabWidget
*/
void OSplitter::commonChangeBox()
{
qWarning(" Name of Splitters is %s", name() );
for (ContainerList::Iterator it = m_container.begin(); it != m_container.end(); ++it )
{
/* only if parent tab.. m_tabWidgets gets deleted and would do that as well */
if (m_parentTab )
removeFromTab( (*it).widget );
qWarning("Adding to box %s", (*it).name.latin1() );
addToBox( (*it) );
}
for ( OSplitter* split = m_splitter.first(); split; split = m_splitter.next() )
{
/* tell them the world had changed */
split->setTabWidget( 0 );
- Opie::OSplitterContainer con;
+ OSplitterContainer con;
con.widget = split;
// con.widget = split->m_tabWidget ? static_cast<QWidget*>(split->m_tabWidget)
// : static_cast<QWidget*>(split->m_hbox);
addToBox( con );
}
if (m_parentTab )
m_parentTab->addTab(m_hbox, iconName(), label() );
else
{
qWarning(" setting Box geometry for %s", name() );
m_hbox->setGeometry( frameRect() );
m_hbox->show();
delete m_tabWidget;
m_tabWidget = 0;
show(); // also show this widget
}
}
/*
* sets the tabwidget, removes tabs, and relayouts the widget
*/
void OSplitter::setTabWidget( OTabWidget* wid)
{
/* clean up cause m_parentTab will not be available for us */
if ( m_parentTab )
{
if (m_hbox )
m_parentTab->removePage( m_hbox );
else if (!m_container.isEmpty() )
{
ContainerList::Iterator it = m_container.begin();
for ( ; it != m_container.end(); ++it )
m_parentTab->removePage( (*it).widget );
}
}
/* the parent Splitter changed so either make us indepent or dep */
m_parentTab = wid;
QWidget *tab = m_tabWidget;
QWidget *box = m_hbox;
m_hbox = 0; m_tabWidget = 0;
if ( layoutMode() )
changeTab();
else if (m_orient == Horizontal )
changeHBox();
else
changeVBox();
/* our own crap is added and children from change* */
delete tab;
delete box;
}
#if 0
void OSplitter::reparentAll()
{
if (m_container.isEmpty() )
return;
ContainerList::Iterator it = m_container.begin();
for ( ; it != m_container.end(); ++it )
(*it).wid->reparent(0, 0, QPoint(0, 0) );
}
#endif
/**
* @internal
*/
bool OSplitter::layoutMode()const
{
if ( size().width() > m_size_policy &&
m_orient == Horizontal )
{
return false;
}
else if ( size().height() > m_size_policy &&
m_orient == Vertical )
{
return false;
}
return true;
}
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 @@
/*
               =. This file is part of the OPIE Project
             .=l. Copyright (c) 2003 hOlgAr <zecke@handhelds.org>
           .>+-=
 _;:,     .>    :=|. This library is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This library is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
-
+
*/
#ifndef OSPLITTER_H
#define OSPLITTER_H
#include "obigscreen_p.h"
/* QT */
#include <qframe.h>
#include <qlist.h>
#include <qstring.h>
#include <qvaluelist.h>
class QHBox;
//template class QValueList<Opie::OSplitterContainer>;
/*
* TODO
* -check API docu
* -one more example
* -allow inserting at a position
*/
-namespace Opie
-{
+namespace Opie{
+namespace Ui {
class OTabWidget;
/**
*
* If you've widgets that could be placed side by side but you think
* on small resolutions is not enough place but it would really make sense
* on bigger resolutions this class will help you.
* You can add as many widgets you want to it. Set a poliy on which width/height it
* should switch the layout.
* You can either say to place widgets vertical or horizontal.
* This class uses QHBox, QVBox and QTAbWidget internally.
* OSplitter takes ownership of the widgets
*
* @since 1.2
*
* @short a small dynamically changing its layout to store two or more widgets side by side
* @version 0.1
* @author zecke
*/
class OSplitter : public QFrame
{
Q_OBJECT
public:
- typedef QValueList<Opie::OSplitterContainer> ContainerList;
+ typedef QValueList<Opie::Ui::Private::OSplitterContainer> ContainerList;
OSplitter( Qt::Orientation = Horizontal, QWidget *parent = 0,
const char* name = 0, WFlags fl = 0 );
~OSplitter();
void setLabel( const QString& name );
void setIconName( const QString& name );
QString label()const;
QString iconName()const;
void setSizeChange( int width_height );
void addWidget( OSplitter* splitter );
void addWidget( QWidget* wid, const QString& icon, const QString& label );
void removeWidget( QWidget* );
void removeWidget( OSplitter* );
void setCurrentWidget( QWidget* );
void setCurrentWidget( const QString& label );
void setCurrentWidget( int );
QWidget* currentWidget()const;
signals:
/**
* Emitted if in tab and comes directly from the tab widget
*
*/
void currentChanged( QWidget* );
/**
* emitted whenever a border is crossed
* true if in small screen mode
* false if in bigscreen
* this signal is emitted after the layout switch
* @param b The layout mode
* @param ori The orientation
*/
void sizeChanged( bool b, Orientation ori);
public:
// QSize sizeHint()const;
// QSize minimumSizeHint()const;
protected:
void resizeEvent( QResizeEvent* );
private:
/* true if OTabMode */
bool layoutMode()const;
// void reparentAll();
void setTabWidget( OTabWidget*);
- void addToTab( const Opie::OSplitterContainer& );
- void addToBox( const Opie::OSplitterContainer& );
+ void addToTab( const Opie::Ui::Private::OSplitterContainer& );
+ void addToBox( const Opie::Ui::Private::OSplitterContainer& );
void removeFromTab( QWidget* );
void changeTab();
void changeHBox();
void changeVBox();
void commonChangeBox();
QHBox *m_hbox;
OTabWidget *m_tabWidget;
OTabWidget *m_parentTab;
Orientation m_orient;
int m_size_policy;
ContainerList m_container;
QList<OSplitter> m_splitter;
QString m_icon, m_name;
struct Private;
Private *d;
};
-};
+}
+}
#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,135 +1,135 @@
/*
               =. This file is part of the OPIE Project
             .=l. Copyright (c) 2003 hOlgAr <zecke@handhelds.org>
           .>+-=
 _;:,     .>    :=|. This library is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This library is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include "owidgetstack.h"
/* QT */
#include <qapplication.h>
#include <qwidgetstack.h>
-namespace {
+namespace Opie {
+namespace Ui {
const int mode_size = 330;
-}
-using namespace Opie;
+
/**
* This is the standard widget. For simple usage see the example. Normally this widget
* is the central widget of a QMainWindow.
* Use removeWidget before you delete a widget yourself. OWidgetStack does not
* yet recognize removal of children.
*
* @param parent The parent widget. It maybe 0 but then you need to take care of deletion.
* Or you use QPEApplication::showMainWidget().
* @param name Name will be passed on to QObject
* @param fl Additional window flags passed to QFrame. see @Qt::WFlags
*/
OWidgetStack::OWidgetStack( QWidget* parent, const char* name, WFlags fl)
: QFrame( parent, name, fl )
{
m_last = m_mWidget = 0;
m_forced = false;
QApplication::desktop()->installEventFilter( this );
setFontPropagation ( AllChildren );
setPalettePropagation( AllChildren );
/* sets m_mode and initializes more */
/* if you change this call change switchTop as well */
m_stack = 0;
switchStack();
}
/**
* The destructor. It deletes also all added widgets.
*
*/
OWidgetStack::~OWidgetStack() {
if (m_mode == BigScreen && !m_list.isEmpty() ) {
QMap<int, QWidget*>::Iterator it = m_list.begin();
for ( ; it != m_list.end(); ++it )
delete it.data();
}
m_list.clear();
}
/**
* return the mode of the desktop. There are currently two modes. SmallScreen
* with a normal PDA resolution and BigScreen with resolutions greater than
* 330 for width and height.
* You can also force the mode this widget is in with forceMode()
* Note that NoForce will be never returned from here
*/
enum OWidgetStack::Mode OWidgetStack::mode()const {
return m_mode;
}
/**
* You can also force one of the modes and then
* this widget stops on listening to size changes. You
* can revert to the scanning behaviour by setting mode
* to NoForce
*/
void OWidgetStack::forceMode( enum Mode mode) {
m_forced = mode != NoForce;
/* we need to see which mode we're in */
if (!m_forced ) {
if ( QApplication::desktop()->width() >=
mode_size )
mode = BigScreen;
else
mode = SmallScreen;
}
switch( mode ) {
case NoForce:
case SmallScreen:
switchStack();
break;
case BigScreen:
switchTop();
break;
}
m_mode = mode;
}
/**
* Adds a widget to the stack. The first widget added is considered
* to be the mainwindow. This is important because if Opie is in
* BigScreen mode the sizeHint of the MainWindow will be returned.
* In Small Screen the sizeHint of the QWidgetStack is returned.
* See QWidgetStack::sizeHint.
* This widget takes ownership of the widget and may even reparent.
* All windows will be hidden
*
* @param wid The QWidget to be added
* @param id An ID for the Widget. If the ID is duplicated the
last set widget will be related to the id
@@ -340,96 +340,99 @@ void OWidgetStack::resizeEvent( QResizeEvent* ev ) {
* the mainwindow but you can change this with this
* function.
* If in BigScreen mode the current mainwindow will be reparented
* and hidden. The position will be taken by the new one.
* If the old MainWindow was hidden the new window will
* also be hidden. If the window was visible the new mainwindow
* will be made visible too and the old one hidden. If there
* was no mainwindow it will be hidden as well.
*
* @param wid The new mainwindow
*/
void OWidgetStack::setMainWindow( QWidget* wid ) {
if (m_mode == BigScreen ) {
bool wasVisible = false;
if (m_mWidget ) {
wasVisible = !m_mWidget->isHidden();
/* hidden by default */
m_mWidget->reparent(0, WType_TopLevel, QPoint(10, 10) );
}
wid->reparent(this, 0, frameRect().topLeft() );
if (wasVisible)
wid->show();
}
m_mWidget = wid;
}
/**
* this is an overloaded member and only differs
* in the type of arguments.
* @see setMainWindow(QWidget*)
*/
void OWidgetStack::setMainWindow( int id) {
setMainWindow( widget( id ) );
}
/*
* this function switches to a stack ;)
*/
void OWidgetStack::switchStack() {
if (m_stack ) {
m_stack->setGeometry( frameRect() );
return;
}
m_mode = SmallScreen;
m_stack = new QWidgetStack(this);
connect(m_stack, SIGNAL(aboutToShow(QWidget*) ),
this, SIGNAL(aboutToShow(QWidget*) ) );
connect(m_stack, SIGNAL(aboutToShow(int) ),
this, SIGNAL(aboutToShow(int) ) );
/* now reparent the widgets... luckily QWidgetSatck does most of the work */
if (m_list.isEmpty() )
return;
QMap<int, QWidget*>::Iterator it = m_list.begin();
for ( ; it != m_list.end(); ++it )
m_stack->addWidget( it.data(), it.key() );
}
/*
* we will switch to top level mode
* reparent the list of widgets and then delete the stack
*/
void OWidgetStack::switchTop() {
m_mode = BigScreen;
/* this works because it is guaranteed that switchStack was called at least once*/
if (!m_stack && m_mWidget) {
m_mWidget->setGeometry( frameRect() );
return;
}else if (!m_stack)
return;
if (!m_list.isEmpty() ) {
QMap<int, QWidget*>::Iterator it = m_list.begin();
for ( ; it != m_list.end(); ++it ) {
/* better than reparenting twice */
if ( it.data() == m_mWidget ) {
m_mWidget->reparent(this, 0, frameRect().topLeft() );
m_mWidget->setGeometry( frameRect() );
m_mWidget->show();
}else
/* ### FIXME we need to place the widget better */
it.data()->reparent(0, WType_TopLevel, QPoint(10, 10) );
}
}
delete m_stack;
m_stack = 0;
}
+
+}
+} \ 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 @@
/*
               =. This file is part of the OPIE Project
             .=l. Copyright (c) 2003 hOlgAr <zecke@handhelds.org>
           .>+-=
 _;:,     .>    :=|. This library is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This library is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef OWIDGETSTACK_H
#define OWIDGETSTACK_H
/* QT*/
#include <qframe.h>
#include <qmap.h>
class QWidgetStack;
-namespace Opie
-{
+namespace Opie {
+namespace Ui {
/**
*
* OWidgetStack is the answer to the problem of using Opie at different screen
* sizes and to have a different behaviour. Most applications use a QWidgetStack
* to supply a view on click. And by clicking the (X) you go back but this
* behaviour feels strange on bigger screens. It's ok on smaller one because
* one can't determine the difference.
* This stack reads the default out of the size of the desktop widget but
* can be forced to have either the one or the other behaviour.
* The first widget added is considered the 'main' widget and its
* sizeHint will be taking if in BigScreen mode.
* In small screen mode this widget behaves exactly like a QWidgetStack and in BigScreen
* mode it'll use the MainWindow as child of this widget and arranges the others as
* hidden top level widgets.
*
* @version 0.1
* @author hOlgAr F.
* @short Either a true stack or a list of top Level widgets
*/
class OWidgetStack : public QFrame {
Q_OBJECT
public:
enum Mode { SmallScreen, BigScreen, NoForce };
OWidgetStack( QWidget* parent, const char* name = 0, WFlags fl = 0 );
~OWidgetStack();
enum Mode mode()const;
void forceMode( enum Mode );
void addWidget( QWidget* , int );
void removeWidget( QWidget* );
// QSizeHint sizeHint()const;
// QSizeHint minimumSizeHint()const;
QWidget *widget( int )const;
int id( QWidget* )const;
QWidget* visibleWidget() const;
bool eventFilter( QObject*, QEvent* );
signals:
/**
* OWidgetStack monitors the Desktop Widget for
* size changes if it recignizes a change size it'll
* send a signal and adjust its mode. After the signal
* was emitted. During the signal a call to mode() the
* old mode will be returned. Note that if a size change happens
* but no modeChange no signal will be emitted
*
*
* @param mode The new mode of the desktop
*/
void modeChanged( enum Mode mode);
/**
* These two signals are emitted whenever we're about to
* show one of the widgets
*/
void aboutToShow( QWidget* );
void aboutToShow( int );
public slots:
void raiseWidget( int );
void raiseWidget( QWidget* );
void hideWidget( int );
void hideWidget( QWidget* );
void setMainWindow( QWidget* );
void setMainWindow( int );
protected:
void resizeEvent( QResizeEvent* );
private:
void switchStack();
void switchTop();
QMap<int, QWidget*> m_list;
QWidgetStack *m_stack;
QWidget *m_mWidget;
QWidget *m_last;
enum Mode m_mode;
bool m_forced : 1;
struct Private;
Private *d;
};
-};
+}
+}
#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,138 +1,138 @@
/*
               =. This file is part of the OPIE Project
             .=l. Copyright (C) Holger Freyther <zecke@handhelds.org>
           .>+-=
 _;:,     .>    :=|. This library is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This library is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
/* OPIE */
#include <opie2/ofiledialog.h>
#include <qpe/applnk.h>
#include <qpe/config.h>
#include <qpe/qpeapplication.h>
/* QT */
#include <qfileinfo.h>
#include <qstring.h>
#include <qapplication.h>
#include <qlayout.h>
-using namespace Opie;
+using namespace Opie::Ui;
namespace
{
/*
* helper functions to load the start dir
* and to save it
* helper to extract the dir out of a file name
*/
/**
* This method will use Config( argv[0] );
* @param key The group key used
*/
QString lastUsedDir( const QString& key )
{
if ( qApp->argc() < 1 )
return QString::null;
Config cfg( QFileInfo(qApp->argv()[0]).fileName() ); // appname
cfg.setGroup( key );
return cfg.readEntry("LastDir", QPEApplication::documentDir() );
}
void saveLastDir( const QString& key, const QString& file )
{
if ( qApp->argc() < 1 )
return;
Config cfg( QFileInfo(qApp->argv()[0]).fileName() );
cfg.setGroup( key );
QFileInfo inf( file );
cfg.writeEntry("LastDir", inf.dirPath( true ) );
}
};
/**
* This constructs a modal dialog
*
* @param caption The caption of the dialog
* @param wid The parent widget
* @param mode The mode of the OFileSelector @see OFileSelector
* @param selector The selector of the OFileSelector
* @param dirName the dir or resource to start from
* @param fileName a proposed or existing filename
* @param mimetypes The mimeTypes
*/
OFileDialog::OFileDialog(const QString &caption,
QWidget *wid, int mode, int selector,
const QString &dirName,
const QString &fileName,
const QMap<QString,QStringList>& mimetypes )
: QDialog( wid, "OFileDialog", true )
{
// QVBoxLayout *lay = new QVBoxLayout(this);
//showMaximized();
QVBoxLayout *lay = new QVBoxLayout(this );
file = new OFileSelector(this , mode, selector,
dirName, fileName,
mimetypes );
lay->addWidget( file );
//lay->addWidget( file );
//showFullScreen();
setCaption( caption.isEmpty() ? tr("FileDialog") : caption );
connect(file, SIGNAL(fileSelected(const QString&) ),
this, SLOT(slotFileSelected(const QString&) ) );
connect(file, SIGNAL(ok() ),
this, SLOT(slotSelectorOk()) ) ;
connect(file, SIGNAL(dirSelected(const QString&) ), this, SLOT(slotDirSelected(const QString&) ) );
#if 0
connect(file, SIGNAL(dirSelected(const QString&) ),
this, SLOT(slotDirSelected(const QString&) ) );
#endif
}
/**
* @returns the mimetype of the selected
* currently it return QString::null
*/
QString OFileDialog::mimetype()const
{
return QString::null;
}
/**
* @return the fileName
*/
QString OFileDialog::fileName()const
{
return file->selectedName();
}
/**
* return a DocLnk to the current file
*/
DocLnk OFileDialog::selectedDocument()const
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 @@
/*
               =. This file is part of the OPIE Project
             .=l. Copyright (c) 2002 zecke <zecke@handhelds.org>
           .>+-=
 _;:,     .>    :=|. This library is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This library is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef OFILEDIALOG_H
#define OFILEDIALOG_H
/* OPIE */
#include <opie2/ofileselector.h>
/* QT */
#include <qdialog.h>
-namespace Opie
-{
+namespace Opie {
+namespace Ui {
/**
* This class places a OFileSelector inside a QDialog.
* It provides static method for letting a user chose
* a file for either opening or saving.
* Most of the time the c'tor will not be used instead using
* the static member functions is prefered.
*
* <pre>
* QMap<QString, QStringList> mimeTypes;
* QStringList types;
* types << "text[slash]* ";
* mimeTypes.insert( tr("Text"), types );
* mimeTypes.insert( tr("All"), " * / * " ); // remove the spaces in the 2nd comment
* QString fileName= OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL,
* "foo","bar", mimeTypes);
* </pre>
*
* @short A small QDialog swalloing a FileSelector
* @see QDialog
* @see OFileSelector
* @version 0.1-unfinished
* @author Holger Freyther ( zecke@handhelds.org )
*/
class OFileDialog : public QDialog
{
Q_OBJECT
public:
OFileDialog(const QString &caption,
QWidget *, int mode, int selector,
const QString &dirName,
const QString &fileName = QString::null,
const MimeTypes &mimetypes = MimeTypes() );
QString mimetype() const;
QString fileName() const;
DocLnk selectedDocument()const;
// static methods
static QString getOpenFileName(int selector,
const QString& startDir = QString::null,
const QString &fileName = QString::null,
const MimeTypes& mime = MimeTypes(),
QWidget *wid = 0,
const QString &caption = QString::null );
static QString getSaveFileName(int selector,
const QString& startDir = QString::null,
const QString& fileName = QString::null,
const MimeTypes& mimefilter = MimeTypes(),
QWidget *wid = 0,
const QString &caption = QString::null );
//let's OFileSelector catch up first
//static QString getExistingDirectory(const QString& startDir = QString::null,
//QWidget *parent = 0, const QString& caption = QString::null );
private:
class OFileDialogPrivate;
OFileDialogPrivate *d;
OFileSelector *file;
private slots:
void slotFileSelected( const QString & );
void slotDirSelected(const QString & );
void slotSelectorOk();
};
-};
+}
+}
#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
@@ -1,155 +1,158 @@
/*
               =. This file is part of the OPIE Project
             .=l. Copyright (C) 2002,2003 Holger Freyther <zecke@handhelds.org>
           .>+-=
 _;:,     .>    :=|. This library is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This library is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
/* hacky but we need to get FileSelector::filter */
#define private public
#include <qpe/fileselector.h>
#undef private
#include "ofileselector_p.h"
/* OPIE */
#include <opie2/ofileselector.h>
#include <qpe/qpeapplication.h>
#include <qpe/mimetype.h>
#include <qpe/resource.h>
#include <qpe/storage.h>
/* QT */
#include <qcombobox.h>
#include <qdir.h>
#include <qhbox.h>
#include <qheader.h>
#include <qlabel.h>
#include <qlayout.h>
#include <qlineedit.h>
#include <qlistview.h>
#include <qpopupmenu.h>
#include <qwidgetstack.h>
#include <qregexp.h>
#include <qobjectlist.h>
-using namespace Opie;
+using namespace Opie::Ui::Private;
+namespace Opie {
+namespace Ui {
+namespace Private {
OFileViewInterface::OFileViewInterface( OFileSelector* selector )
: m_selector( selector )
{}
OFileViewInterface::~OFileViewInterface()
{}
QString OFileViewInterface::name()const
{
return m_name;
}
void OFileViewInterface::setName( const QString& name )
{
m_name = name;
}
OFileSelector* OFileViewInterface::selector()const
{
return m_selector;
}
DocLnk OFileViewInterface::selectedDocument()const
{
return DocLnk( selectedName() );
}
bool OFileViewInterface::showNew()const
{
return selector()->showNew();
}
bool OFileViewInterface::showClose()const
{
return selector()->showClose();
}
MimeTypes OFileViewInterface::mimeTypes()const
{
return selector()->mimeTypes();
}
QStringList OFileViewInterface::currentMimeType()const
{
return selector()->currentMimeType();
}
void OFileViewInterface::activate( const QString& )
{
// not implemented here
}
void OFileViewInterface::ok()
{
emit selector()->ok();
}
void OFileViewInterface::cancel()
{
emit selector()->cancel();
}
void OFileViewInterface::closeMe()
{
emit selector()->closeMe();
}
void OFileViewInterface::fileSelected( const QString& str)
{
emit selector()->fileSelected( str);
}
void OFileViewInterface::fileSelected( const DocLnk& lnk)
{
emit selector()->fileSelected( lnk );
}
void OFileViewInterface::setCurrentFileName( const QString& str )
{
selector()->m_lneEdit->setText( str );
}
QString OFileViewInterface::currentFileName()const
{
return selector()->m_lneEdit->text();
}
QString OFileViewInterface::startDirectory()const
{
return selector()->m_startDir;
}
ODocumentFileView::ODocumentFileView( OFileSelector* selector )
:OFileViewInterface( selector )
{
m_selector = 0;
@@ -717,192 +720,194 @@ bool OFileViewFileListView::compliesMime( const QString& str)
return true;
}
return false;
}
/*
* The listView giving access to the file system!
*/
class OFileViewFileSystem : public OFileViewInterface
{
public:
OFileViewFileSystem( OFileSelector* );
~OFileViewFileSystem();
QString selectedName() const;
QString selectedPath() const;
QString directory()const;
void reread();
int fileCount()const;
QWidget* widget( QWidget* parent );
void activate( const QString& );
private:
OFileViewFileListView* m_view;
bool m_all : 1;
};
OFileViewFileSystem::OFileViewFileSystem( OFileSelector* sel)
: OFileViewInterface( sel )
{
m_view = 0;
m_all = false;
}
OFileViewFileSystem::~OFileViewFileSystem()
{
}
QString OFileViewFileSystem::selectedName()const
{
if (!m_view )
return QString::null;
QString cFN=currentFileName();
if (cFN.startsWith("/")) return cFN;
return m_view->currentDir() + "/" + cFN;
}
QString OFileViewFileSystem::selectedPath()const
{
return QString::null;
}
QString OFileViewFileSystem::directory()const
{
if (!m_view)
return QString::null;
OFileSelectorItem* item = m_view->currentItem();
if (!item )
return QString::null;
return QDir(item->directory() ).absPath();
}
void OFileViewFileSystem::reread()
{
if (!m_view)
return;
m_view->reread( m_all );
}
int OFileViewFileSystem::fileCount()const
{
if (!m_view )
return -1;
return m_view->fileCount();
}
QWidget* OFileViewFileSystem::widget( QWidget* parent )
{
if (!m_view )
{
m_view = new OFileViewFileListView( parent, startDirectory(), selector() );
}
return m_view;
}
void OFileViewFileSystem::activate( const QString& str)
{
m_all = (str != QObject::tr("Files") );
}
+
+}
/* Selector */
/**
* @short new and complete c'tor
*
* Create a OFileSelector to let the user select a file. It can
* either be used to open a file, select a save name in a dir or
* as a dropin for the FileSelector.
*
* <pre>
* QMap<QString, QStringList> mimeTypes;
* QStringList types;
* types << "text@slash* ";
* types << "audio@slash*";
* mimeTypes.insert( tr("Audio and Text"), types );
* mimeTypes.insert( tr("All"), "*@slash*);
*
* now you could create your fileselector
* </pre>
*
*
* @param parent the parent of this widget
* @param mode The mode from the enum Mode (Open,Save,FILESELECTOR)
* @param sel The selector to be used
* @param dirName The name of the dir to start int
* @param fileName The fileName placed in the fileselector lineedit
* @param mimetypes The MimeType map of used mimetypes
* @param showNew Show a New Button. Most likely to be used in the FileSelector view.
* @param showClose Show a Close Button. Most likely to be used in FileSelector view.
*
*/
OFileSelector::OFileSelector( QWidget* parent, int mode, int sel,
const QString& dirName, const QString& fileName,
const MimeTypes& mimetypes,
bool showNew, bool showClose)
:QWidget( parent, "OFileSelector" )
{
m_current = 0;
m_shNew = showNew;
m_shClose = showClose;
m_mimeType = mimetypes;
m_startDir = dirName;
m_mode = mode;
m_selector = sel;
initUI();
m_lneEdit->setText( fileName );
initMime();
initViews();
QString str;
switch ( m_selector )
{
default:
case Normal:
str = QObject::tr("Documents");
m_cmbView->setCurrentItem( 0 );
break;
case Extended:
str = QObject::tr("Files");
m_cmbView->setCurrentItem( 1 );
break;
case ExtendedAll:
str = QObject::tr("All Files");
m_cmbView->setCurrentItem( 2 );
break;
}
slotViewChange( str );
}
/**
* This a convience c'tor to just substitute the use of FileSelector
*/
OFileSelector::OFileSelector( const QString& mimeFilter, QWidget* parent, const char* name,
bool showNew, bool showClose )
: QWidget( parent, name )
{
m_current = 0;
m_shNew = showNew;
m_shClose = showClose;
m_startDir = QPEApplication::documentDir();
if (!mimeFilter.isEmpty() )
m_mimeType.insert(mimeFilter, QStringList::split(";", mimeFilter ) );
m_mode = OFileSelector::FileSelector;
m_selector = OFileSelector::Normal;
initUI();
initMime();
initViews();
m_cmbView->setCurrentItem( 0 );
slotViewChange( QObject::tr("Documents") );
}
@@ -1071,96 +1076,98 @@ OFileViewInterface* OFileSelector::currentView()const
bool OFileSelector::showNew()const
{
return m_shNew;
}
bool OFileSelector::showClose()const
{
return m_shClose;
}
MimeTypes OFileSelector::mimeTypes()const
{
return m_mimeType;
}
/**
* @return the Mode of the OFileSelector
*/
int OFileSelector::mode()const
{
return m_mode;
}
/**
* @return the Selector of the OFileSelector
*/
int OFileSelector::selector()const
{
return m_selector;
}
QStringList OFileSelector::currentMimeType()const
{
return m_mimeType[m_cmbMime->currentText()];
}
void OFileSelector::slotMimeTypeChanged()
{
reread();
}
void OFileSelector::slotDocLnkBridge( const DocLnk& lnk)
{
m_lneEdit->setText( lnk.name() );
emit fileSelected( lnk );
emit fileSelected( lnk.name() );
}
void OFileSelector::slotFileBridge( const QString& str)
{
DocLnk lnk( str );
emit fileSelected( lnk );
}
void OFileSelector::slotViewChange( const QString& view )
{
OFileViewInterface* interface = m_views[view];
if (!interface)
return;
interface->activate( view );
if (m_current)
m_stack->removeWidget( m_current->widget( m_stack ) );
static int id = 1;
m_stack->addWidget( interface->widget(m_stack), id );
m_stack->raiseWidget( id );
interface->reread();
m_current = interface;
id++;
}
void OFileSelector::setNewVisible( bool b )
{
m_shNew = b;
currentView()->reread();
}
void OFileSelector::setCloseVisible( bool b )
{
m_shClose = b;
currentView()->reread();
}
void OFileSelector::setNameVisible( bool b )
{
if ( b )
m_nameBox->show();
else
m_nameBox->hide();
}
+}
+}
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
@@ -1,219 +1,222 @@
/*
               =. This file is part of the OPIE Project
             .=l. Copyright (C) 2002,2003 Holger Freyther <zecke@handhelds.org>
           .>+-=
 _;:,     .>    :=|. This library is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This library is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
/*
This is based on code and ideas of
L. J. Potter ljp@llornkcor.com
Thanks a lot
*/
#ifndef OFILESELECTOR_H
#define OFILESELECTOR_H
/* OPIE */
#include <qpe/applnk.h>
/* QT */
#include <qlist.h>
#include <qwidget.h>
#include <qmap.h>
#include <qvaluelist.h>
#include <qstringlist.h>
class QLineEdit;
class QComboBox;
class QWidgetStack;
class QHBox;
typedef QMap<QString, QStringList> MimeTypes;
-namespace Opie
-{
+namespace Opie {
+namespace Ui {
+namespace Private {
class OFileViewInterface;
class OFileViewFileListView;
+}
/**
* @short a dropin replacement for the FileSelector
*
* This class is first used insert the OFileDialog.
* It supports multiple view and mimetype filtering for now.
*
* @see OFileDialog
* @see FileSelector
* @author zecke
* @version 0.1
*/
class OFileSelector : public QWidget
{
Q_OBJECT
- friend class Opie::OFileViewInterface;
- friend class Opie::OFileViewFileListView;
+ friend class Private::OFileViewInterface;
+ friend class Private::OFileViewFileListView;
public:
/**
* The Mode of the Fileselector
* Open = Open A File
* Save = Save a File
* FILESELECTOR = As A GUI in a screen to select a file
*/
enum Mode { Open=1, Save=2, FileSelector=4, OPEN=1, SAVE=2, FILESELECTOR=4 };
// enum OldMode { OPEN=1, SAVE=2, FILESELECTOR = 4 };
/**
* Normal = The old FileSelector
* Extended = Dir View
* ExtendedAll = Dir View with all hidden files
* Default = What the vendor considers best
*/
enum Selector { Normal = 0, Extended=1, ExtendedAll =2, Default=3, NORMAL=0,EXTENDED=1, EXTENDED_ALL =2, DEFAULT=3 };
// enum OldSelector { NORMAL = 0, EXTENDED =1, EXTENDED_ALL = 2};
OFileSelector(QWidget* parent, int mode, int selector,
const QString& dirName,
const QString& fileName,
const MimeTypes& mimetypes = MimeTypes(),
bool newVisible = FALSE, bool closeVisible = FALSE );
OFileSelector(const QString& mimeFilter, QWidget* parent,
const char* name = 0, bool newVisible = TRUE, bool closeVisible = FALSE );
~OFileSelector();
const DocLnk* selected();
QString selectedName()const;
QString selectedPath()const;
QString directory()const;
DocLnk selectedDocument()const;
int fileCount()const;
void reread();
int mode()const;
int selector()const;
/**
* Set the Icon visible
* @param b Show or Hide the New Button
*/
void setNewVisible( bool b );
/**
* Set the Icon visible
*/
void setCloseVisible( bool b );
/**
* Set the Name Line visible
*/
void setNameVisible( bool b );
signals:
/**
* dirSelected is emitted whenever changed into a different dir
*/
void dirSelected( const QString& );
/**
* fileSelected is emitted when a file is selected
* it uses a DocLnk as parameter
*/
void fileSelected( const DocLnk& );
/**
* fileSelected is emitted when a file is selected
* the complete path is a parameter
*/
void fileSelected( const QString& );
/**
* Create a new File with a DocLnk
*/
void newSelected( const DocLnk& );
void closeMe();
/**
* Ok is emitted on a Qt::Key_Return or Q::Key_Enter
* in the line edit
*/
void ok();
void cancel();
/* used by the ViewInterface */
private:
bool showNew()const;
bool showClose()const;
MimeTypes mimeTypes()const;
QStringList currentMimeType()const;
private:
/* inits the Widgets */
void initUI();
/* inits the MimeType ComboBox content + connects signals and slots */
void initMime();
/* init the Views :) */
void initViews();
private:
QLineEdit* m_lneEdit; // the LineEdit for the Name
QComboBox *m_cmbView, *m_cmbMime; // two ComboBoxes to select the View and MimeType
QWidgetStack* m_stack; // our widget stack which will contain the views
- OFileViewInterface* currentView() const; // returns the currentView
- OFileViewInterface* m_current; // here is the view saved
+ Private::OFileViewInterface* currentView() const; // returns the currentView
+ Private::OFileViewInterface* m_current; // here is the view saved
bool m_shNew : 1; // should we show New?
bool m_shClose : 1; // should we show Close?
MimeTypes m_mimeType; // list of mimetypes
- QMap<QString, OFileViewInterface*> m_views; // QString translated view name + ViewInterface Ptr
+ QMap<QString, Private::OFileViewInterface*> m_views; // QString translated view name + ViewInterface Ptr
QHBox* m_nameBox; // the LineEdit + Label is hold here
QHBox* m_cmbBox; // this holds the two combo boxes
QString m_startDir;
int m_mode;
int m_selector;
struct Data; // used for future versions
Data *d;
private slots:
void slotMimeTypeChanged();
/* will set the text of the lineedit and emit a fileChanged signal */
void slotDocLnkBridge( const DocLnk& );
void slotFileBridge( const QString& );
void slotViewChange( const QString& );
bool eventFilter (QObject *o, QEvent *e);
};
-};
+}
+}
#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
@@ -1,191 +1,193 @@
/*
               =. This file is part of the OPIE Project
             .=l. Copyright (C) Holger Freyther <zecke@handhelds.org>
           .>+-=
 _;:,     .>    :=|. This library is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This library is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef OFILESELECTOR_PRIVATE_H
#define OFILESELECTOR_PRIVATE_H
/* OPIE */
#include <qpe/applnk.h>
#include <qpe/fileselector.h>
/* QT */
#include <qmap.h>
#include <qstringlist.h>
#include <qwidget.h>
#include <qlistview.h>
/*
* How to avoid having really two different objects
* for Extended and ExtendedAll
* The only difference is the Lister...
* a) static object?
* b) leave some object inside the OFileSelector which can be used?
* c) when switching views tell which view we want o have.. internally we can switch then
*
* I'll take c) -zecke
*/
typedef QMap<QString, QStringList> MimeTypes;
/* the View Interface */
class QFileInfo;
class QToolButton;
-namespace Opie
-{
-
+namespace Opie{
+namespace Ui{
class OFileSelector;
+namespace Private {
class OFileViewInterface
{
public:
OFileViewInterface( OFileSelector* selector );
virtual ~OFileViewInterface();
virtual QString selectedName()const = 0;
virtual QString selectedPath()const = 0;
virtual QString directory()const = 0;
virtual void reread() = 0;
virtual int fileCount()const = 0;
virtual DocLnk selectedDocument()const;
virtual QWidget* widget( QWidget* parent) = 0;
virtual void activate( const QString& );
QString name()const;
protected:
OFileSelector* selector()const;
void setName( const QString& );
bool showNew()const;
bool showClose()const;
MimeTypes mimeTypes()const;
QStringList currentMimeType()const;
QString startDirectory()const;
protected:
void ok();
void cancel();
void closeMe();
void fileSelected( const QString& );
void fileSelected( const DocLnk& );
void setCurrentFileName( const QString& );
QString currentFileName()const;
private:
QString m_name;
OFileSelector* m_selector;
};
/* THE Document View hosting a FileSelector*/
class ODocumentFileView : public OFileViewInterface
{
public:
ODocumentFileView( OFileSelector* selector );
~ODocumentFileView();
QString selectedName() const;
QString selectedPath() const;
QString directory() const;
void reread();
int fileCount()const;
DocLnk selectedDocument()const;
QWidget* widget( QWidget* parent );
private:
mutable FileSelector* m_selector;
};
class OFileSelectorItem : public QListViewItem
{
public:
OFileSelectorItem( QListView* view, const QPixmap& pixmap,
const QString& path, const QString& date,
const QString& size, const QString& mDir,
bool isLocked = false, bool isDir = false );
~OFileSelectorItem();
bool isLocked()const;
bool isDir()const;
QString directory()const;
QString path()const;
QString key(int id, bool )const;
private:
bool m_locked : 1;
bool m_isDir : 1;
QString m_dir;
};
class OFileViewFileListView : public QWidget
{
Q_OBJECT
public:
OFileViewFileListView( QWidget* parent, const QString& dir, OFileSelector* selector );
~OFileViewFileListView();
OFileSelectorItem* currentItem()const;
void reread( bool all = false );
int fileCount()const;
QString currentDir()const;
protected:
bool eventFilter (QObject *o, QEvent *e);
private slots:
void slotNew(); // will emit newSelected
void cdUP();
void cdHome();
void cdDoc();
void changeDir( const QString& );
void slotCurrentChanged( QListViewItem* );
void slotClicked(int, QListViewItem*, const QPoint&, int );
void slotFSActivated(int);
protected:
OFileSelector* selector();
private:
QMap<QString, QString> m_dev;
bool m_all : 1;
OFileSelector* m_sel;
QPopupMenu* m_fsPop;
bool compliesMime( const QString& );
QStringList m_mimes; // used in compy mime
QString m_currentDir;
QToolButton *m_btnNew, *m_btnClose;
void connectSlots();
void addFile( QFileInfo* info, bool symlink = FALSE );
void addDir ( QFileInfo* info, bool symlink = FALSE );
void addSymlink( QFileInfo* info, bool = FALSE );
private:
QListView* m_view;
};
-};
+}
+}
+}
#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 @@
/*
               =. This file is part of the OPIE Project
             .=l. Copyright (C) 2002 Holger Freyther <zecke@handhelds.org>
           .>+-=
 _;:,     .>    :=|. This library is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This library is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef OFILEVIEW_H
#define OFILEVIEW_H
/* QT */
#include <qobject.h>
#include <qwidget.h>
class QFileInfo;
class QDir;
class DocLnk;
-namespace Opie
-{
+namespace Opie {
+namespace Ui {
+namespace Private {
/**
* A OFileView is a specialised View for the
* OFileSelector
* With a View you can chage the user visible
* representation of a OFileLister
* OFileView is just a basic interface which helps you to
* write new views
*/
class OFileView : public QWidget
{
Q_OBJECT
public:
OFileView(QWidget *widget,
const char *name );
OFileView();
virtual void addFile(const QString &mine,
QFileInfo *info,
bool isSymlink = FALSE ) = 0;
virtual void addDir (const QString &mine,
QFileInfo *info,
bool isSymlink = FALSE ) = 0;
virtual void addSymlink(const QString &mime,
QFileInfo *info,
bool isSymlink = FALSE ) = 0;
virtual void cd(const QString &path ) = 0;
signals:
void fileSelected(const QString &);
void fileSelected(const DocLnk & );
void contextMenu();
void changedDir(const QString &);
void changedDir(const QDir & );
};
class OFileViewFactory
{
// Q_OBJECT
public:
OFileViewFactory() {} ;
virtual ~OFileViewFactory() = 0;
OFileView* newView(QWidget *parent, const char *name );
QString name()const;
};
-};
+}
+}
+}
#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,128 +1,128 @@
/*
This file is part of the Opie Project
Copyright (C) Maximillian Reiß <harlekin@handhelds.org>
=. Copyright (C) The Opie Team <opie-devel@handhelds.org>
.=l.
           .>+-=
 _;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include <opie2/oclickablelabel.h>
-using namespace Opie;
+using namespace Opie::Ui;
/**
* This constructs the clickable ButtonLabel
*
* @param parent The parent of this label
* @param name A name of this label @see QObject
* @param fl The windowing flags
*/
OClickableLabel::OClickableLabel(QWidget* parent, const char* name, WFlags fl)
:QLabel(parent,name,fl)
{
textInverted=false;
isToggle=false;
isDown=false;
showState(false);
setFrameShadow(Sunken);
}
/**
* This method makes the label behave as a toggle button
*
* @param t Whether or not to behave like a toggle button
*/
void OClickableLabel::setToggleButton(bool t)
{
isToggle=t;
}
/**
* @internal
*/
void OClickableLabel::mousePressEvent( QMouseEvent * /*e*/ )
{
if (isToggle && isDown)
{
showState(false);
}
else
{
showState(true);
}
}
/**
* @internal
*/
void OClickableLabel::mouseReleaseEvent( QMouseEvent *e )
{
if (rect().contains(e->pos()) && isToggle) isDown=!isDown;
if (isToggle && isDown)
{
showState(true);
}
else
{
showState(false);
}
if (rect().contains(e->pos()))
{
if (isToggle)
{
emit toggled(isDown);
}
emit clicked();
}
}
/**
* @internal
*/
void OClickableLabel::mouseMoveEvent( QMouseEvent *e )
{
if (rect().contains(e->pos()))
{
if (isToggle && isDown)
{
showState(false);
}
else
{
showState(true);
}
}
else
{
if (isToggle && isDown)
{
showState(true);
}
else
{
showState(false);
}
}
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 @@
/*
This file is part of the Opie Project
Copyright (C) Maximillian Reiß <harlekin@handhelds.org>
=. Copyright (C) The Opie Team <opie-devel@handhelds.org>
.=l.
           .>+-=
 _;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef OCLICKABLELABEL_H
#define OCLICKABLELABEL_H
/* QT */
#include <qlabel.h>
-namespace Opie
-{
+namespace Opie{
+namespace Ui {
/**
* This class is a special QLabel which can behave
* as a QPushButton or QToggleButton.
* The reason to use a clickable is if you want to save space
* or you want to skip the border of a normal button
*
* <pre>
* QLabel* lbl = new OClickableLabel( parent, "PushLabel" );
* lbl->setPixmap( "config" );
* QWhatsThis::add( lbl, tr("Click here to do something") );
* </pre>
*
* @short A Label behaving as button
* @author Hakan Ardo, Maximillian Reiß ( harlekin@handhelds.org )
* @see QLabel
* @see QPushButton
* @see QToggleButton
* @version 1.0
*/
class OClickableLabel: public QLabel
{
Q_OBJECT
public:
OClickableLabel(QWidget* parent = 0, const char* name = 0,
WFlags fl = 0);
void setToggleButton(bool t);
protected:
/** @internal */
void mousePressEvent( QMouseEvent *e );
/** @internal */
void mouseReleaseEvent( QMouseEvent *e );
/** @internal */
void mouseMoveEvent( QMouseEvent *e );
public slots:
void setOn(bool on);
signals:
/**
* emitted when the labels gets clicked
*/
void clicked();
/**
* emitted when the labels gets toggled
* @param on the new new state of the label
*/
void toggled(bool on);
private:
bool isToggle : 1;
bool isDown : 1;
bool textInverted : 1;
void showState(bool on);
void setInverted(bool on);
private:
class Private;
Private *d; // private d pointer
};
-};
+}
+}
#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 @@
/*
                This file is part of the Opie Project
              Copyright (C) 2003 Michael 'Mickey' Lauer <mickey@Vanille.de>
=.
.=l.
           .>+-=
 _;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include <opie2/odialog.h>
#warning Make Margin and Spacing device dependend and configurable!
+using namespace Opie::Ui;
+
int ODialog::mMarginSize = 5;
int ODialog::mSpacingSize = 2;
ODialog::ODialog(QWidget *parent, const char *name, bool modal, WFlags f)
:QDialog(parent, name, modal, f)
{
// d = new ODialogPrivate();
}
int ODialog::marginHint()
{
return( mMarginSize );
}
int ODialog::spacingHint()
{
return( mSpacingSize );
}
// 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
@@ -1,91 +1,96 @@
/*
                This file is part of the Opie Project
              (C) 2003 Michael 'Mickey' Lauer <mickey@Vanille.de>
=.
.=l.
           .>+-=
 _;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef ODIALOG_H
#define ODIALOG_H
class QLayoutItem;
#include <qdialog.h>
/**
* Dialog with extended nonmodal support and methods for OPIE standard
* compliance.
*
* The @ref marginHint() and @ref spacingHint() sizes shall be used
* whenever you layout the interior of a dialog. One special note. If
* you make your own action buttons (OK, Cancel etc), the space
* beteween the buttons shall be @ref spacingHint(), whereas the space
* above, below, to the right and to the left shall be @ref marginHint().
* If you add a separator line above the buttons, there shall be a
* @ref marginHint() between the buttons and the separator and a
* @ref marginHint() above the separator as well.
*
* @author Michael 'Mickey' Lauer <mickey@Vanille.de>
*/
// lets fix up Qt instead! Size does matter. -zecke
// while that may be true, reducing maintainance effort for the future does also matter -
// and I believe that maintaining a patch against QtE is more work than our classes -mml
+namespace Opie {
+namespace Ui {
+
class ODialog : public QDialog
{
Q_OBJECT
public:
/**
* Constructor.
*
* Takes the same arguments as @ref QDialog.
*/
ODialog(QWidget *parent = 0, const char *name = 0, bool modal = false, WFlags f = 0);
/**
* Return the number of pixels you shall use between a
* dialog edge and the outermost widget(s) according to the KDE standard.
**/
static int marginHint();
/**
* Return the number of pixels you shall use between
* widgets inside a dialog according to the KDE standard.
*/
static int spacingHint();
private:
static int mMarginSize;
static int mSpacingSize;
class ODialogPrivate;
ODialogPrivate *d;
};
+}
+}
#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,206 +1,206 @@
/*
This file is part of the Opie Project
Copyright (C) Robert Griebl <sandman@handhelds.org>
=. Copyright (C) The Opie Team <opie-devel@handhelds.org>
.=l.
           .>+-=
 _;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
/* OPIE */
#include <opie2/ofontselector.h>
#include <qpe/fontdatabase.h>
/* QT */
#include <qlayout.h>
#include <qlistbox.h>
#include <qcombobox.h>
#include <qlabel.h>
#include <qmultilineedit.h>
-using namespace Opie;
-namespace Opie
-{
+namespace Opie {
+namespace Ui {
+namespace Private {
class OFontSelectorPrivate
{
public:
QListBox * m_font_family_list;
QComboBox * m_font_style_list;
QComboBox * m_font_size_list;
QMultiLineEdit *m_preview;
bool m_pointbug : 1;
FontDatabase m_fdb;
};
-};
-
-namespace
-{
-
class FontListItem : public QListBoxText
{
public:
FontListItem ( const QString &t, const QStringList &styles, const QValueList<int> &sizes ) : QListBoxText()
{
m_name = t;
m_styles = styles;
m_sizes = sizes;
QString str = t;
str [0] = str [0]. upper();
setText ( str );
}
QString family() const
{
return m_name;
}
const QStringList &styles() const
{
return m_styles;
}
const QValueList<int> &sizes() const
{
return m_sizes;
}
private:
QStringList m_styles;
QValueList<int> m_sizes;
QString m_name;
};
+}
+}
+}
+
+using namespace Opie::Ui;
+using namespace Opie::Ui::Private;
static int findItemCB( QComboBox *box, const QString &str )
{
for ( int i = 0; i < box->count(); i++ )
{
if ( box->text ( i ) == str )
return i;
}
return -1;
}
-}
/* static same as anon. namespace */
static int qt_version()
{
const char *qver = qVersion();
return ( qver [0] - '0' ) * 100 + ( qver [2] - '0' ) * 10 + ( qver [4] - '0' );
}
/**
* Constructs the Selector object
* @param withpreview If a font preview should be given
* @param parent The parent of the Font Selector
* @param name The name of the object
* @param fl WidgetFlags
*/
OFontSelector::OFontSelector( bool withpreview, QWidget *parent, const char *name, WFlags fl ) : QWidget ( parent, name, fl )
{
d = new OFontSelectorPrivate();
QGridLayout *gridLayout = new QGridLayout( this, 0, 0, 4, 4 );
gridLayout->setRowStretch( 4, 10 );
d->m_font_family_list = new QListBox( this, "FontListBox" );
gridLayout->addMultiCellWidget( d->m_font_family_list, 0, 4, 0, 0 );
connect( d->m_font_family_list, SIGNAL( highlighted(int) ), this, SLOT( fontFamilyClicked(int) ) );
QLabel *label = new QLabel( tr( "Style" ), this );
gridLayout->addWidget( label, 0, 1 );
d->m_font_style_list = new QComboBox( this, "StyleListBox" );
connect( d->m_font_style_list, SIGNAL( activated(int) ), this, SLOT( fontStyleClicked(int) ) );
gridLayout->addWidget( d->m_font_style_list, 1, 1 );
label = new QLabel( tr( "Size" ), this );
gridLayout->addWidget( label, 2, 1 );
d->m_font_size_list = new QComboBox( this, "SizeListBox" );
connect( d->m_font_size_list, SIGNAL( activated(int) ),
this, SLOT( fontSizeClicked(int) ) );
gridLayout->addWidget( d->m_font_size_list, 3, 1 );
d->m_pointbug = ( qt_version() <= 233 );
if ( withpreview )
{
d->m_preview = new QMultiLineEdit ( this, "Preview" );
d->m_preview->setAlignment ( AlignCenter );
d->m_preview->setWordWrap ( QMultiLineEdit::WidgetWidth );
d->m_preview->setMargin ( 3 );
d->m_preview->setText ( tr( "The Quick Brown Fox Jumps Over The Lazy Dog" ));
gridLayout->addRowSpacing ( 5, 4 );
gridLayout->addMultiCellWidget ( d->m_preview, 6, 6, 0, 1 );
gridLayout->setRowStretch ( 6, 5 );
}
else
d->m_preview = 0;
loadFonts ( d->m_font_family_list );
}
OFontSelector::~OFontSelector()
{
delete d;
}
/**
* This methods tries to set the font
* @param f The wishes font
* @return success or failure
*/
bool OFontSelector::setSelectedFont ( const QFont &f )
{
return setSelectedFont ( f. family(), d->m_fdb. styleString ( f ), f. pointSize(), QFont::encodingName ( f. charSet()));
}
/**
* This is an overloaded method @see setSelectedFont
* @param familyStr The family of the font
* @param styleStr The style of the font
* @param sizeVal The size of font
* @param charset The charset to be used. Will be deprecated by QT3
*/
bool OFontSelector::setSelectedFont( const QString &familyStr, const QString &styleStr, int sizeVal, const QString & charset )
{
QString sizeStr = QString::number ( sizeVal );
QListBoxItem *family = d->m_font_family_list->findItem ( familyStr );
if ( !family )
family = d->m_font_family_list->findItem ( "Helvetica" );
if ( !family )
family = d->m_font_family_list->firstItem();
d->m_font_family_list->setCurrentItem ( family );
fontFamilyClicked ( d->m_font_family_list->index ( family ));
int style = findItemCB ( d->m_font_style_list, styleStr );
@@ -333,96 +333,97 @@ void OFontSelector::fontFamilyClicked ( int index )
FontListItem *fli = (FontListItem *) d->m_font_family_list->item ( index );
d->m_font_style_list->clear();
d->m_font_style_list->insertStringList ( fli->styles());
d->m_font_style_list->setEnabled ( !fli->styles(). isEmpty());
int i;
i = findItemCB ( d->m_font_style_list, oldstyle );
if ( i < 0 )
i = findItemCB ( d->m_font_style_list, "Regular" );
if (( i < 0 ) && ( d->m_font_style_list->count() > 0 ))
i = 0;
if ( i >= 0 )
{
d->m_font_style_list->setCurrentItem ( i );
fontStyleClicked ( i );
}
d->m_font_size_list->clear();
QValueList<int> sl = fli->sizes();
for ( QValueList<int>::Iterator it = sl. begin(); it != sl. end(); ++it )
d->m_font_size_list->insertItem ( QString::number ( *it ));
i = findItemCB ( d->m_font_size_list, oldsize );
if ( i < 0 )
i = findItemCB ( d->m_font_size_list, "10" );
if (( i < 0 ) && ( d->m_font_size_list->count() > 0 ))
i = 0;
if ( i >= 0 )
{
d->m_font_size_list->setCurrentItem ( i );
fontSizeClicked ( i );
}
changeFont();
}
void OFontSelector::fontStyleClicked ( int /*index*/ )
{
changeFont();
}
void OFontSelector::fontSizeClicked ( int /*index*/ )
{
changeFont();
}
void OFontSelector::changeFont()
{
QFont f = selectedFont();
if ( d->m_preview )
d->m_preview->setFont ( f );
emit fontSelected ( f );
}
/**
* Return the selected font
*/
QFont OFontSelector::selectedFont()
{
int ffa = d->m_font_family_list->currentItem();
int fst = d->m_font_style_list->currentItem();
int fsi = d->m_font_size_list->currentItem();
FontListItem *fli = (FontListItem *) d->m_font_family_list->item ( ffa );
if ( fli )
{
return d->m_fdb. font ( fli->family(), \
fst >= 0 ? fli->styles() [fst] : QString::null, \
fsi >= 0 ? fli->sizes() [fsi] : 10, \
d->m_fdb. charSets ( fli->family()) [0] );
}
else
return QFont();
}
void OFontSelector::resizeEvent ( QResizeEvent *re )
{
if ( d->m_preview )
{
d->m_preview->setMinimumHeight ( 1 );
d->m_preview->setMaximumHeight ( 32767 );
}
QWidget::resizeEvent ( re );
if ( d->m_preview )
d->m_preview->setFixedHeight ( d->m_preview->height());
}
+
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 @@
/*
This file is part of the Opie Project
Copyright (C) Robert Griebl <sandman@handhelds.org>
=. Copyright (C) The Opie Team <opie-devel@handhelds.org>
.=l.
           .>+-=
 _;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef OFONTSELECTOR_H
#define OFONTSELECTOR_H
/* QT */
#include <qwidget.h>
class QListBox;
-namespace Opie
-{
-
+namespace Opie {
+namespace Ui {
+namespace Private {
class OFontSelectorPrivate;
+}
/**
* This class lets you chose a Font out of a list of Fonts.
* It can show a preview too. This selector will use all available
* fonts
*
*
* @short A widget to select a font
* @see QWidget
* @see QFont
* @author Rober Griebl
*/
class OFontSelector : public QWidget
{
Q_OBJECT
public:
OFontSelector ( bool withpreview, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
virtual ~OFontSelector ( );
bool selectedFont ( QString &family, QString &style, int &size );
bool selectedFont ( QString &family, QString &style, int &size, QString &charset );
QFont selectedFont ( );
bool setSelectedFont ( const QFont & );
bool setSelectedFont ( const QString &family, const QString &style, int size, const QString &charset = 0 );
QString fontFamily ( ) const;
QString fontStyle ( ) const;
int fontSize ( ) const;
QString fontCharSet ( ) const;
signals:
/**
* This signal gets emitted when a font got chosen
*/
void fontSelected ( const QFont & );
protected slots:
/** @internal */
virtual void fontFamilyClicked ( int );
/** @internal */
virtual void fontStyleClicked ( int );
/** @internal */
virtual void fontSizeClicked ( int );
protected:
virtual void resizeEvent ( QResizeEvent *re );
private:
void loadFonts ( QListBox * );
void changeFont ( );
private:
- OFontSelectorPrivate *d;
+ Private::OFontSelectorPrivate *d;
};
-};
+}
+}
#endif
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,139 +1,143 @@
/* This file is part of the KDE libraries
Copyright (C) 1998, 1999, 2001, 2002 Daniel M. Duley <mosfet@kde.org>
(C) 1998, 1999 Christian Tibirna <ctibirna@total.net>
(C) 1998, 1999 Dirk A. Mueller <mueller@kde.org>
(C) 2000 Josef Weidendorfer <weidendo@in.tum.de>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
// $Id$
#include <math.h>
#include <qimage.h>
#include <stdlib.h>
#include <opie2/oimageeffect.h>
#include <opie2/odebug.h>
#define MaxRGB 255L
#define DegreesToRadians(x) ((x)*M_PI/180.0)
using namespace std;
+using namespace Opie::Core;
+
+namespace Opie {
+namespace Ui {
inline unsigned int intensityValue(unsigned int color)
{
return((unsigned int)((0.299*qRed(color) +
0.587*qGreen(color) +
0.1140000000000001*qBlue(color))));
}
//======================================================================
//
// Gradient effects
//
//======================================================================
QImage OImageEffect::gradient(const QSize &size, const QColor &ca,
const QColor &cb, GradientType eff, int ncols)
{
int rDiff, gDiff, bDiff;
int rca, gca, bca, rcb, gcb, bcb;
QImage image(size, 32);
if (size.width() == 0 || size.height() == 0) {
odebug << "WARNING: OImageEffect::gradient: invalid image" << oendl;
return image;
}
register int x, y;
rDiff = (rcb = cb.red()) - (rca = ca.red());
gDiff = (gcb = cb.green()) - (gca = ca.green());
bDiff = (bcb = cb.blue()) - (bca = ca.blue());
if( eff == VerticalGradient || eff == HorizontalGradient ){
uint *p;
uint rgb;
register int rl = rca << 16;
register int gl = gca << 16;
register int bl = bca << 16;
if( eff == VerticalGradient ) {
int rcdelta = ((1<<16) / size.height()) * rDiff;
int gcdelta = ((1<<16) / size.height()) * gDiff;
int bcdelta = ((1<<16) / size.height()) * bDiff;
for ( y = 0; y < size.height(); y++ ) {
p = (uint *) image.scanLine(y);
rl += rcdelta;
gl += gcdelta;
bl += bcdelta;
rgb = qRgb( (rl>>16), (gl>>16), (bl>>16) );
for( x = 0; x < size.width(); x++ ) {
*p = rgb;
p++;
}
}
}
else { // must be HorizontalGradient
unsigned int *o_src = (unsigned int *)image.scanLine(0);
unsigned int *src = o_src;
int rcdelta = ((1<<16) / size.width()) * rDiff;
int gcdelta = ((1<<16) / size.width()) * gDiff;
int bcdelta = ((1<<16) / size.width()) * bDiff;
for( x = 0; x < size.width(); x++) {
rl += rcdelta;
gl += gcdelta;
bl += bcdelta;
*src++ = qRgb( (rl>>16), (gl>>16), (bl>>16));
}
src = o_src;
// Believe it or not, manually copying in a for loop is faster
// than calling memcpy for each scanline (on the order of ms...).
// I think this is due to the function call overhead (mosfet).
for (y = 1; y < size.height(); ++y) {
p = (unsigned int *)image.scanLine(y);
src = o_src;
for(x=0; x < size.width(); ++x)
*p++ = *src++;
}
}
@@ -3672,97 +3676,98 @@ QImage OImageEffect::blur(QImage &src, double factor)
Blur(2); Blur(weight); Blur(2);
s=p+2*src.width();
Blur(1); Blur(2); Blur(1);
*q = qRgba((unsigned char)((total_red+(quantum/2))/quantum),
(unsigned char)((total_green+(quantum/2))/quantum),
(unsigned char)((total_blue+(quantum/2))/quantum),
(unsigned char)((total_opacity+(quantum/2))/quantum));
p++;
q++;
}
p++;
*q++=(*p);
}
}
else{ // PsudeoClass source image
unsigned char *p, *p2, *p3, *s;
unsigned int *cTable = src.colorTable();
int scanLineIdx;
for(y=0; y < src.height(); ++y){
scanLineIdx = QMIN(QMAX(y-1,0),src.height()-3);
p = (unsigned char *)src.scanLine(scanLineIdx);
p2 = (unsigned char *)src.scanLine(scanLineIdx+1);
p3 = (unsigned char *)src.scanLine(scanLineIdx+2);
q = (unsigned int *)dest.scanLine(y);
// blur this row of pixels.
*q++=(*(cTable+(*p2)));
for(x=1; x < src.width()-1; ++x){
// compute weighted average of target pixel color components.
total_red=0.0;
total_green=0.0;
total_blue=0.0;
total_opacity=0.0;
s=p;
Blur256(1); Blur256(2); Blur256(1);
s=p2;
Blur256(2); Blur256(weight); Blur256(2);
s=p3;
Blur256(1); Blur256(2); Blur256(1);
*q = qRgba((unsigned char)((total_red+(quantum/2))/quantum),
(unsigned char)((total_green+(quantum/2))/quantum),
(unsigned char)((total_blue+(quantum/2))/quantum),
(unsigned char)((total_opacity+(quantum/2))/quantum));
p++;
p2++;
p3++;
q++;
}
p++;
*q++=(*(cTable+(*p)));
}
}
return(dest);
}
// High quality, expensive HSV contrast. You can do a faster one by just
// taking a grayscale threshold (ie: 128) and incrementing RGB color
// channels above it and decrementing those below it, but this gives much
// better results. (mosfet 12/28/01)
void OImageEffect::contrastHSV(QImage &img, bool sharpen)
{
int i, sign;
unsigned int *data;
int count;
double brightness, scale, theta;
QColor c;
int h, s, v;
sign = sharpen ? 1 : -1;
scale=0.5000000000000001;
if(img.depth() > 8){
count = img.width()*img.height();
data = (unsigned int *)img.bits();
}
else{
count = img.numColors();
data = (unsigned int *)img.colorTable();
}
for(i=0; i < count; ++i){
c.setRgb(data[i]);
c.hsv(&h, &s, &v);
brightness = v/255.0;
theta=(brightness-0.5)*M_PI;
brightness+=scale*(((scale*((sin(theta)+1.0)))-brightness)*sign);
if (brightness > 1.0)
brightness=1.0;
else
if (brightness < 0)
brightness=0.0;
v = (int)(brightness*255);
c.setHsv(h, s, v);
data[i] = qRgba(c.red(), c.green(), c.blue(), qAlpha(data[i]));
}
}
-
+}
+}
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,137 +1,139 @@
//FIXME: Revise for Opie - do we really need such fancy stuff on PDA's?
//FIXME: Maybe not on SL5xxx, but surely on C700 :))
//FIXME: I think we don#t need that -zecke
/* This file is part of the KDE libraries
Copyright (C) 1998, 1999, 2001, 2002 Daniel M. Duley <mosfet@interaccess.com>
(C) 1998, 1999 Christian Tibirna <ctibirna@total.net>
(C) 1998, 1999 Dirk A. Mueller <mueller@kde.org>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
// $Id$
#ifndef OIMAGEEFFECT_H
#define OIMAGEEFFECT_H
class QImage;
class QSize;
class QColor;
+namespace Opie {
+namespace Ui {
/**
* This class includes various @ref QImage based graphical effects.
*
* Everything is
* static, so there is no need to create an instance of this class. You can
* just call the static methods. They are encapsulated here merely to provide
* a common namespace.
*/
class OImageEffect
{
public:
enum GradientType { VerticalGradient, HorizontalGradient,
DiagonalGradient, CrossDiagonalGradient,
PyramidGradient, RectangleGradient,
PipeCrossGradient, EllipticGradient };
enum RGBComponent { Red, Green, Blue, Gray, All };
enum Lighting {NorthLite, NWLite, WestLite, SWLite,
SouthLite, SELite, EastLite, NELite};
enum ModulationType { Intensity, Saturation, HueShift, Contrast };
enum NoiseType { UniformNoise=0, GaussianNoise, MultiplicativeGaussianNoise,
ImpulseNoise, LaplacianNoise, PoissonNoise};
enum RotateDirection{ Rotate90, Rotate180, Rotate270 };
/**
* Create a gradient from color a to color b of the specified type.
*
* @param size The desired size of the gradient.
* @param ca Color a
* @param cb Color b
* @param type The type of gradient.
* @param ncols The number of colors to use when not running on a
* truecolor display. The gradient will be dithered to this number of
* colors. Pass 0 to prevent dithering.
*/
static QImage gradient(const QSize &size, const QColor &ca,
const QColor &cb, GradientType type, int ncols=3);
/**
* Create an unbalanced gradient.
* An unbalanced gradient is a gradient where the transition from
* color a to color b is not linear, but in this case, exponential.
*
* @param size The desired size of the gradient.
* @param ca Color a
* @param cb Color b
* @param type The type of gradient.
* @param xfactor The x decay length. Use a value between -200 and 200.
* @param yfactor The y decay length.
* @param ncols The number of colors. See OPixmapEffect:gradient.
*/
static QImage unbalancedGradient(const QSize &size, const QColor &ca,
const QColor &cb, GradientType type, int xfactor = 100,
int yfactor = 100, int ncols = 3);
/**
* Blends a color into the destination image, using an opacity
* value for blending one into another. Very fast direct pixel
* manipulation is used.
*
* @author Karol Szwed (gallium@kde.org)
* @param clr source color to be blended into the destination image.
* @param dst destination image in which the source will be blended into.
* @param opacity opacity (in percent) which determines how much the source
* color will be blended into the destination image.
* @return The destination image (dst) containing the result.
*/
static QImage& blend(const QColor& clr, QImage& dst, float opacity);
/**
* Blend the src image into the destination image, using an opacity
* value for blending one into another. Very fast direct pixel
* manipulation is used.
*
* @author Karol Szwed (gallium@kde.org)
* @param src source image to be blended into the destination image.
* @param dst destination image in which the source will be blended into.
* @param opacity opacity (in percent) which determines how much the source
* image will be blended into the destination image.
* @return The destination image (dst) containing the result.
*/
static QImage& blend(QImage& src, QImage& dst, float opacity);
/**
* Blend the provided image into a background of the indicated color.
*
* @param initial_intensity this parameter takes values from -1 to 1:
* a) if positive: how much to fade the image in its
* less affected spot
* b) if negative: roughly indicates how much of the image
* remains unaffected
@@ -463,97 +465,100 @@ public:
* @param background An RGBA value to use for the background. After the
* effect some pixels may be "empty". This value is used for those pixels.
* @return The imploded image. The original is not changed.
*/
static QImage implode(QImage &src, double factor=30.0,
unsigned int background = 0xFFFFFFFF);
/**
* Produces an oil painting effect.
*
* @author Daniel M. Duley (mosfet)
* @param src The QImage to process.
* @param radius The radius of the pixel neighborhood used in applying the
* effect.
* @return The new image. The original is not changed.
*/
static QImage oilPaint(QImage &src, int radius=3);
/**
* Sharpens the pixels in the image using pixel neighborhoods.
*
* @author Daniel M. Duley (mosfet)
* @param src The QImage to process.
* @param factor The percent weight to give to the center pixel.
* @return The sharpened image. The original is not changed.
*/
static QImage sharpen(QImage &src, double factor=30.0);
/**
* Randomly displaces pixels.
*
* @author Daniel M. Duley (mosfet)
* @param src The QImage to process.
* @param amount The vicinity for choosing a random pixel to swap.
* @return The image with pixels displaced. The original is not changed.
*/
static QImage spread(QImage &src, unsigned int amount=3);
/**
* Shades the image using a distance light source.
*
* @author Daniel M. Duley (mosfet)
* @param src The QImage to process.
* @param color_shading If true do color shading, otherwise do grayscale.
* @param azimuth Determines the light source and direction.
* @param elevation Determines the light source and direction.
* @return The shaded image. The original is not changed.
*/
static QImage shade(QImage &src, bool color_shading=true, double azimuth=30.0,
double elevation=30.0);
/**
* Swirls the image by a specified amount
*
* @author Daniel M. Duley (mosfet)
* @param src The QImage to process.
* @param degrees The tightness of the swirl.
* @param background An RGBA value to use for the background. After the
* effect some pixels may be "empty". This value is used for those pixels.
* @return The swirled image. The original is not changed.
*/
static QImage swirl(QImage &src, double degrees=50.0, unsigned int background =
0xFFFFFFFF);
/**
* Modifies the pixels along a sine wave.
*
* @author Daniel M. Duley (mosfet)
* @param src The QImage to process.
* @param amplitude The amplitude of the sine wave.
* @param wavelength The frequency of the sine wave.
* @return The new image. The original is not changed.
*/
static QImage wave(QImage &src, double amplitude=25.0, double frequency=150.0,
unsigned int background = 0xFFFFFFFF);
private:
/**
* Helper function to fast calc some altered (lighten, shaded) colors
*
*/
static unsigned int lHash(unsigned int c);
static unsigned int uHash(unsigned int c);
/**
* Helper function to find the nearest color to the RBG triplet
*/
static int nearestColor( int r, int g, int b, const QColor *pal, int size );
static void hull(const int x_offset, const int y_offset, const int polarity,
const int width, const int height,
unsigned int *f, unsigned int *g);
static unsigned int generateNoise(unsigned int pixel, NoiseType type);
static unsigned int interpolateColor(QImage *image, double x, double y,
unsigned int background);
};
+}
+}
+
#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,134 +1,139 @@
/*
                This file is part of the Opie Project
=. (C) 2003-2004 Michael 'Mickey' Lauer <mickey@Vanille.de>
.=l.
           .>+-=
 _;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
/* QT */
#include <qpixmap.h>
/* OPIE */
#include <opie2/odebug.h>
#include <opie2/olistview.h>
+using namespace Opie::Core;
+
+
+namespace Opie {
+namespace Ui {
/*======================================================================================
* OListView
*======================================================================================*/
OListView::OListView( QWidget *parent, const char *name )
:QListView( parent, name )
{
//FIXME: get from global settings and calculate ==> see oglobalsettings.*
m_alternateBackground = QColor( 238, 246, 255 );
m_columnSeparator = QPen( QColor( 150, 160, 170 ), 0, DotLine );
m_fullWidth = true;
connect( this, SIGNAL(expanded(QListViewItem*)), SLOT(expand(QListViewItem*)));
}
OListView::~OListView()
{
}
void OListView::setFullWidth( bool fullWidth )
{
m_fullWidth = m_fullWidth;
#if QT_VERSION > 290
header()->setStretchEnabled( fullWidth, columns()-1 );
#endif
}
bool OListView::fullWidth() const
{
return m_fullWidth;
}
int OListView::addColumn( const QString& label, int width )
{
int result = QListView::addColumn( label, width );
#if QT_VERSION > 290
if (m_fullWidth) {
header()->setStretchEnabled( false, columns()-2 );
header()->setStretchEnabled( true, columns()-1 );
}
#endif
return result;
}
int OListView::addColumn( const QIconSet& iconset, const QString& label, int width )
{
int result = QListView::addColumn( iconset, label, width );
#if QT_VERSION > 290
if (m_fullWidth) {
header()->setStretchEnabled( false, columns()-2 );
header()->setStretchEnabled( true, columns()-1 );
}
#endif
return result;
}
void OListView::removeColumn( int index )
{
QListView::removeColumn(index);
#if QT_VERSION > 290
if ( m_fullWidth && index == columns() )
{
header()->setStretchEnabled( true, columns()-1 );
}
#endif
}
const QColor& OListView::alternateBackground() const
{
return m_alternateBackground;
}
void OListView::setAlternateBackground( const QColor &c )
{
m_alternateBackground = c;
repaint();
}
const QPen& OListView::columnSeparator() const
{
return m_columnSeparator;
}
void OListView::setColumnSeparator( const QPen& p )
{
m_columnSeparator = p;
repaint();
}
void OListView::expand(QListViewItem *item)
{
((OListViewItem*)item)->expand();
}
OListViewItem* OListView::childFactory()
{
@@ -662,96 +667,98 @@ ONamedListViewItem* ONamedListView::find( const QString& column, const QString&
{
int col = findColumn( column );
if ( col != -1 )
return find( (ONamedListViewItem*) firstChild(), col, text, recurse );
else
return 0;
}
ONamedListViewItem* ONamedListView::find( ONamedListViewItem* item, const QString& column, const QString& text, int recurse ) const
{
int col = findColumn( column );
if ( col != -1 )
return find( item, col, text, recurse );
else
return 0;
}
/*======================================================================================
* ONamedListViewItem
*======================================================================================*/
ONamedListViewItem::ONamedListViewItem( QListView* parent, const QStringList& texts )
:OListViewItem( parent )
{
setText( texts );
}
ONamedListViewItem::ONamedListViewItem( QListViewItem* parent, const QStringList& texts )
:OListViewItem( parent )
{
setText( texts );
}
ONamedListViewItem::ONamedListViewItem( QListView* parent, QListViewItem* after, const QStringList& texts )
:OListViewItem( parent, after )
{
setText( texts );
}
ONamedListViewItem::ONamedListViewItem( QListViewItem* parent, QListViewItem* after, const QStringList& texts )
:OListViewItem( parent, after )
{
setText( texts );
}
ONamedListViewItem::~ONamedListViewItem()
{
}
void ONamedListViewItem::setText( const QStringList& texts )
{
int col = 0;
for ( QStringList::ConstIterator it = texts.begin(); it != texts.end(); ++it )
{
qDebug( "setting column %d = text %s", col, (const char*) *it );
OListViewItem::setText( col++, *it );
}
}
void ONamedListViewItem::setText( const QString& column, const QString& text )
{
//FIXME: If used excessively, this will slow down performance of updates
//FIXME: because of the linear search over all column texts.
//FIXME: I will optimize later by using a hash map.
int col = ( (ONamedListView*) listView() )->findColumn( column );
if ( col != -1 )
OListViewItem::setText( col, text );
else
qWarning( "ONamedListViewItem::setText(): Warning! Columntext '%s' not found.", (const char*) column );
}
ONamedListViewItem* ONamedListViewItem::find( int column, const QString& text, int recurse ) const
{
return ( (ONamedListView*) listView() )->find( (ONamedListViewItem*) firstChild(), column, text, recurse );
}
ONamedListViewItem* ONamedListViewItem::find( const QString& column, const QString& text, int recurse ) const
{
int col = ( (ONamedListView*) listView() )->findColumn( column );
if ( col != -1 )
return ( (ONamedListView*) listView() )->find( (ONamedListViewItem*) firstChild(), col, text, recurse );
else
return 0;
}
+}
+}
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,409 +1,426 @@
/*
                This file is part of the Opie Project
=. (C) 2003-2004 Michael 'Mickey' Lauer <mickey@vanille.de>
.=l.
           .>+-=
 _;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef OLISTVIEW_H
#define OLISTVIEW_H
#include <qcolor.h>
#include <qlistview.h>
#include <qpen.h>
#include <qdatastream.h>
#include <qstringlist.h>
+
+namespace Opie {
+namespace Ui {
class OListViewItem;
/*======================================================================================
* OListView
*======================================================================================*/
/**
* @brief A list/tree widget.
*
* A @ref QListView variant featuring visual and functional enhancements
* like an alternate background for odd rows, an autostretch mode
* for the width of the widget ( >= Qt 3 only ) and persistence capabilities.
*
* @author Michael 'Mickey' Lauer <mickey@vanille.de>
*/
class OListView: public QListView
{
+ Q_OBJECT
public:
/**
* Constructor.
*
* The parameters @a parent and @a name are handled by
* @ref QListView, as usual.
*/
OListView( QWidget* parent = 0, const char* name = 0 );
/**
* Destructor.
*/
virtual ~OListView();
/**
* Let the last column fit exactly all the available width.
*/
void setFullWidth( bool fullWidth );
/**
* Returns whether the last column is set to fit the available width.
*/
bool fullWidth() const;
/**
* Reimplemented for full width support
*/
virtual int addColumn( const QString& label, int width = -1 );
/**
* Reimplemented for full width support
*/
virtual int addColumn( const QIconSet& iconset, const QString& label, int width = -1 );
/**
* Reimplemented for full width support
*/
virtual void removeColumn(int index);
/**
* Set the alternate background background @a color.
* Set to an invalid color to disable alternate colors.
* This only has an effect if the items are OListViewItems
*/
void setAlternateBackground( const QColor& color );
/**
* Sets the column separator @a pen.
*/
void setColumnSeparator( const QPen& pen );
/**
* @returns the alternate background color
*/
const QColor& alternateBackground() const;
/**
* @return the column separator pen
*/
const QPen& columnSeparator() const;
/**
* Create a list view item as child of this object
* @returns the new object
*/
virtual OListViewItem* childFactory();
#ifndef QT_NO_DATASTREAM
/**
* Serialize this object to @ref QDataStream @a stream
*/
virtual void serializeTo( QDataStream& stream ) const;
/**
* Serialize this object from a @ref QDataStream @a stream
*/
virtual void serializeFrom( QDataStream& s );
#endif
public slots:
/**
* Expand all items
*/
void expand();
/**
* Collapse all items
*/
void collapse();
protected slots:
/**
* expand the current OListViewItem
*/
void expand(QListViewItem*);
private:
QColor m_alternateBackground;
- bool m_fullWidth;
+ bool m_fullWidth : 1;
QPen m_columnSeparator;
+ class Private;
+ Private *d;
};
#ifndef QT_NO_DATASTREAM
/**
* @relates OListView
* Writes @a listview to the @a stream and returns a reference to the stream.
*/
QDataStream& operator<<( QDataStream& stream, const OListView& listview );
/**
* @relates OListView
* Reads @a listview from the @a stream and returns a reference to the stream.
*/
QDataStream& operator>>( QDataStream& stream, OListView& listview );
#endif // QT_NO_DATASTREAM
/*======================================================================================
* OListViewItem
*======================================================================================*/
class OListViewItem: public QListViewItem
{
friend class OCheckListItem;
public:
/**
* Constructors.
*/
OListViewItem( QListView * parent );
OListViewItem( QListViewItem * parent );
OListViewItem( QListView * parent, QListViewItem * after );
OListViewItem( QListViewItem * parent, QListViewItem * after );
OListViewItem( QListView * parent,
QString, QString = QString::null,
QString = QString::null, QString = QString::null,
QString = QString::null, QString = QString::null,
QString = QString::null, QString = QString::null );
OListViewItem( QListViewItem * parent,
QString, QString = QString::null,
QString = QString::null, QString = QString::null,
QString = QString::null, QString = QString::null,
QString = QString::null, QString = QString::null );
OListViewItem( QListView * parent, QListViewItem * after,
QString, QString = QString::null,
QString = QString::null, QString = QString::null,
QString = QString::null, QString = QString::null,
QString = QString::null, QString = QString::null );
OListViewItem( QListViewItem * parent, QListViewItem * after,
QString, QString = QString::null,
QString = QString::null, QString = QString::null,
QString = QString::null, QString = QString::null,
QString = QString::null, QString = QString::null );
/**
* Destructor.
*/
virtual ~OListViewItem();
/**
* @returns the background color of the list item.
*/
const QColor& backgroundColor();
/**
* @returns true, if the item is at an odd position and
* thus have to be painted with the alternate background color.
*/
bool isAlternate();
/**
* @note: Reimplemented for internal purposes - the API is not affected
*
*/
void paintCell( QPainter *p, const QColorGroup &cg, int column, int width, int alignment );
/**
* Perform object initialization.
*/
void init();
/**
* create a list view item as child of this object
* @returns the new object
*/
virtual OListViewItem* childFactory();
#ifndef QT_NO_DATASTREAM
/**
* serialize this object to or from a @ref QDataStream
* @param s the stream used to serialize this object.
*/
virtual void serializeTo( QDataStream& s ) const;
/**
* serialize this object to or from a @ref QDataStream
* @param s the stream used to serialize this object.
*/
virtual void serializeFrom( QDataStream& s );
#endif
/**
* expand the the item
*/
virtual void expand(){};
private:
- bool m_known;
- bool m_odd;
+ bool m_known : 1;
+ bool m_odd : 1;
+ class Private;
+ Private *d;
};
#ifndef QT_NO_DATASTREAM
/**
* @relates QListViewItem
* Writes listview @a item and all subitems recursively to @a stream
* and returns a reference to the stream.
*/
QDataStream& operator<<( QDataStream& stream, const OListViewItem& item );
/**
* @relates QListViewItem
* Reads listview @a item from @a stream and returns a reference to the stream.
*/
QDataStream& operator>>( QDataStream& stream, OListViewItem& item );
#endif // QT_NO_DATASTREAM
/*======================================================================================
* OCheckListItem
*======================================================================================*/
class OCheckListItem : public QCheckListItem
{
public:
OCheckListItem( QCheckListItem *parent, const QString &text,
Type = Controller );
OCheckListItem( QListViewItem *parent, const QString &text,
Type = Controller );
OCheckListItem( QListView *parent, const QString &text,
Type = Controller );
OCheckListItem( QListViewItem *parent, const QString &text,
const QPixmap & );
OCheckListItem( QListView *parent, const QString &text,
const QPixmap & );
~OCheckListItem();
/**
* @returns the background color of the list item.
*/
const QColor& backgroundColor();
/**
* @returns true, if the item is at an odd position and
* thus have to be painted with the alternate background color.
*/
bool isAlternate();
/**
* @note: Reimplemented for internal purposes - the API is not affected
*
*/
void paintCell( QPainter *p, const QColorGroup &cg, int column, int width, int alignment );
/**
* Perform object initialization.
*/
void init();
private:
bool m_known;
bool m_odd;
};
/*======================================================================================
* ONamedListView
*======================================================================================*/
class ONamedListViewItem;
/**
* @brief An OListView variant with named columns.
*
* This class provides a higher-level interface to an OListView.
*
* @author Michael 'Mickey' Lauer <mickey@vanille.de>
*/
class ONamedListView: public OListView
{
public:
/**
* Constructor.
*
* The parameters @a parent and @a name are handled by
* @ref OListView, as usual.
*/
ONamedListView( QWidget* parent = 0, const char* name = 0 );
/**
* Destructor.
*/
virtual ~ONamedListView();
/**
* Add a number of @a columns to the listview.
*/
virtual void addColumns( const QStringList& columns );
/**
* @returns the column index matching to @a text or -1 if not found.
*/
virtual int findColumn( const QString& text ) const;
/**
* @returns the first item which has a @a text in column @a column.
* Set @a recurse to indicate how much subchild levels to search, e.g.<ul>
* <li>set it to 0 to search only among direct childs,
* <li>set it to 1 to search direct childs and all 1st order subchilds
* <li>set it to -1 for maximum recursion.
* </ul>
* @sa ONamedListViewItem::find()
*/
virtual ONamedListViewItem* find( ONamedListViewItem* start, int column, const QString& text, int recurse = -1 ) const;
virtual ONamedListViewItem* find( int column, const QString& text, int recurse = -1 ) const;
virtual ONamedListViewItem* find( ONamedListViewItem* start, const QString& column, const QString& text, int recurse = -1 ) const;
virtual ONamedListViewItem* find( const QString& column, const QString& text, int recurse = -1 ) const;
+ private:
+ class Private;
+ Private *d;
};
/*======================================================================================
* ONamedListViewItem
*======================================================================================*/
/**
* @brief An OListView variant with named columns.
*
* This class provides a higher-level interface to an OListViewItem.
*
* @author Michael 'Mickey' Lauer <mickey@vanille.de>
*/
class ONamedListViewItem: public OListViewItem
{
public:
/**
* Constructor. Accepts the same parameters as a @ref OListViewItem,
* plus a @ref QStringList which holds an arbitrary number of @a texts.
*/
ONamedListViewItem( QListView* parent, const QStringList& texts );
ONamedListViewItem( QListViewItem* parent, const QStringList& texts );
ONamedListViewItem( QListView* parent, QListViewItem* after, const QStringList& texts );
ONamedListViewItem( QListViewItem* parent, QListViewItem* after, const QStringList& texts );
/**
* Destructor.
*/
virtual ~ONamedListViewItem();
/**
* Sets the text in column @a column to @a text.
* This method differs from @ref QListViewItem::setText() in that it
* accepts a string as column indicator instead of an int.
*/
virtual void setText( const QString& column, const QString& text );
/**
* Sets a number of @a texts for this item.
*/
virtual void setText( const QStringList& texts );
/**
* @returns the first child which has a @a text in column @a column.
* Set @a recurse to indicate how much subchild levels to search, e.g.<ul>
* <li>set it to 0 to search only among direct childs,
* <li>set it to 1 to search direct childs and all 1st order subchilds
* <li>set it to -1 for maximum recursion.
* </ul>
* @sa ONamedListView::find()
*/
virtual ONamedListViewItem* find( int column, const QString& text, int recurse = -1 ) const;
virtual ONamedListViewItem* find( const QString& column, const QString& text, int recurse = -1 ) const;
-};
+ private:
+ class Private;
+ Private *d;
+
+};
+}
+}
#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 @@
TEMPLATE = lib
CONFIG += qt warn_on debug
DESTDIR = $(OPIEDIR)/lib
HEADERS = oclickablelabel.h \
odialog.h \
ofontselector.h \
oimageeffect.h \
olistview.h \
- omessagebox.h \
opixmapeffect.h \
opopupmenu.h \
opixmapprovider.h \
- oresource.h \
oselector.h \
oseparator.h \
otabinfo.h \
otabbar.h \
otabwidget.h \
otaskbarapplet.h \
oticker.h \
otimepicker.h \
oversatileview.h \
oversatileviewitem.h \
owait.h
SOURCES = oclickablelabel.cpp \
odialog.cpp \
ofontselector.cpp \
oimageeffect.cpp \
olistview.cpp \
opixmapeffect.cpp \
opopupmenu.cpp \
opixmapprovider.cpp \
- oresource.cpp \
oselector.cpp \
oseparator.cpp \
otabbar.cpp \
otabwidget.cpp \
otaskbarapplet.cpp \
oticker.cpp \
otimepicker.cpp \
oversatileview.cpp \
oversatileviewitem.cpp \
owait.cpp
include ( big-screen/big-screen.pro )
include ( fileselector/fileselector.pro )
INTERFACES = otimepickerbase.ui
TARGET = opieui2
VERSION = 1.8.5
INCLUDEPATH += $(OPIEDIR)/include
DEPENDPATH += $(OPIEDIR)/include
LIBS += -lopiecore2
!contains( platform, x11 ) {
include ( $(OPIEDIR)/include.pro )
}
contains( platform, x11 ) {
LIBS += -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib
}
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,115 +1,117 @@
/* This file is part of the KDE libraries
Copyright (C) 1998, 1999 Christian Tibirna <ctibirna@total.net>
(C) 1998, 1999 Daniel M. Duley <mosfet@kde.org>
(C) 1998, 1999 Dirk A. Mueller <mueller@kde.org>
*/
// $Id$
/* QT */
#include <qimage.h>
#include <qpainter.h>
/* OPIE */
#include <opie2/opixmapeffect.h>
#include <opie2/oimageeffect.h>
+
+using namespace Opie::Ui;
//======================================================================
//
// Gradient effects
//
//======================================================================
OPixmap& OPixmapEffect::gradient(OPixmap &pixmap, const QColor &ca,
const QColor &cb, GradientType eff, int ncols)
{
if(pixmap.depth() > 8 &&
(eff == VerticalGradient || eff == HorizontalGradient)) {
int rDiff, gDiff, bDiff;
int rca, gca, bca /*, rcb, gcb, bcb*/;
register int x, y;
rDiff = (/*rcb = */ cb.red()) - (rca = ca.red());
gDiff = (/*gcb = */ cb.green()) - (gca = ca.green());
bDiff = (/*bcb = */ cb.blue()) - (bca = ca.blue());
register int rl = rca << 16;
register int gl = gca << 16;
register int bl = bca << 16;
int rcdelta = ((1<<16) / (eff == VerticalGradient ? pixmap.height() : pixmap.width())) * rDiff;
int gcdelta = ((1<<16) / (eff == VerticalGradient ? pixmap.height() : pixmap.width())) * gDiff;
int bcdelta = ((1<<16) / (eff == VerticalGradient ? pixmap.height() : pixmap.width())) * bDiff;
QPainter p(&pixmap);
// these for-loops could be merged, but the if's in the inner loop
// would make it slow
switch(eff) {
case VerticalGradient:
for ( y = 0; y < pixmap.height(); y++ ) {
rl += rcdelta;
gl += gcdelta;
bl += bcdelta;
p.setPen(QColor(rl>>16, gl>>16, bl>>16));
p.drawLine(0, y, pixmap.width()-1, y);
}
break;
case HorizontalGradient:
for( x = 0; x < pixmap.width(); x++) {
rl += rcdelta;
gl += gcdelta;
bl += bcdelta;
p.setPen(QColor(rl>>16, gl>>16, bl>>16));
p.drawLine(x, 0, x, pixmap.height()-1);
}
break;
default:
;
}
}
else {
QImage image = OImageEffect::gradient(pixmap.size(), ca, cb,
(OImageEffect::GradientType) eff, ncols);
pixmap.convertFromImage(image);
}
return pixmap;
}
// -----------------------------------------------------------------------------
OPixmap& OPixmapEffect::unbalancedGradient(OPixmap &pixmap, const QColor &ca,
const QColor &cb, GradientType eff, int xfactor, int yfactor,
int ncols)
{
QImage image = OImageEffect::unbalancedGradient(pixmap.size(), ca, cb,
(OImageEffect::GradientType) eff,
xfactor, yfactor, ncols);
pixmap.convertFromImage(image);
return pixmap;
}
//======================================================================
//
// Intensity effects
//
//======================================================================
OPixmap& OPixmapEffect::intensity(OPixmap &pixmap, float percent)
{
QImage image = pixmap.convertToImage();
OImageEffect::intensity(image, percent);
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,113 +1,116 @@
/* This file is part of the KDE libraries
Copyright (C) 1998, 1999 Christian Tibirna <ctibirna@total.net>
(C) 1998, 1999 Daniel M. Duley <mosfet@kde.org>
(C) 1998, 1999 Dirk A. Mueller <mueller@kde.org>
*/
// $Id$
#ifndef __OPIXMAP_EFFECT_H
#define __OPIXMAP_EFFECT_H
#include <qsize.h>
typedef QPixmap OPixmap;
class QColor;
+
+namespace Opie {
+namespace Ui {
/**
* This class includes various pixmap-based graphical effects.
*
* Everything is
* static, so there is no need to create an instance of this class. You can
* just call the static methods. They are encapsulated here merely to provide
* a common namespace.
*/
class OPixmapEffect
{
public:
enum GradientType { VerticalGradient, HorizontalGradient,
DiagonalGradient, CrossDiagonalGradient,
PyramidGradient, RectangleGradient,
PipeCrossGradient, EllipticGradient };
enum RGBComponent { Red, Green, Blue };
enum Lighting {NorthLite, NWLite, WestLite, SWLite,
SouthLite, SELite, EastLite, NELite};
/**
* Creates a gradient from color a to color b of the specified type.
*
* @param pixmap The pixmap to process.
* @param ca Color a.
* @param cb Color b.
* @param type The type of gradient.
* @param ncols The number of colors to use when not running on a
* truecolor display. The gradient will be dithered to this number of
* colors. Pass 0 to prevent dithering.
* @return Returns the generated pixmap, for convenience.
*/
static OPixmap& gradient(OPixmap& pixmap, const QColor &ca, const QColor &cb,
GradientType type, int ncols=3);
/**
* Creates an unbalanced gradient.
*
* An unbalanced gradient is a gradient where the transition from
* color a to color b is not linear, but in this case, exponential.
*
* @param pixmap The pixmap that should be written.
* @param ca Color a.
* @param cb Color b.
* @param type The type of gradient.
* @param xfactor The x decay length. Use a value between -200 and 200.
* @param yfactor The y decay length.
* @param ncols The number of colors. See #gradient.
* @return The generated pixmap, for convencience.
*/
static OPixmap& unbalancedGradient(OPixmap& pixmap, const QColor &ca,
const QColor &cb, GradientType type, int xfactor = 100,
int yfactor = 100, int ncols=3);
/**
* Creates a pixmap of a given size with the given pixmap.
*
* if the
* given size is bigger than the size of the pixmap, the pixmap is
* tiled.
*
* @param pixmap This is the source pixmap
* @param size The size the new pixmap should have.
* @return The generated, tiled pixmap.
*/
static OPixmap createTiled(const OPixmap& pixmap, QSize size);
/**
* Either brightens or dims a pixmap by a specified ratio.
*
* @param pixmap The pixmap to process.
* @param ratio The ratio to use. Use negative value to dim.
* @return Returns The @ref pixmap(), provided for convenience.
*/
static OPixmap& intensity(OPixmap& pixmap, float ratio);
/**
* Modifies the intensity of a pixmap's RGB channel component.
*
* @param pixmap The pixmap to process.
* @param ratio value. Use negative value to dim.
* @param channel Which channel(s) should be modified
* @return Returns the @ref pixmap(), provided for convenience.
*/
static OPixmap& channelIntensity(OPixmap& pixmap, float ratio,
RGBComponent channel);
/**
* Blends the provided pixmap into a background of the indicated color.
*
* @param pixmap The pixmap to process.
* @param initial_intensity this parameter takes values from -1 to 1:
* @li If positive, it tells how much to fade the image in its
* less affected spot.
* @li If negative, it tells roughly indicates how much of the image
* remains unaffected
@@ -117,99 +120,100 @@ public:
* with concentric blending effects).
* @return Returns the @ref pixmap(), provided for convenience.
*/
static OPixmap& blend(OPixmap& pixmap, float initial_intensity,
const QColor &bgnd, GradientType eff,
bool anti_dir=false, int ncols=3);
/**
* Builds a hash on any given pixmap.
*
* @param pixmap The pixmap to process.
* @param lite The hash faces the indicated lighting (cardinal poles)
* @param spacing How many unmodified pixels inbetween hashes.
* @return Returns The @ref pixmap(), provided for convenience.
*/
static OPixmap& hash(OPixmap& pixmap, Lighting lite=NorthLite,
unsigned int spacing=0, int ncols=3);
/**
* Creates a pattern from a pixmap.
*
* The given pixmap is "flattened"
* between color a to color b.
*
* @param pixmap The pixmap to process.
* @param ca Color a.
* @param cb Color b.
* @param ncols The number of colors to use. The image will be
* dithered to this depth. Pass zero to prevent dithering.
* @return The @ref pixmap(), provided for convenience.
*/
static OPixmap pattern(const OPixmap& pixmap, QSize size,
const QColor &ca, const QColor &cb, int ncols=8);
/**
* Recolors a pixmap.
*
* The most dark color will become color a,
* the most bright one color b, and in between.
*
* @param pixmap The pixmap to process.
* @param ca Color a.
* @param cb Color b.
* @param ncols The number of colors to use. Pass zero to prevent
* dithering.
* @return Returns the @ref pixmap(), provided for convenience.
*/
static OPixmap& fade(OPixmap& pixmap, double val, const QColor &color);
/**
* Converts a pixmap to grayscale.
*
* @param pixmap The pixmap to process.
* @param fast Set to @p true in order to use a faster but non-photographic
* quality algorithm. Appropriate for things such as toolbar icons.
* @return Returns the @ref pixmap(), provided for convenience.
*/
static OPixmap& toGray(OPixmap& pixmap, bool fast=false);
/**
* Desaturates a pixmap.
*
* @param pixmap The pixmap to process.
* @param desat A value between 0 and 1 setting the degree of desaturation
* @return Returns The @ref pixmap(), provided for convenience.
*/
static OPixmap& desaturate(OPixmap& pixmap, float desat = 0.3);
/**
* Modifies the contrast of a pixmap.
*
* @param pixmap The pixmap to process.
* @param c A contrast value between -255 and 255.
* @return Returns the @ref pixmap(), provided for convenience.
*/
static OPixmap& contrast(OPixmap& pixmap, int c);
/**
* Dithers a pixmap using Floyd-Steinberg dithering for low-color
* situations.
*
* @param pixmap The pixmap to process.
* @param palette The color palette to use.
* @param size The size of the palette.
* @return Returns the @ref pixmap(), provided for convenience.
*/
static OPixmap& dither(OPixmap &pixmap, const QColor *palette, int size);
/**
* Calculate a 'selected' pixmap, for instance a selected icon
* on the desktop.
* @param pixmap the pixmap to select
* @param col the selected color, usually from QColorGroup::highlight().
*/
static OPixmap selectedPixmap( const OPixmap &pixmap, const QColor &col );
};
-
+}
+}
#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 @@
/* This file is part of the KDE libraries
Copyright (c) 2000 Carsten Pfeiffer <pfeiffer@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License (LGPL) as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include <opie2/opixmapprovider.h>
+using namespace Opie::Ui;
+
OPixmapProvider::~OPixmapProvider() {}
void OPixmapProvider::virtual_hook( int , void* )
{ /*BASE::virtual_hook( id, data );*/ }
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 @@
/* This file is part of the KDE libraries
Copyright (c) 2000 Carsten Pfeiffer <pfeiffer@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License (LGPL) as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef OPIXMAPPROVIDER_H
#define OPIXMAPPROVIDER_H
#include <qpixmap.h>
+namespace Opie {
+namespace Ui {
/**
+ * \todo make usefull
* A tiny abstract class with just one method:
* @ref pixmapFor()
*
* It will be called whenever an icon is searched for @p text.
*
* Used e.g. by @ref KHistoryCombo
*
* @author Carsten Pfeiffer <pfeiffer@kde.org>
* @short an abstract interface for looking up icons
*/
class OPixmapProvider
{
public:
virtual ~OPixmapProvider();
/**
* You may subclass this and return a pixmap of size @p size for @p text.
* @param text the text that is associated with the pixmap
* @param size the size of the icon in pixels, 0 for defaylt size.
* See @ref KIcon::StdSize.
* @return the pixmap for the arguments, or null if there is none
*/
virtual QPixmap pixmapFor( const QString& text, int size = 0 ) = 0;
protected:
virtual void virtual_hook( int id, void* data );
+private:
+ class Private;
+ Private *d;
};
+}
+}
#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,125 +1,128 @@
/* This file is part of the KDE libraries
Copyright (C) 2000 Daniel M. Duley <mosfet@kde.org>
Copyright (C) 2002 Hamish Rodda <meddie@yoyo.its.monash.edu.au>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License version 2 as published by the Free Software Foundation.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
/* QT */
#include <qdrawutil.h>
#include <qtimer.h>
/* OPIE */
#include <opie2/opopupmenu.h>
#include <opie2/oconfig.h>
+using namespace Opie::Core;
+using namespace Opie::Ui;
+
OPopupTitle::OPopupTitle(QWidget *parent, const char *name)
: QWidget(parent, name)
{
setMinimumSize(16, fontMetrics().height()+8);
}
OPopupTitle::OPopupTitle(OPixmapEffect::GradientType /* gradient */,
const QColor &/* color */, const QColor &/* textColor */,
QWidget *parent, const char *name)
: QWidget(parent, name)
{
setMinimumSize(16, fontMetrics().height()+8);
}
OPopupTitle::OPopupTitle(const OPixmap & /* background */, const QColor &/* color */,
const QColor &/* textColor */, QWidget *parent,
const char *name)
: QWidget(parent, name)
{
setMinimumSize(16, fontMetrics().height()+8);
}
void OPopupTitle::setTitle(const QString &text, const QPixmap *icon)
{
titleStr = text;
if (icon)
miniicon = *icon;
else
miniicon.resize(0, 0);
int w = miniicon.width()+fontMetrics().width(titleStr);
int h = QMAX( fontMetrics().height(), miniicon.height() );
setMinimumSize( w+16, h+8 );
}
void OPopupTitle::setText( const QString &text )
{
titleStr = text;
int w = miniicon.width()+fontMetrics().width(titleStr);
int h = QMAX( fontMetrics().height(), miniicon.height() );
setMinimumSize( w+16, h+8 );
}
void OPopupTitle::setIcon( const QPixmap &pix )
{
miniicon = pix;
int w = miniicon.width()+fontMetrics().width(titleStr);
int h = QMAX( fontMetrics().height(), miniicon.height() );
setMinimumSize( w+16, h+8 );
}
void OPopupTitle::paintEvent(QPaintEvent *)
{
QRect r(rect());
QPainter p(this);
#if QT_VERSION > 290
qApp->style().drawPrimitive(QStyle::PE_HeaderSection, &p, r, palette().active());
#else
#warning OPopupMenu is not fully functional on Qt2
#endif
if (!miniicon.isNull())
p.drawPixmap(4, (r.height()-miniicon.height())/2, miniicon);
if (!titleStr.isNull())
{
p.setPen(palette().active().text());
QFont f = p.font();
f.setBold(true);
p.setFont(f);
if(!miniicon.isNull())
{
p.drawText(miniicon.width()+8, 0, width()-(miniicon.width()+8),
height(), AlignLeft | AlignVCenter | SingleLine,
titleStr);
}
else
{
p.drawText(0, 0, width(), height(),
AlignCenter | SingleLine, titleStr);
}
}
p.setPen(palette().active().highlight());
p.drawLine(0, 0, r.right(), 0);
}
QSize OPopupTitle::sizeHint() const
{
return(minimumSize());
}
class OPopupMenu::OPopupMenuPrivate
{
public:
OPopupMenuPrivate ()
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,129 +1,131 @@
//FIXME what is ODE? ODE Desktop Environemt? -zecke
//FIXME do we need titles? space is limited that is only eyecandy? -zecke
//FIXME keyboard navigation is also not that popular on a PDA might be with a keyboard (tuxphone) -zecke
/* This file is part of the ODE libraries
Copyright (C) 2000 Daniel M. Duley <mosfet@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License version 2 as published by the Free Software Foundation.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef _OPOPUP_H
#define _OPOPUP_H
#define INCLUDE_MENUITEM_DEF
/* QT */
#include <qpopupmenu.h>
/* OPIE */
#include <opie2/opixmapeffect.h>
+namespace Opie {
+namespace Ui {
/**
* Title widget for use in @ref OPopupMenu.
*
* You usually don't have to create this manually since
* @ref OPopupMenu::insertTitle will do it for you, but it is allowed if
* you wish to customize it's look.
*
* @author Daniel M. Duley <mosfet@kde.org>
* @short OPopupMenu title widget.
*/
class OPopupTitle : public QWidget
{
Q_OBJECT
public:
/**
* Constructs a title widget with the user specified gradient, pixmap,
* and colors.
*/
OPopupTitle(QWidget *parent=0, const char *name=0);
/**
* @deprecated
* Constructs a title widget with the specified gradient and colors.
*/
OPopupTitle(OPixmapEffect::GradientType gradient, const QColor &color,
const QColor &textColor, QWidget *parent=0,
const char *name=0);
/**
* @deprecated
* Constructs a title widget with the specified pixmap and colors.
*/
OPopupTitle(const OPixmap &background, const QColor &color,
const QColor &textColor, QWidget *parent=0,
const char *name=0);
/**
* Sets the title string and optional icon for the title widget.
*
* You will want to call this before inserting into a menu.
*/
void setTitle(const QString &text, const QPixmap *icon=NULL);
/**
* Returns the current title.
*/
QString title() const { return(titleStr); }
/**
* Returns the current icon.
*/
QPixmap icon() const { return(miniicon); }
QSize sizeHint() const;
public slots:
/// @since 3.1
void setText( const QString &text );
/// @since 3.1
void setIcon( const QPixmap &pix );
protected:
void paintEvent(QPaintEvent *ev);
QString titleStr;
QPixmap miniicon;
// Remove in KDE4
OPixmapEffect::GradientType grType;
QPixmap fill;
QColor fgColor, bgColor, grHigh, grLow;
bool useGradient;
protected:
virtual void virtual_hook( int id, void* data );
private:
class OPopupTitlePrivate;
OPopupTitlePrivate *d;
};
/**
* OPopupMenu is a class for menus with standard title items and keyboard
* accessibility for popups with many options and/or varying options. It acts
* identically to QPopupMenu, with the addition of insertTitle(),
* changeTitle(), setKeyboardShortcutsEnabled() and
* setKeyboardShortcutsExecute() methods.
*
* The titles support a text string, an icon, plus user defined gradients,
* colors, and background pixmaps.
*
* The keyboard search algorithm is incremental with additional underlining
* for user feedback.
*
* @short A menu with title items.
* @author Daniel M. Duley <mosfet@kde.org>
* @author Hamish Rodda <meddie@yoyo.its.monash.edu.au>
*/
class OPopupMenu : public QPopupMenu {
Q_OBJECT
public:
@@ -163,97 +165,100 @@ public:
QString title(int id=-1) const;
/**
* Returns the icon of the title item at the specified id.
*/
QPixmap titlePixmap(int id) const;
/**
* Enables keyboard navigation by searching for the entered key sequence.
* Also underlines the currently selected item, providing feedback on the search.
*
* Defaults to off.
*
* WARNING: calls to text() of currently keyboard-selected items will
* contain additional ampersand characters.
*
* WARNING: though pre-existing keyboard shortcuts will not interfere with the
* operation of this feature, they may be confusing to the user as the existing
* shortcuts will not work.
* @since 3.1
*/
void setKeyboardShortcutsEnabled(bool enable);
/**
* Enables execution of the menu item once it is uniquely specified.
* Defaults to off.
* @since 3.1
*/
void setKeyboardShortcutsExecute(bool enable);
/**
* Obsolete method provided for backwards compatibility only. Use the
* normal constructor and insertTitle instead.
*/
OPopupMenu(const QString &title, QWidget *parent=0, const char *name=0);
/**
* Obsolete method provided for backwards compatibility only. Use
* insertTitle and changeTitle instead.
*/
void setTitle(const QString &title);
/**
* Returns the context menu associated with this menu
* @since 3.2
*/
QPopupMenu* contextMenu();
/**
* Hides the context menu if shown
* @since 3.2
*/
void cancelContextMenuShow();
/**
* Returns the OPopupMenu associated with the current context menu
* @since 3.2
*/
static OPopupMenu* contextMenuFocus();
/**
* returns the ID of the menuitem associated with the current context menu
* @since 3.2
*/
static int contextMenuFocusItem();
signals:
/**
* connect to this signal to be notified when a context menu is about to be shown
* @param menu The menu that the context menu is about to be shown for
* @param menuItem The menu item that the context menu is currently on
* @param ctxMenu The context menu itself
* @since 3.2
*/
void aboutToShowContextMenu(OPopupMenu* menu, int menuItem, QPopupMenu* ctxMenu);
protected:
virtual void closeEvent(QCloseEvent *);
virtual void keyPressEvent(QKeyEvent* e);
virtual bool eventFilter(QObject* obj, QEvent* event);
virtual void hideEvent(QHideEvent*);
virtual void virtual_hook( int id, void* data );
protected slots:
/// @since 3.1
QString underlineText(const QString& text, uint length);
/// @since 3.1
void resetKeyboardVars(bool noMatches = false);
void itemHighlighted(int whichItem);
void showCtxMenu(QPoint pos);
void ctxMenuHiding();
private:
class OPopupMenuPrivate;
OPopupMenuPrivate *d;
};
+}
+}
+
#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,571 +1,573 @@
/* This file is part of the KDE libraries
Copyright (C) 1997 Martin Jones (mjones@kde.org)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
/* QT */
#include <qimage.h>
#include <qdrawutil.h>
/* OPIE */
#include <opie2/oimageeffect.h>
#include <opie2/oselector.h>
#define STORE_W 8
#define STORE_W2 STORE_W * 2
//-----------------------------------------------------------------------------
/*
* 2D value selector.
* The contents of the selector are drawn by derived class.
*/
+using namespace Opie::Ui;
+
OXYSelector::OXYSelector( QWidget *parent, const char *name )
: QWidget( parent, name )
{
xPos = 0;
yPos = 0;
minX = 0;
minY = 0;
maxX = 100;
maxY = 100;
store.setOptimization( QPixmap::BestOptim );
store.resize( STORE_W2, STORE_W2 );
}
OXYSelector::~OXYSelector()
{}
void OXYSelector::setRange( int _minX, int _minY, int _maxX, int _maxY )
{
px = 2;
py = 2;
minX = _minX;
minY = _minY;
maxX = _maxX;
maxY = _maxY;
}
void OXYSelector::setValues( int _xPos, int _yPos )
{
xPos = _xPos;
yPos = _yPos;
if ( xPos > maxX )
xPos = maxX;
else if ( xPos < minX )
xPos = minX;
-
+
if ( yPos > maxY )
yPos = maxY;
else if ( yPos < minY )
yPos = minY;
int xp = 2 + (width() - 4) * xPos / (maxX - minX);
int yp = height() - 2 - (height() - 4) * yPos / (maxY - minY);
setPosition( xp, yp );
}
QRect OXYSelector::contentsRect() const
{
return QRect( 2, 2, width()-4, height()-4 );
}
void OXYSelector::paintEvent( QPaintEvent *ev )
{
QRect cursorRect( px - STORE_W, py - STORE_W, STORE_W2, STORE_W2);
QRect paintRect = ev->rect();
QPainter painter;
painter.begin( this );
QBrush brush;
qDrawShadePanel( &painter, 0, 0, width(), height(), colorGroup(),
TRUE, 2, &brush );
drawContents( &painter );
if (paintRect.contains(cursorRect))
{
bitBlt( &store, 0, 0, this, px - STORE_W, py - STORE_W,
STORE_W2, STORE_W2, CopyROP );
drawCursor( &painter, px, py );
}
else if (paintRect.intersects(cursorRect))
{
repaint( cursorRect, false);
}
painter.end();
}
void OXYSelector::mousePressEvent( QMouseEvent *e )
{
int xVal, yVal;
valuesFromPosition( e->pos().x() - 2, e->pos().y() - 2, xVal, yVal );
setValues( xVal, yVal );
emit valueChanged( xPos, yPos );
}
void OXYSelector::mouseMoveEvent( QMouseEvent *e )
{
int xVal, yVal;
valuesFromPosition( e->pos().x() - 2, e->pos().y() - 2, xVal, yVal );
setValues( xVal, yVal );
emit valueChanged( xPos, yPos );
}
void OXYSelector::wheelEvent( QWheelEvent *e )
{
#if QT_VERSION > 290
if ( e->orientation() == Qt::Horizontal )
setValues( xValue() + e->delta()/120, yValue() );
else
setValues( xValue(), yValue() + e->delta()/120 );
emit valueChanged( xPos, yPos );
#endif
}
void OXYSelector::valuesFromPosition( int x, int y, int &xVal, int &yVal ) const
{
xVal = ( (maxX-minX) * (x-2) ) / ( width()-4 );
yVal = maxY - ( ( (maxY-minY) * (y-2) ) / ( height()-4 ) );
if ( xVal > maxX )
xVal = maxX;
else if ( xVal < minX )
xVal = minX;
if ( yVal > maxY )
yVal = maxY;
else if ( yVal < minY )
yVal = minY;
}
void OXYSelector::setPosition( int xp, int yp )
{
if ( xp < 2 )
xp = 2;
else if ( xp > width() - 2 )
xp = width() - 2;
if ( yp < 2 )
yp = 2;
else if ( yp > height() - 2 )
yp = height() - 2;
QPainter painter;
painter.begin( this );
bitBlt( this, px - STORE_W, py - STORE_W, &store, 0, 0,
STORE_W2, STORE_W2, CopyROP );
bitBlt( &store, 0, 0, this, xp - STORE_W, yp - STORE_W,
STORE_W2, STORE_W2, CopyROP );
drawCursor( &painter, xp, yp );
px = xp;
py = yp;
painter.end();
}
void OXYSelector::drawContents( QPainter * )
{}
void OXYSelector::drawCursor( QPainter *p, int xp, int yp )
{
p->setPen( QPen( white ) );
p->drawLine( xp - 6, yp - 6, xp - 2, yp - 2 );
p->drawLine( xp - 6, yp + 6, xp - 2, yp + 2 );
p->drawLine( xp + 6, yp - 6, xp + 2, yp - 2 );
p->drawLine( xp + 6, yp + 6, xp + 2, yp + 2 );
}
//-----------------------------------------------------------------------------
/*
* 1D value selector with contents drawn by derived class.
* See OColorDialog for example.
*/
OSelector::OSelector( QWidget *parent, const char *name )
: QWidget( parent, name ), QRangeControl()
{
_orientation = Horizontal;
_indent = TRUE;
}
OSelector::OSelector( Orientation o, QWidget *parent, const char *name )
: QWidget( parent, name ), QRangeControl()
{
_orientation = o;
_indent = TRUE;
}
OSelector::~OSelector()
{}
QRect OSelector::contentsRect() const
{
if ( orientation() == Vertical )
return QRect( 2, 5, width()-9, height()-10 );
else
return QRect( 5, 2, width()-10, height()-9 );
}
void OSelector::paintEvent( QPaintEvent * )
{
QPainter painter;
painter.begin( this );
drawContents( &painter );
QBrush brush;
if ( indent() )
{
if ( orientation() == Vertical )
qDrawShadePanel( &painter, 0, 3, width()-5, height()-6,
colorGroup(), TRUE, 2, &brush );
else
qDrawShadePanel( &painter, 3, 0, width()-6, height()-5,
colorGroup(), TRUE, 2, &brush );
}
QPoint pos = calcArrowPos( value() );
- drawArrow( &painter, TRUE, pos );
+ drawArrow( &painter, TRUE, pos );
painter.end();
}
void OSelector::mousePressEvent( QMouseEvent *e )
{
moveArrow( e->pos() );
}
void OSelector::mouseMoveEvent( QMouseEvent *e )
{
moveArrow( e->pos() );
}
void OSelector::wheelEvent( QWheelEvent *e )
{
int val = value() + e->delta()/120;
emit valueChanged( val );
setValue( val );
}
void OSelector::valueChange()
{
QPainter painter;
QPoint pos;
painter.begin( this );
pos = calcArrowPos( prevValue() );
- drawArrow( &painter, FALSE, pos );
+ drawArrow( &painter, FALSE, pos );
pos = calcArrowPos( value() );
- drawArrow( &painter, TRUE, pos );
+ drawArrow( &painter, TRUE, pos );
painter.end();
}
void OSelector::moveArrow( const QPoint &pos )
{
int val;
if ( orientation() == Vertical )
val = ( maxValue() - minValue() ) * (height()-pos.y()-3)
/ (height()-10) + minValue();
else
val = ( maxValue() - minValue() ) * (width()-pos.x()-3)
/ (width()-10) + minValue();
if ( val > maxValue() )
val = maxValue();
if ( val < minValue() )
val = minValue();
emit valueChanged( val );
setValue( val );
}
QPoint OSelector::calcArrowPos( int val )
{
QPoint p;
if ( orientation() == Vertical )
{
p.setY( height() - ( (height()-10) * val
/ ( maxValue() - minValue() ) + 5 ) );
p.setX( width() - 5 );
}
else
{
p.setX( width() - ( (width()-10) * val
/ ( maxValue() - minValue() ) + 5 ) );
p.setY( height() - 5 );
}
return p;
}
void OSelector::drawContents( QPainter * )
{}
void OSelector::drawArrow( QPainter *painter, bool show, const QPoint &pos )
{
if ( show )
{
QPointArray array(3);
painter->setPen( QPen() );
painter->setBrush( QBrush( colorGroup().buttonText() ) );
if ( orientation() == Vertical )
{
array.setPoint( 0, pos.x()+0, pos.y()+0 );
array.setPoint( 1, pos.x()+5, pos.y()+5 );
array.setPoint( 2, pos.x()+5, pos.y()-5 );
}
else
{
array.setPoint( 0, pos.x()+0, pos.y()+0 );
array.setPoint( 1, pos.x()+5, pos.y()+5 );
array.setPoint( 2, pos.x()-5, pos.y()+5 );
}
painter->drawPolygon( array );
- }
- else
+ }
+ else
{
if ( orientation() == Vertical )
{
repaint(pos.x(), pos.y()-5, 6, 11, true);
}
else
{
repaint(pos.x()-5, pos.y(), 11, 6, true);
}
}
}
//----------------------------------------------------------------------------
OGradientSelector::OGradientSelector( QWidget *parent, const char *name )
: OSelector( parent, name )
{
init();
}
OGradientSelector::OGradientSelector( Orientation o, QWidget *parent,
const char *name )
: OSelector( o, parent, name )
{
init();
}
OGradientSelector::~OGradientSelector()
{}
void OGradientSelector::init()
{
color1.setRgb( 0, 0, 0 );
color2.setRgb( 255, 255, 255 );
-
+
text1 = text2 = "";
}
void OGradientSelector::drawContents( QPainter *painter )
{
QImage image( contentsRect().width(), contentsRect().height(), 32 );
QColor col;
float scale;
int redDiff = color2.red() - color1.red();
int greenDiff = color2.green() - color1.green();
int blueDiff = color2.blue() - color1.blue();
if ( orientation() == Vertical )
{
for ( int y = 0; y < image.height(); y++ )
{
scale = 1.0 * y / image.height();
col.setRgb( color1.red() + int(redDiff*scale),
color1.green() + int(greenDiff*scale),
color1.blue() + int(blueDiff*scale) );
unsigned int *p = (uint *) image.scanLine( y );
for ( int x = 0; x < image.width(); x++ )
*p++ = col.rgb();
}
}
else
{
unsigned int *p = (uint *) image.scanLine( 0 );
for ( int x = 0; x < image.width(); x++ )
{
scale = 1.0 * x / image.width();
col.setRgb( color1.red() + int(redDiff*scale),
color1.green() + int(greenDiff*scale),
color1.blue() + int(blueDiff*scale) );
*p++ = col.rgb();
}
for ( int y = 1; y < image.height(); y++ )
memcpy( image.scanLine( y ), image.scanLine( y - 1),
sizeof( unsigned int ) * image.width() );
}
QColor ditherPalette[8];
for ( int s = 0; s < 8; s++ )
ditherPalette[s].setRgb( color1.red() + redDiff * s / 8,
color1.green() + greenDiff * s / 8,
color1.blue() + blueDiff * s / 8 );
OImageEffect::dither( image, ditherPalette, 8 );
QPixmap p;
p.convertFromImage( image );
painter->drawPixmap( contentsRect().x(), contentsRect().y(), p );
if ( orientation() == Vertical )
{
int yPos = contentsRect().top() + painter->fontMetrics().ascent() + 2;
int xPos = contentsRect().left() + (contentsRect().width() -
painter->fontMetrics().width( text2 )) / 2;
QPen pen( color2 );
painter->setPen( pen );
painter->drawText( xPos, yPos, text2 );
yPos = contentsRect().bottom() - painter->fontMetrics().descent() - 2;
- xPos = contentsRect().left() + (contentsRect().width() -
+ xPos = contentsRect().left() + (contentsRect().width() -
painter->fontMetrics().width( text1 )) / 2;
pen.setColor( color1 );
painter->setPen( pen );
painter->drawText( xPos, yPos, text1 );
}
else
{
int yPos = contentsRect().bottom()-painter->fontMetrics().descent()-2;
QPen pen( color2 );
painter->setPen( pen );
painter->drawText( contentsRect().left() + 2, yPos, text1 );
pen.setColor( color1 );
painter->setPen( pen );
painter->drawText( contentsRect().right() -
painter->fontMetrics().width( text2 ) - 2, yPos, text2 );
}
}
//-----------------------------------------------------------------------------
static QColor *standardPalette = 0;
#define STANDARD_PAL_SIZE 17
OColor::OColor()
: QColor()
{
r = 0; g = 0; b = 0; h = 0; s = 0; v = 0;
};
OColor::OColor( const OColor &col)
: QColor( col )
{
h = col.h; s = col.s; v = col.v;
r = col.r; g = col.g; b = col.b;
};
OColor::OColor( const QColor &col)
: QColor( col )
{
QColor::rgb(&r, &g, &b);
QColor::hsv(&h, &s, &v);
};
bool OColor::operator==(const OColor& col) const
{
return (h == col.h) && (s == col.s) && (v == col.v) &&
(r == col.r) && (g == col.g) && (b == col.b);
}
OColor& OColor::operator=(const OColor& col)
{
*(QColor *)this = col;
h = col.h; s = col.s; v = col.v;
r = col.r; g = col.g; b = col.b;
return *this;
}
void
OColor::setHsv(int _h, int _s, int _v)
{
h = _h; s = _s; v = _v;
QColor::setHsv(h, s, v);
QColor::rgb(&r, &g, &b);
};
void
OColor::setRgb(int _r, int _g, int _b)
{
r = _r; g = _g; b = _b;
QColor::setRgb(r, g, b);
QColor::hsv(&h, &s, &v);
}
void
OColor::rgb(int *_r, int *_g, int *_b) const
{
*_r = r; *_g = g; *_b = b;
}
void
OColor::hsv(int *_h, int *_s, int *_v) const
{
*_h = h; *_s = s; *_v = v;
}
static void createStandardPalette()
{
if ( standardPalette )
return;
standardPalette = new QColor[STANDARD_PAL_SIZE];
int i = 0;
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,125 +1,128 @@
/* This file is part of the KDE libraries
Copyright (C) 1997 Martin Jones (mjones@kde.org)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
//-----------------------------------------------------------------------------
// Selector widgets for KDE Color Selector, but probably useful for other
// stuff also.
#ifndef __OSELECT_H__
#define __OSELECT_H__
#include <qwidget.h>
#include <qrangecontrol.h>
#include <qpixmap.h>
+
+namespace Opie {
+namespace Ui {
/**
* OXYSelector is the base class for other widgets which
* provides the ability to choose from a two-dimensional
* range of values. The currently chosen value is indicated
* by a cross. An example is the @ref OHSSelector which
* allows to choose from a range of colors, and which is
* used in OColorDialog.
*
* A custom drawing routine for the widget surface has
* to be provided by the subclass.
*/
class OXYSelector : public QWidget
{
Q_OBJECT
public:
/**
* Constructs a two-dimensional selector widget which
* has a value range of [0..100] in both directions.
*/
OXYSelector( QWidget *parent=0, const char *name=0 );
/**
* Destructs the widget.
*/
~OXYSelector();
/**
* Sets the current values in horizontal and
* vertical direction.
*/
void setValues( int xPos, int yPos );
/**
* Sets the range of possible values.
*/
void setRange( int minX, int minY, int maxX, int maxY );
/**
* @return the current value in horizontal direction.
*/
int xValue() const { return xPos; }
/**
* @return the current value in vertical direction.
*/
int yValue() const { return yPos; }
/**
* @return the rectangle on which subclasses should draw.
*/
QRect contentsRect() const;
signals:
/**
* This signal is emitted whenever the user chooses a value,
* e.g. by clicking with the mouse on the widget.
*/
void valueChanged( int x, int y );
protected:
/**
* Override this function to draw the contents of the widget.
* The default implementation does nothing.
*
* Draw within @ref contentsRect() only.
*/
virtual void drawContents( QPainter * );
/**
* Override this function to draw the cursor which
* indicates the currently selected value pair.
*/
virtual void drawCursor( QPainter *p, int xp, int yp );
/**
* @reimplemented
*/
virtual void paintEvent( QPaintEvent *e );
/**
* @reimplemented
*/
virtual void mousePressEvent( QMouseEvent *e );
/**
* @reimplemented
*/
virtual void mouseMoveEvent( QMouseEvent *e );
/**
* @reimplemented
*/
virtual void wheelEvent( QWheelEvent * );
/**
* Converts a pixel position to its corresponding values.
*/
void valuesFromPosition( int x, int y, int& xVal, int& yVal ) const;
private:
void setPosition( int xp, int yp );
int px;
int py;
int xPos;
@@ -419,100 +422,102 @@ private:
private:
class OHSSelectorPrivate;
OHSSelectorPrivate *d;
};
class OValueSelectorPrivate;
/**
* Widget for color value selection.
*
* @see OHSSelector, OColorDialog
* @author Martin Jones (mjones@kde.org)
* @version $Id$
*/
class OValueSelector : public OSelector
{
Q_OBJECT
public:
/**
* Constructs a widget for color selection.
*/
OValueSelector( QWidget *parent=0, const char *name=0 );
/**
* Constructs a widget for color selection with a given orientation
*/
OValueSelector( Orientation o, QWidget *parent = 0, const char *name = 0 );
int hue() const
{ return _hue; }
void setHue( int h )
{ _hue = h; }
int saturation() const
{ return _sat; }
void setSaturation( int s )
{ _sat = s; }
void updateContents();
protected:
/**
* Draws the contents of the widget on a pixmap,
* which is used for buffering.
*/
virtual void drawPalette( QPixmap *pixmap );
/**
* @reimplemented
*/
virtual void resizeEvent( QResizeEvent * );
/**
* Reimplemented from OSelector. The drawing is
* buffered in a pixmap here. As real drawing
* routine, drawPalette() is used.
*/
virtual void drawContents( QPainter *painter );
private:
int _hue;
int _sat;
QPixmap pixmap;
private:
class OValueSelectorPrivate;
OValueSelectorPrivate *d;
};
class OColor : public QColor
{
public:
OColor();
OColor( const OColor &col);
OColor( const QColor &col);
OColor& operator=( const OColor& col);
bool operator==( const OColor& col) const;
void setHsv(int _h, int _s, int _v);
void setRgb(int _r, int _g, int _b);
void rgb(int *_r, int *_g, int *_b) const;
void hsv(int *_h, int *_s, int *_v) const;
protected:
int h;
int s;
int v;
int r;
int g;
int b;
private:
class OColorPrivate;
OColorPrivate *d;
};
+}
+}
#endif // __OSELECT_H__
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,127 +1,129 @@
/*
                This file is part of the Opie Project
              Copyright (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
Copyright (C) 1997 Michael Roth <mroth@wirlweb.de>
=.
.=l.
           .>+-=
 _;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
/* OPIE */
#include <opie2/odebug.h>
#include <opie2/oseparator.h>
/* QT */
+using namespace Opie::Core;
+using namespace Opie::Ui;
OSeparator::OSeparator(QWidget* parent, const char* name, WFlags f)
: QFrame(parent, name, f)
{
setLineWidth(1);
setMidLineWidth(0);
setOrientation( HLine );
}
OSeparator::OSeparator(int orientation, QWidget* parent, const char* name, WFlags f)
: QFrame(parent, name, f)
{
setLineWidth(1);
setMidLineWidth(0);
setOrientation( orientation );
}
void OSeparator::setOrientation(int orientation)
{
switch(orientation)
{
case Vertical:
case VLine:
setFrameStyle( QFrame::VLine | QFrame::Sunken );
setMinimumSize(2, 0);
break;
default:
owarn << "OSeparator::setOrientation(): invalid orientation, using default orientation HLine" << oendl;
case Horizontal:
case HLine:
setFrameStyle( QFrame::HLine | QFrame::Sunken );
setMinimumSize(0, 2);
break;
}
}
int OSeparator::orientation() const
{
if ( frameStyle() & VLine )
return VLine;
if ( frameStyle() & HLine )
return HLine;
return 0;
}
void OSeparator::drawFrame(QPainter *p)
{
QPoint p1, p2;
QRect r = frameRect();
const QColorGroup & g = colorGroup();
if ( frameStyle() & HLine ) {
p1 = QPoint( r.x(), r.height()/2 );
p2 = QPoint( r.x()+r.width(), p1.y() );
}
else {
p1 = QPoint( r.x()+r.width()/2, 0 );
p2 = QPoint( p1.x(), r.height() );
}
#if QT_VERSION < 300
style().drawSeparator( p, p1.x(), p1.y(), p2.x(), p2.y(), g, true, 1, midLineWidth() );
#else
QStyleOption opt( lineWidth(), midLineWidth() );
style().drawPrimitive( QStyle::PE_Separator, p, QRect( p1, p2 ), g, QStyle::Style_Sunken, opt );
#endif
}
QSize OSeparator::sizeHint() const
{
if ( frameStyle() & VLine )
return QSize(2, 0);
if ( frameStyle() & HLine )
return QSize(0, 2);
return QSize(-1, -1);
}
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 @@
/*
                This file is part of the Opie Project
              Copyright (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
Copyright (C) 1997 Michael Roth <mroth@wirlweb.de>
=.
.=l.
           .>+-=
 _;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef OSEPARATOR_H
#define OSEPARATOR_H
#include <qframe.h>
+namespace Opie {
+namespace Ui {
+
/**
* Standard horizontal or vertical separator.
*
* @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
* @author Michael Roth <mroth@wirlweb.de>
* @version $Id$
*/
class OSeparator : public QFrame
{
Q_OBJECT
Q_PROPERTY( int orientation READ orientation WRITE setOrientation )
public:
/**
* Constructor.
**/
OSeparator(QWidget* parent=0, const char* name=0, WFlags f=0);
/**
* Constructor.
*
* @param orientation Set the orientation of the separator.
* Possible values are HLine or Horizontal and VLine or Vertical.
**/
OSeparator(int orientation, QWidget* parent=0, const char* name=0,
WFlags f=0);
/**
* Returns the orientation of the separator.
*
* Possible values are VLine and HLine.
**/
int orientation() const;
/**
* Set the orientation of the separator to @p orient
*
* Possible values are VLine and HLine.
*/
void setOrientation(int orient);
/**
* The recommended height (width) for a horizontal (vertical) separator.
**/
virtual QSize sizeHint() const;
protected:
virtual void drawFrame( QPainter * );
private:
class OSeparatorPrivate* d;
};
+}
+}
#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,83 +1,83 @@
/*
                This file is part of the Opie Project
              Copyright (c) 2002 Dan Williams <williamsdr@acm.org>
=.
.=l.
           .>+-=
 _;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include <opie2/otabbar.h>
-using namespace Opie;
+using namespace Opie::Ui;
OTabBar::OTabBar( QWidget *parent , const char *name )
:QTabBar( parent, name )
{}
void OTabBar::paintLabel( QPainter* p, const QRect& br, QTab* t, bool has_focus ) const
{
QRect r = br;
if ( t->iconset)
{
QIconSet::Mode mode = (t->enabled && isEnabled()) ? QIconSet::Normal : QIconSet::Disabled;
if ( mode == QIconSet::Normal && has_focus )
{
mode = QIconSet::Active;
}
QPixmap pixmap = t->iconset->pixmap( QIconSet::Small, mode );
int pixw = pixmap.width();
int pixh = pixmap.height();
r.setLeft( r.left() + pixw + 2 );
p->drawPixmap( br.left()+2, br.center().y()-pixh/2, pixmap );
}
QRect tr = r;
if ( t->id == currentTab() )
{
tr.setBottom( tr.bottom() - style().defaultFrameWidth() );
}
if ( t->enabled && isEnabled() )
{
p->setPen( colorGroup().foreground() );
p->drawText( tr, AlignCenter | ShowPrefix, t->label );
}
else if ( style() == MotifStyle )
{
p->setPen( palette().disabled().foreground() );
p->drawText( tr, AlignCenter | ShowPrefix, t->label );
}
else
{
p->setPen( colorGroup().light() );
QRect wr = tr;
wr.moveBy( 1, 1 );
p->drawText( wr, AlignCenter | ShowPrefix, t->label );
p->setPen( palette().disabled().foreground() );
p->drawText( tr, AlignCenter | ShowPrefix, t->label );
}
}
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 @@
/*
                This file is part of the Opie Project
              Copyright (c) 2002 Dan Williams <williamsdr@acm.org>
=.
.=l.
           .>+-=
 _;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef OTABBAR_H
#define OTABBAR_H
/* QT */
#include <qtabbar.h>
-namespace Opie
-{
+namespace Opie {
+namespace Ui {
/**
* @class OTabBar
* @brief The OTabBar class is a derivative of QTabBar.
*
* OTabBar is a derivation of TrollTech's QTabBar which provides
* a row of tabs for selection. The only difference between this
* class and QTabBar is that there is no dotted line box around
* the label of the tab with the current focus.
*/
class OTabBar : public QTabBar
{
Q_OBJECT
public:
/**
* @fn OTabBar( QWidget *parent = 0, const char *name = 0 )
* @brief Object constructor.
*
* @param parent Pointer to parent of this control.
* @param name Name of control.
*
* Constructs a new OTabBar control with parent and name.
*/
OTabBar( QWidget * = 0, const char * = 0 );
protected:
/**
* @fn paintLabel( QPainter* p, const QRect& br , QTab* t, bool has_focus)const
* @brief Internal function to draw a tab's label.
*
* @param p Pointer to QPainter used for drawing.
* @param br QRect providing region to draw label in.
* @param t Tab to draw label for.
* @param has_focus Boolean value not used, retained for compatibility reasons.
*/
void paintLabel( QPainter *, const QRect &, QTab *, bool ) const;
private:
class Private;
Private *d;
};
-};
+}
+}
#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 @@
/*
                This file is part of the Opie Project
              Copyright (c) 2002 Dan Williams <williamsdr@acm.org>
=.
.=l.
           .>+-=
 _;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef OTABINFO_H
#define OTABINFO_H
/* QT */
#include <qlist.h>
#include <qstring.h>
class QWidget;
-namespace Opie
-{
+namespace Opie{
+namespace Ui {
/**
* @class OTabInfo
* @brief The OTabInfo class is used internally by OTabWidget to keep track
* of widgets added to the control.
*
* OTabInfo provides the following information about a widget added to an
* OTabWidget control:
*
* ID - integer tab bar ID
* Control - QWidget pointer to child widget
* Label - QString text label for OTabWidget selection control
* Icon - QString name of icon file
*/
class OTabInfo
{
public:
/**
* @fn OTabInfo()
* @brief Object constructor.
*
* @param parent Pointer to parent of this control.
* @param name Name of control.
* @param s Style of widget selection control.
* @param p Position of the widget selection control.
*/
OTabInfo() : i( -1 ), c( 0 ), p( 0 ), l( QString::null ) {}
/**
* @fn OTabInfo( int id, QWidget *control, const QString &icon, const QString &label )
* @brief Object constructor.
*
* @param id TabBar identifier for widget.
* @param control QWidget pointer to widget.
* @param icon QString name of icon file.
* @param label QString text label for OTabWidget selection control.
*/
OTabInfo( int id, QWidget *control, const QString &icon, const QString &label )
: i( id ), c( control ), p( icon ), l( label ) {}
/**
* @fn id()const
* @brief Returns TabBar ID.
*/
int id() const { return i; }
/**
* @fn label()const
* @brief Returns text label for widget.
*/
const QString &label() const { return l; }
/**
* @fn setLabel( const QString &label )
* @brief Set label for tab.
*
* @param label QString text label for OTabWidget selection control.
*/
void setLabel( const QString &label ) { l = label; }
/**
* @fn control()const
* @brief Returns pointer to widget.
*/
QWidget *control() const { return c; }
/**
* @fn icon()const
* @brief Returns name of icon file.
*/
const QString &icon() const { return p; }
/**
* @fn setIcon( const QString &icon )
* @brief Set icon for tab.
*
* @param icon QString name of icon file.
*/
void setIcon( const QString &icon ) { p = icon; }
private:
int i;
QWidget *c;
QString p;
QString l;
class Private;
Private *d;
};
/**
* @class OTabInfoList
* @brief A list of OTabInfo objects used by OTabWidget.
*/
typedef QList<OTabInfo> OTabInfoList;
-};
+}
+}
#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,140 +1,140 @@
/*
                This file is part of the Opie Project
              Copyright (c) 2002 Dan Williams <williamsdr@acm.org>
=.
.=l.
           .>+-=
 _;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include <opie2/otabwidget.h>
/* OPIE */
#include <qpe/applnk.h>
#include <qpe/config.h>
#include <qpe/resource.h>
#include <opie2/otabbar.h>
/* QT */
#include <qcombobox.h>
#include <qwidgetstack.h>
-using namespace Opie;
+using namespace Opie::Ui;
OTabWidget::OTabWidget( QWidget *parent, const char *name, TabStyle s, TabPosition p )
: QWidget( parent, name )
{
if ( s == Global )
{
Config config( "qpe" );
config.setGroup( "Appearance" );
s = ( TabStyle ) config.readNumEntry( "TabStyle", (int) IconTab );
if ( s <= Global || s > IconList)
{
s = IconTab;
}
QString pos = config.readEntry( "TabPosition", "Top");
if ( pos == "Bottom" )
{
p = Bottom;
}
else
{
p = Top;
}
}
widgetStack = new QWidgetStack( this, "widgetstack" );
widgetStack->setFrameStyle( QFrame::NoFrame );
widgetStack->setLineWidth( style().defaultFrameWidth() );
tabBarStack = new QWidgetStack( this, "tabbarstack" );
tabBar = new OTabBar( tabBarStack, "tabbar" );
tabBarStack->addWidget( tabBar, 0 );
connect( tabBar, SIGNAL( selected(int) ), this, SLOT( slotTabBarSelected(int) ) );
tabList = new QComboBox( false, tabBarStack, "tablist" );
tabBarStack->addWidget( tabList, 1 );
connect( tabList, SIGNAL( activated(int) ), this, SLOT( slotTabListSelected(int) ) );
tabBarPosition = p;
setTabStyle( s );
setTabPosition( p );
currTab= 0x0;
}
OTabWidget::~OTabWidget()
{}
void OTabWidget::addTab( QWidget *child, const QString &icon, const QString &label )
{
QPixmap iconset = loadSmooth( icon );
QTab *tab = new QTab();
if ( tabBarStyle == IconTab )
{
tab->label = QString::null;
}
else
{
tab->label = label;
}
if ( tabBarStyle == IconTab || tabBarStyle == IconList )
{
tab->iconset = new QIconSet( iconset );
}
int tabid = tabBar->addTab( tab );
if ( tabBarStyle == IconTab || tabBarStyle == IconList )
{
tabList->insertItem( iconset, label, -1 );
}
else
{
tabList->insertItem( label );
}
widgetStack->addWidget( child, tabid );
widgetStack->raiseWidget( child );
widgetStack->setFrameStyle( QFrame::StyledPanel | QFrame::Raised );
OTabInfo *tabinfo = new OTabInfo( tabid, child, icon, label );
tabs.append( tabinfo );
selectTab( tabinfo );
}
void OTabWidget::removePage( QWidget *childwidget )
{
if ( childwidget )
{
OTabInfo *tab = tabs.first();
while ( tab && tab->control() != childwidget )
{
tab = tabs.next();
}
if ( tab && tab->control() == childwidget )
{
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,145 +1,144 @@
/*
                This file is part of the Opie Project
              Copyright (C) 2002 Dan Williams <williamsdr@acm.org>
=.
.=l.
           .>+-=
 _;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef OTABWIDGET_H
#define OTABWIDGET_H
/* OPIE */
#include <opie2/otabinfo.h>
/* QT */
#include <qwidget.h>
#include <qlist.h>
-using namespace Opie;
class QComboBox;
class QPixmap;
class QTabBar;
class QWidgetStack;
-namespace Opie
-{
+namespace Opie {
+namespace Ui {
class OTabBar;
/**
* @class OTabWidget
* @brief The OTabWidget class provides a stack of widgets.
*
* OTabWidget is a derivation of TrollTech's QTabWidget which provides
* a stack of widgets. Widgets can be selected using either a tab bar or
* drop down list box.
*
* The normal way to use OTabWidget is to do the following in the
* constructor:
* - Create a OTabWidget.
* - Create a QWidget for each of the pages in the control, insert
* children into it, set up geometry management for it, and use addTab()
* to add the widget.
*/
class OTabWidget : public QWidget
{
Q_OBJECT
public:
/**
* @enum TabStyle
* @brief Defines how the widget selection control is displayed.
*
* Valid values:
* - Global: use globally selected options (qpe.conf - TabStyle & TabPosition)
* - TextTab: Tabbed widget selection with text labels
* - IconTab: Tabbed widget selection with icon labels, text label for active widget
* (similar to Opie launcher)
* - TextList: Drop down list widget selection with text labels
* - IconList: Drop down list widget selection with icon & text labels
*/
enum TabStyle { Global, TextTab, IconTab, TextList, IconList };
/**
* @enum TabPosition
* @brief Defines where the widget selection control is drawn.
*
* Valid values:
* - Top: Widget selection control is drawn above widgets
* - Bottom: Widget selection control is drawn below widgets
*/
enum TabPosition { Top, Bottom };
/**
* @fn OTabWidget( QWidget *parent = 0, const char *name = 0, TabStyle s = Global, TabPosition p = Top )
* @brief Object constructor.
*
* @param parent Pointer to parent of this control.
* @param name Name of control.
* @param s Style of widget selection control.
* @param p Position of the widget selection control.
*
* Constructs a new OTabWidget control with parent and name. The style and position parameters
* determine how the widget selection control will be displayed.
*/
OTabWidget( QWidget * = 0, const char * = 0, TabStyle = Global, TabPosition = Top );
/**
* @fn ~OTabWidget()
* @brief Object destructor.
*/
~OTabWidget();
/**
* @fn addTab( QWidget *child, const QString &icon, const QString &label )
* @brief Add new widget to control.
*
* @param child Widget control.
* @param icon Path to icon.
* @param label Text label.
*/
void addTab( QWidget *, const QString &, const QString & );
/**
* @fn removePage( QWidget *widget )
* @brief Remove widget from control. Does not delete widget.
*
* @param widget Widget control to be removed.
*/
void removePage( QWidget * );
/**
* @fn changeTab( QWidget *widget, const QString &icon, const QString &label )
* @brief Change text and/or icon for existing tab
*
* @param child Widget control.
* @param icon Path to icon.
* @param label Text label.
*/
void changeTab( QWidget *, const QString &, const QString & );
/**
@@ -194,99 +193,100 @@ class OTabWidget : public QWidget
*/
void setCurrentTab(int);
/**
* @fn sizeHint()const
* @brief Reimplemented for internal purposes.
*/
QSize sizeHint() const;
/**
* @fn currentTab( )
* @brief returns current tab id.
*/
// ### make const
int currentTab()/* const */;
/**
* @brief returns the current page of the active tab
*
* @since 1.2
*/
QWidget* currentWidget()const;
protected:
/**
* @fn resizeEvent( QResizeEvent * )
* @brief Reimplemented for internal purposes.
*/
void resizeEvent( QResizeEvent * );
private:
OTabInfoList tabs;
OTabInfo *currTab;
TabStyle tabBarStyle;
TabPosition tabBarPosition;
QWidgetStack *tabBarStack;
OTabBar *tabBar;
QComboBox *tabList;
QWidgetStack *widgetStack;
class Private;
Private* d;
/**
* @fn loadSmooth( const QString &name )
* @brief Loads icon for widget.
*
* @param name Name of icon image file.
*/
QPixmap loadSmooth( const QString & );
/**
* @fn selectTab( OTabInfo *tab )
* @brief Internal function to select desired widget.
*
* @param tab Pointer to data for widget.
*/
void selectTab( OTabInfo * );
/**
* @fn setUpLayout()
* @brief Internal function to adjust layout.
*/
void setUpLayout();
signals:
/**
* @fn currentChanegd( QWidget *widget )
* @brief This signal is emitted whenever the widget has changed.
*
* @param widget Pointer to new current widget.
*/
void currentChanged( QWidget * );
private slots:
/**
* @fn slotTabBarSelected( int id )
* @brief Slot which is called when a tab is selected.
*
* @param id ID of widget selected.
*/
void slotTabBarSelected( int );
/**
* @fn slotTabListSelected( int index )
* @brief Slot which is called when a drop down selection is made.
*
* @param id Index of widget selected.
*/
void slotTabListSelected( int );
};
-};
+}
+}
#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 @@
/*
                This file is part of the Opie Project
              Copyright (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
=.
.=l.
           .>+-=
 _;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
+#include <opie2/otaskbarapplet.h>
+
+#include <qpe/qpeapplication.h>
+#include <qframe.h>
+
+using namespace Opie::Ui;
+
+
+/**
+ * \todo no example yet!!!
+ * If you want to implement an Applet for the Opie Taskbar
+ * use this interface.
+ * The only specail thing about applets is that you need to build
+ * it as plugin/library and do EXPORT_OPIE_APPLET_v1( YourApplet )
+ * at the bottom of your application. This takes care of
+ * the activation and implementing the TaskbarAppletInterface.
+ * You also need to add a static int position() functions to your
+ * application.
+ * \code
+ * class MyApplet : public OTaskBarApplet {
+ * public:
+ * static int position() { return 3: }
+ * void doStuff() {
+ * popup( myWidget );
+ * }
+ * };
+ * EXPORT_OPIE_APPLET_v1( MyApplet )
+ * \endcode
+ *
+ * @author Michael Lauer
+ * @version 0.5
+ * @see TaskbarAppletInterface
+ */
+OTaskbarApplet::OTaskbarApplet( QWidget* parent, const char* name )
+ :QWidget( parent, name ){
+ setFixedHeight( 18 );
+ setFixedWidth( 14 );
+}
+
+OTaskbarApplet::~OTaskbarApplet(){
+}
+
+void OTaskbarApplet::popup( QWidget* widget ){
+ QPoint curPos = mapToGlobal( QPoint( 0, 0 ) );
+ int w = widget->sizeHint().width();
+ int x = curPos.x() - (w/2 );
+ if ( (x+w) > QPEApplication::desktop()->width() )
+ x = QPEApplication::desktop()->width()-w;
+ widget->move( x, curPos.y()-widget->sizeHint().height() );
+ widget->show();
+}
-// 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 @@
/*
                This file is part of the Opie Project
              Copyright (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
=.
.=l.
           .>+-=
 _;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef OTASKBARAPPLET_H
#define OTASKBARAPPLET_H
#include <qpe/taskbarappletinterface.h>
+#include <qpe/qcom.h>
+#include <qwidget.h>
+
+class QMouseEvent;
+
+namespace Opie {
+namespace Ui {
+namespace Private {
/*======================================================================================
* OTaskbarAppletWrapper
*======================================================================================*/
+class OTaskbarAppletWrapperPrivate;
template<class T> class OTaskbarAppletWrapper : public TaskbarAppletInterface
{
public:
OTaskbarAppletWrapper():_applet( 0 )
{
}
virtual ~OTaskbarAppletWrapper()
{
delete _applet;
}
QRESULT queryInterface( const QUuid& uuid, QUnknownInterface** iface )
{
qDebug( "OTaskbarAppletWrapper::queryInterface()" );
*iface = 0;
if ( uuid == IID_QUnknown )
*iface = this;
else if ( uuid == IID_TaskbarApplet )
*iface = this;
else
return QS_FALSE;
if ( *iface ) (*iface)->addRef();
return QS_OK;
}
Q_REFCOUNT
virtual T* applet( QWidget* parent )
{
if ( !_applet ) _applet = new T( parent );
return _applet;
}
virtual int position() const
{
return T::position();
}
private:
T* _applet;
+ OTaskbarAppletWrapperPrivate *d;
};
-#include <qframe.h>
-#include <qwidget.h>
-#include <qpe/qpeapplication.h>
-
-class QMouseEvent;
-
+}
/*======================================================================================
* OTaskbarApplet
*======================================================================================*/
// Must be inline until after we shipped Opie 1.0
// Having OTaskBarApplet reside in libopieui2 is not possible
// until we link the launcher binary against libopieui2 -
// otherwise the necessary symbols are not present, when
// the dynamic loader [dlopen] tries to resolve an applet which
// inherits OTaskbarApplet
class OTaskbarApplet : public QWidget
{
public:
- OTaskbarApplet( QWidget* parent, const char* name = 0 ):QWidget( parent, name )
- {
- setFixedHeight( 18 );
- setFixedWidth( 14 );
- }
-
- virtual ~OTaskbarApplet()
- {
- }
+ OTaskbarApplet( QWidget* parent, const char* name = 0 );
+ virtual ~OTaskbarApplet();
protected:
- virtual void popup( QWidget* widget )
- {
- QPoint curPos = mapToGlobal( QPoint( 0, 0 ) );
- int w = widget->sizeHint().width();
- int x = curPos.x() - (w/2 );
- if ( (x+w) > QPEApplication::desktop()->width() )
- x = QPEApplication::desktop()->width()-w;
- widget->move( x, curPos.y()-widget->sizeHint().height() );
- widget->show();
- }
+ virtual void popup( QWidget* widget );
+private:
+ class Private;
+ Private *d;
};
+}
+}
+
+#define EXPORT_OPIE_APPLET_v1( AppLet ) \
+ Q_EXPORT_INTERFACE() { \
+ Q_CREATE_INSTANCE( Opie::Ui::Private::OTaskbarAppletWrapper<AppLet> ) \
+ }
#endif
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,292 +1,301 @@
/*
This file is part of the Opie Project
Copyright (C) Stefan Eilers <eilers.stefan@epost.de>
=. Copyright (C) The Opie Team <opie-devel@handhelds.org>
.=l.
           .>+-=
 _;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
+/* OPIE */
+#include <opie2/otimepicker.h>
+
/* QT */
+#include <qgroupbox.h>
#include <qlayout.h>
#include <qlineedit.h>
-/* OPIE */
-#include <opie2/otimepicker.h>
-using namespace Opie;
+
+namespace Opie {
+namespace Ui {
/**
* Constructs the widget
* @param parent The parent of the OTimePicker
* @param name The name of the object
* @param fl Window Flags
*/
OTimePicker::OTimePicker(QWidget* parent, const char* name, Qt::WFlags fl)
:QWidget(parent,name,fl)
{
QVBoxLayout *vbox=new QVBoxLayout(this);
OClickableLabel *r;
QString s;
// Hour Row
QWidget *row=new QWidget(this);
QHBoxLayout *l=new QHBoxLayout(row);
vbox->addWidget(row);
for (int i=0; i<24; i++)
{
r=new OClickableLabel(row);
hourLst.append(r);
s.sprintf("%.2d",i);
r->setText(s);
r->setToggleButton(true);
r->setAlignment(AlignHCenter | AlignVCenter);
l->addWidget(r);
connect(r, SIGNAL(toggled(bool)),
this, SLOT(slotHour(bool)));
if (i==11)
{ // Second row
row=new QWidget(this);
l=new QHBoxLayout(row);
vbox->addWidget(row);
}
}
// Minute Row
row=new QWidget(this);
l=new QHBoxLayout(row);
vbox->addWidget(row);
for (int i=0; i<60; i+=5)
{
r=new OClickableLabel(row);
minuteLst.append(r);
s.sprintf("%.2d",i);
r->setText(s);
r->setToggleButton(true);
r->setAlignment(AlignHCenter | AlignVCenter);
l->addWidget(r);
connect(r, SIGNAL(toggled(bool)),
this, SLOT(slotMinute(bool)));
}
}
/**
* This method return the current time
* @return the time
*/
QTime OTimePicker::time()const
{
return tm;
}
void OTimePicker::slotHour(bool b)
{
OClickableLabel *r = (OClickableLabel *) sender();
if (b)
{
QValueListIterator<OClickableLabel *> it;
for (it=hourLst.begin(); it!=hourLst.end(); it++)
{
if (*it != r) (*it)->setOn(false);
else tm.setHMS((*it)->text().toInt(), tm.minute(), 0);
}
emit timeChanged(tm);
}
else
{
r->setOn(true);
}
}
void OTimePicker::slotMinute(bool b)
{
OClickableLabel *r = (OClickableLabel *) sender();
if (b)
{
QValueListIterator<OClickableLabel *> it;
for (it=minuteLst.begin(); it!=minuteLst.end(); it++)
{
if (*it != r) (*it)->setOn(false);
else tm.setHMS(tm.hour(),(*it)->text().toInt(), 0);
}
emit timeChanged(tm);
}
else
{
r->setOn(true);
}
}
/**
* Method to set the time. No signal gets emitted during this method call
* Minutes must be within 5 minutes step starting at 0 ( 0,5,10,15,20... )
* @param t The time to be set
*/
void OTimePicker::setTime( const QTime& t)
{
setTime( t.hour(), t.minute() );
}
/**
* Method to set the time. No signal gets emitted during this method call
* @param h The hour
* @param m The minute. Minutes need to set by 5 minute steps
*/
void OTimePicker::setTime( int h, int m )
{
setHour(h);
setMinute(m);
}
/*
* FIXME round minutes to the 5 minute arrangement -zecke
*/
/**
* Method to set the minutes
* @param m minutes
*/
void OTimePicker::setMinute(int m)
{
QString minute;
minute.sprintf("%.2d",m);
QValueListIterator<OClickableLabel *> it;
for (it=minuteLst.begin(); it!=minuteLst.end(); it++)
{
if ((*it)->text() == minute) (*it)->setOn(true);
else (*it)->setOn(false);
}
tm.setHMS(tm.hour(),m,0);
}
/**
* Method to set the hour
*/
void OTimePicker::setHour(int h)
{
QString hour;
hour.sprintf("%.2d",h);
QValueListIterator<OClickableLabel *> it;
for (it=hourLst.begin(); it!=hourLst.end(); it++)
{
if ((*it)->text() == hour) (*it)->setOn(true);
else (*it)->setOn(false);
}
tm.setHMS(h,tm.minute(),0);
}
/**
* This is a modal Dialog.
*
* @param parent The parent widget
* @param name The name of the object
* @param fl Possible window flags
*/
OTimePickerDialog::OTimePickerDialog ( QWidget* parent, const char* name, WFlags fl )
: OTimePickerDialogBase (parent , name, true , fl)
{
+ m_timePicker = new OTimePicker( GroupBox1, "m_timePicker" );
+ GroupBox1Layout->addWidget( m_timePicker, 0, 0 );
connect ( m_timePicker, SIGNAL( timeChanged(const QTime&) ),
this, SLOT( setTime(const QTime&) ) );
connect ( minuteField, SIGNAL( textChanged(const QString&) ),
this, SLOT ( setMinute(const QString&) ) );
connect ( hourField, SIGNAL( textChanged(const QString&) ),
this, SLOT ( setHour(const QString&) ) );
}
/**
* @return the time
*/
QTime OTimePickerDialog::time()const
{
return m_time;
}
/**
* Set the time to time
* @param time The time to be set
*/
void OTimePickerDialog::setTime( const QTime& time )
{
m_time = time;
m_timePicker->setHour ( time.hour() );
m_timePicker->setMinute( time.minute() );
// Set Textfields
if ( time.hour() < 10 )
hourField->setText( "0" + QString::number( time.hour() ) );
else
hourField->setText( QString::number( time.hour() ) );
if ( time.minute() < 10 )
minuteField->setText( "0" + QString::number( time.minute() ) );
else
minuteField->setText( QString::number( time.minute() ) );
}
/**
* This method takes the current minute and tries to set hour
* to hour. This succeeds if the resulting date is valid
* @param hour The hour as a string
*/
void OTimePickerDialog::setHour ( const QString& hour )
{
if ( QTime::isValid ( hour.toInt(), m_time.minute() , 00 ) )
{
m_time.setHMS ( hour.toInt(), m_time.minute() , 00 );
setTime ( m_time );
}
}
/**
* Method to set a new minute. It tries to convert the string to int and
* if the resulting date is valid a new date is set.
* @see setHour
*/
void OTimePickerDialog::setMinute ( const QString& minute )
{
if ( QTime::isValid ( m_time.hour(), minute.toInt(), 00 ) )
{
m_time.setHMS ( m_time.hour(), minute.toInt(), 00 );
setTime ( m_time );
}
}
+
+}
+}
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 @@
/*
This file is part of the Opie Project
Copyright (C) Stefan Eilers <eilers.stefan@epost.de>
=. Copyright (C) The Opie Team <opie-devel@handhelds.org>
.=l.
           .>+-=
 _;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef OTIMEPICKER_H
#define OTIMEPICKER_H
/* OPIE */
#include <opie2/oclickablelabel.h>
-#include "otimepickerbase.h"
+#include <opie2/otimepickerbase.h>
/* QT */
#include <qwidget.h>
#include <qvaluelist.h>
#include <qdatetime.h>
#include <qdialog.h>
-using namespace Opie;
-// namespace Opie
-// {
+namespace Opie {
+namespace Ui {
/**
* A class to pick time. It uses clickable labels
* internally to allow a quick selection of a time.
* A time can be selected by two clicks of a user
*
* @short A widget to quickly pick a QTime
* @version 1.0
* @see QWidget
* @see QTime
* @author Hakan Ardo, Stefan Eilers
*/
-class OTimePicker: public QWidget
+class OTimePicker : public QWidget
{
Q_OBJECT
public:
OTimePicker(QWidget* parent = 0, const char* name = 0, WFlags fl = 0);
public slots:
void setHour(int h);
void setMinute(int m);
void setTime( const QTime& );
void setTime( int h, int m );
public:
QTime time()const;
private:
QValueList<OClickableLabel *> hourLst;
QValueList<OClickableLabel *> minuteLst;
QTime tm;
struct Private;
Private *d;
private slots:
void slotHour(bool b);
void slotMinute(bool b);
signals:
/**
* gets emitted when the time got changed by the user
*/
void timeChanged(const QTime &);
};
/**
*
* @short A small dialog to pick a time
* @version 1.0
* @author Stefan Eilers
*
**/
class OTimePickerDialog: public OTimePickerDialogBase
{
Q_OBJECT
public:
OTimePickerDialog ( QWidget* parent = 0, const char* name = NULL, WFlags fl = 0 );
~OTimePickerDialog() { };
QTime time()const;
public slots:
void setTime( const QTime& time );
void setHour( const QString& hour );
void setMinute( const QString& minute );
private:
+ OTimePicker *m_timePicker;
QTime m_time;
class Private;
Private* d;
};
-// };
+}
+}
+/* for Qt2 */
+#if ( QT_VERSION-0 >= 0x030000 )
+#error "Fix the UI File to use namespaces"
+#else
+typedef Opie::Ui::OTimePicker OUIOTimePicker;
+#endif
#endif
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,110 +1,110 @@
<!DOCTYPE UI><UI>
<class>OTimePickerDialogBase</class>
<widget>
<class>QDialog</class>
<property stdset="1">
<name>name</name>
<cstring>OTimePickerDialogBase</cstring>
</property>
<property stdset="1">
<name>geometry</name>
<rect>
<x>0</x>
<y>0</y>
- <width>210</width>
+ <width>182</width>
<height>137</height>
</rect>
</property>
<property stdset="1">
<name>sizePolicy</name>
<sizepolicy>
<hsizetype>3</hsizetype>
<vsizetype>1</vsizetype>
</sizepolicy>
</property>
<property stdset="1">
<name>caption</name>
<string>OTimePickerDialogBase</string>
</property>
<property>
<name>layoutMargin</name>
</property>
<property>
<name>layoutSpacing</name>
</property>
<vbox>
<property stdset="1">
<name>margin</name>
<number>5</number>
</property>
<property stdset="1">
<name>spacing</name>
<number>4</number>
</property>
<widget>
<class>QFrame</class>
<property stdset="1">
<name>name</name>
<cstring>Frame10</cstring>
</property>
<property stdset="1">
<name>sizePolicy</name>
<sizepolicy>
<hsizetype>1</hsizetype>
<vsizetype>7</vsizetype>
</sizepolicy>
</property>
<property stdset="1">
<name>frameShape</name>
<enum>NoFrame</enum>
</property>
<property stdset="1">
<name>frameShadow</name>
<enum>Raised</enum>
</property>
<property>
<name>layoutMargin</name>
</property>
<hbox>
<property stdset="1">
<name>margin</name>
<number>2</number>
</property>
<property stdset="1">
<name>spacing</name>
<number>6</number>
</property>
<spacer>
<property>
<name>name</name>
<cstring>Spacer4</cstring>
</property>
<property stdset="1">
<name>orientation</name>
<enum>Horizontal</enum>
</property>
<property stdset="1">
<name>sizeType</name>
<enum>MinimumExpanding</enum>
</property>
<property>
<name>sizeHint</name>
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
<widget>
<class>QFrame</class>
<property stdset="1">
<name>name</name>
<cstring>Frame4</cstring>
</property>
<property stdset="1">
<name>sizePolicy</name>
<sizepolicy>
<hsizetype>4</hsizetype>
<vsizetype>4</vsizetype>
</sizepolicy>
</property>
@@ -156,137 +156,101 @@
</sizepolicy>
</property>
<property stdset="1">
<name>alignment</name>
<set>AlignHCenter</set>
</property>
<property>
<name>hAlign</name>
</property>
</widget>
<widget>
<class>QLabel</class>
<property stdset="1">
<name>name</name>
<cstring>TextLabel1_2</cstring>
</property>
<property stdset="1">
<name>font</name>
<font>
<bold>1</bold>
</font>
</property>
<property stdset="1">
<name>text</name>
<string>:</string>
</property>
</widget>
<widget>
<class>QLineEdit</class>
<property stdset="1">
<name>name</name>
<cstring>minuteField</cstring>
</property>
<property stdset="1">
<name>alignment</name>
<set>AlignHCenter</set>
</property>
<property>
<name>hAlign</name>
</property>
</widget>
</hbox>
</widget>
<spacer>
<property>
<name>name</name>
<cstring>Spacer5</cstring>
</property>
<property stdset="1">
<name>orientation</name>
<enum>Horizontal</enum>
</property>
<property stdset="1">
<name>sizeType</name>
<enum>MinimumExpanding</enum>
</property>
<property>
<name>sizeHint</name>
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</hbox>
</widget>
<widget>
<class>QGroupBox</class>
<property stdset="1">
<name>name</name>
<cstring>GroupBox1</cstring>
</property>
<property stdset="1">
<name>sizePolicy</name>
<sizepolicy>
<hsizetype>3</hsizetype>
<vsizetype>3</vsizetype>
</sizepolicy>
</property>
<property stdset="1">
<name>margin</name>
<number>0</number>
</property>
<property stdset="1">
<name>title</name>
<string>Pick Time:</string>
</property>
<grid>
<property stdset="1">
<name>margin</name>
<number>11</number>
</property>
<property stdset="1">
<name>spacing</name>
<number>6</number>
</property>
- <widget row="0" column="0" >
- <class>OTimePicker</class>
- <property stdset="1">
- <name>name</name>
- <cstring>m_timePicker</cstring>
- </property>
- <property stdset="1">
- <name>sizePolicy</name>
- <sizepolicy>
- <hsizetype>3</hsizetype>
- <vsizetype>3</vsizetype>
- </sizepolicy>
- </property>
- </widget>
</grid>
</widget>
</vbox>
</widget>
-<customwidgets>
- <customwidget>
- <class>OTimePicker</class>
- <header location="local">otimepicker.h</header>
- <sizehint>
- <width>-1</width>
- <height>-1</height>
- </sizehint>
- <container>0</container>
- <sizepolicy>
- <hordata>7</hordata>
- <verdata>1</verdata>
- </sizepolicy>
- <pixmap>image0</pixmap>
- </customwidget>
-</customwidgets>
-<images>
- <image>
- <name>image0</name>
- <data format="XPM.GZ" length="646">789c6dd2c10ac2300c00d07bbf2234b7229d1ddec44f503c0ae2a154410f53d0ed20e2bf6bdb656dd6861dd23d9a66591b0587fd1654235ebded6f0edcd53e419d87ae7b1f4f9b8f906d0bfe012317426a70b07bdc2f3ec77f8ed6b89559061a0343d06a124cc105596482585094bc0ae599b04646c9018926491b2205e140c485cace25755c175d0a967b622ff900b8cc9c7d29af594ea722d589167f813aa852ba07d94b9dce296e883fe7bb163f23896753</data>
- </image>
-</images>
</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,317 +1,320 @@
/*
                This file is part of the Opie Project
=. (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
.=l.
           .>+-=
 _;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
/* OPIE */
#include <opie2/odebug.h>
#include <opie2/oversatileview.h>
#include <opie2/oversatileviewitem.h>
#include <opie2/olistview.h>
/* QT */
#include <qaction.h>
#include <qpopupmenu.h>
+using namespace Opie::Core;
+using namespace Opie::Ui;
+
/* XPM */
static const char * view_icon_xpm[] = {
"16 16 16 1",
" c None",
". c #87BD88",
"+ c #8BBE8B",
"@ c #81BA81",
"# c #6DAF6D",
"$ c #87BD87",
"% c #FCFDFC",
"& c #AED0AE",
"* c #4E9C4C",
"= c #91BD91",
"- c #72B172",
"; c #448643",
"> c #519F50",
", c #499247",
"' c #356A35",
") c #686868",
" ",
" .+@# .+@# ",
" $%&* $%&* ",
" @=-; @=-; ",
" #>,' #>,' ",
" ",
" )))))) )))))) ",
" ",
" ",
" .+@# .+@# ",
" $%&* $%&* ",
" @=-; @=-; ",
" #>,' #>,' ",
" ",
" )))))) )))))) ",
" "};
/* XPM */
static const char * view_tree_xpm[] = {
"16 16 17 1",
" c None",
". c #3A3A3A",
"+ c #87BD88",
"@ c #8BBE8B",
"# c #81BA81",
"$ c #6DAF6D",
"% c #87BD87",
"& c #FCFDFC",
"* c #AED0AE",
"= c #4E9C4C",
"- c #91BD91",
"; c #72B172",
"> c #448643",
", c #686868",
"' c #519F50",
") c #499247",
"! c #356A35",
" . ",
" . ",
" . +@#$ ",
" . %&*= ",
" .. #-;> ,, ,,,",
" . $')! ",
" . ",
" . ",
" . ",
" . +@#$ ",
" . %&*= ",
" .. #-;> ,, ,,,",
" $')! ",
" ",
" ",
" "};
OVersatileView::OVersatileView( QWidget* parent, const char* name, int mode )
:QWidgetStack( parent, name ),
_viewmode( mode ), _warningpolicy( None ),
_treeleaf(), _treeopened(), _treeclosed(),
_iconleaf(), _iconopened(), _iconclosed()
{
//
// Create child widgets and set some reasonable default styles
//
_listview = new OListView( this, "oversatileview embedded listview" );
_iconview = new QIconView( this, "oversatileview embedded iconview" );
_listview->setAllColumnsShowFocus( true );
_listview->setRootIsDecorated( true );
_listview->setShowSortIndicator( true );
_iconview->setGridX( 90 );
_iconview->setGridY( 42 );
_iconview->setAutoArrange( true );
-
+
#ifdef QWS // TODO: Let this depend on current geometry (rotation)
_iconview->setArrangement( QIconView::TopToBottom );
#else
_iconview->setArrangement( QIconView::LeftToRight );
#endif
-
+
_iconview->setResizeMode( QIconView::Adjust );
-
+
// qt-embedded: map stylus right on hold to right button press
#ifdef QWS
( (QPEApplication*) qApp)->setStylusOperation( _iconview->viewport(), QPEApplication::RightOnHold );
( (QPEApplication*) qApp)->setStylusOperation( _listview->viewport(), QPEApplication::RightOnHold );
#endif
setViewMode( mode ); // TODO: Read last style from config
// setSynchronization( true ); // TODO: Implement this
// create context menu allowing to switch between the views
_contextmenu = new QPopupMenu( 0, "oversatileview contextmenu" );
_contextmenu->setCaption( "Style" );
_contextmenu->setCheckable( true );
QActionGroup* ag = new QActionGroup( _contextmenu, "style option group" );
QAction* a1 = new QAction( "View Items in Icon Style", QIconSet( QPixmap( view_icon_xpm ) ),
"View Icons", 0, ag, "viewicon action", true );
QAction* a2 = new QAction( "View Items in Tree Style", QIconSet( QPixmap( view_tree_xpm ) ),
"View Tree", 0, ag, "viewtree action", true );
ag->addTo( _contextmenu );
if ( mode == Icons )
a1->setOn( true );
else if ( mode == Tree )
a2->setOn( true );
connect( a1, SIGNAL( activated() ), this, SLOT( setIconViewMode() ) );
connect( a2, SIGNAL( activated() ), this, SLOT( setTreeViewMode() ) );
-
+
#if (QT_VERSION >= 0x030000)
connect( _listview, SIGNAL( contextMenuRequested(QListViewItem*,const QPoint&,int) ), this, SLOT( contextMenuRequested(QListViewItem*,const QPoint&,int) ) );
connect( _iconview, SIGNAL( contextMenuRequested(QIconViewItem*,const QPoint&) ), this, SLOT( contextMenuRequested(QIconViewItem*,const QPoint&) ) );
#else
connect( _listview, SIGNAL( rightButtonPressed(QListViewItem*,const QPoint&,int) ), this, SLOT( contextMenuRequested(QListViewItem*,const QPoint&,int) ) );
connect( _iconview, SIGNAL( rightButtonPressed(QIconViewItem*,const QPoint&) ), this, SLOT( contextMenuRequested(QIconViewItem*,const QPoint&) ) );
#endif
-
+
//
// signal forwarders
//
// unfortunately we can't short-circuit all the QListView and QIconView signals
// to OVersatileView signals, because the signal/slot mechanism doesn't allow
// type-conversion :-(
// common signals for listview
-
+
connect( _listview, SIGNAL( selectionChanged() ), this, SIGNAL( selectionChanged() ) );
connect( _listview, SIGNAL( selectionChanged(QListViewItem*) ), this, SLOT( selectionChanged(QListViewItem*) ) );
- connect( _listview, SIGNAL( currentChanged(QListViewItem*) ), this, SLOT( currentChanged(QListViewItem*) ) );
+ connect( _listview, SIGNAL( currentChanged(QListViewItem*) ), this, SLOT( currentChanged(QListViewItem*) ) );
connect( _listview, SIGNAL( clicked(QListViewItem*) ), this, SLOT( clicked(QListViewItem*) ) );
connect( _listview, SIGNAL( pressed(QListViewItem*) ), this, SLOT( pressed(QListViewItem*) ) );
-
+
connect( _listview, SIGNAL( doubleClicked(QListViewItem*) ), this, SLOT( doubleClicked(QListViewItem*) ) );
connect( _listview, SIGNAL( returnPressed(QListViewItem*) ), this, SLOT( returnPressed(QListViewItem*) ) );
-
+
connect( _listview, SIGNAL( onItem(QListViewItem*) ), this, SLOT( onItem(QListViewItem*) ) );
connect( _listview, SIGNAL( onViewport() ), this, SIGNAL( onViewport() ) );
// common signals for iconview
-
+
connect( _iconview, SIGNAL( selectionChanged() ), this, SIGNAL( selectionChanged() ) );
connect( _iconview, SIGNAL( selectionChanged(QIconViewItem*) ), this, SLOT( selectionChanged(QIconViewItem*) ) );
- connect( _iconview, SIGNAL( currentChanged(QIconViewItem*) ), this, SLOT( currentChanged(QIconViewItem*) ) );
+ connect( _iconview, SIGNAL( currentChanged(QIconViewItem*) ), this, SLOT( currentChanged(QIconViewItem*) ) );
connect( _iconview, SIGNAL( clicked(QIconViewItem*) ), this, SLOT( clicked(QIconViewItem*) ) );
connect( _iconview, SIGNAL( pressed(QIconViewItem*) ), this, SLOT( pressed(QIconViewItem*) ) );
-
+
connect( _iconview, SIGNAL( doubleClicked(QIconViewItem*) ), this, SLOT( doubleClicked(QIconViewItem*) ) );
connect( _iconview, SIGNAL( returnPressed(QIconViewItem*) ), this, SLOT( returnPressed(QIconViewItem*) ) );
-
+
connect( _iconview, SIGNAL( onItem(QIconViewItem*) ), this, SLOT( onItem(QIconViewItem*) ) );
connect( _iconview, SIGNAL( onViewport() ), this, SIGNAL( onViewport() ) );
-
+
// listview only signals
-
+
connect( _listview, SIGNAL( expanded(QListViewItem*) ), this, SLOT( expanded(QListViewItem*) ) );
connect( _listview, SIGNAL( collapsed(QListViewItem*) ), this, SLOT( collapsed(QListViewItem*) ) );
-
+
// iconview only signals
-
+
connect( _iconview, SIGNAL( moved() ), this, SIGNAL( moved() ) );
}
OVersatileView::~OVersatileView()
{
}
QPopupMenu* OVersatileView::contextMenu() const
{
return _contextmenu;
}
void OVersatileView::contextMenuRequested( QListViewItem* item, const QPoint& pos, int col )
{
// can't use QObject::inherits here, because ListViewItems, beit Q, O or K,
// do not inherit from QObject - assuming here the programmer is
// disciplined enough to only add OVersatileViewItems to an OVersatileView
popupContextMenu( static_cast<OVersatileViewItem*>( item ), pos, col );
}
void OVersatileView::contextMenuRequested( QIconViewItem* item, const QPoint& pos )
{
// see above
popupContextMenu( static_cast<OVersatileViewItem*>( item ), pos, -1 );
}
void OVersatileView::popupContextMenu( OVersatileViewItem* item, const QPoint& pos, int col )
{
if ( !item )
_contextmenu->exec( pos );
else
emit( contextMenuRequested( item, pos, col ) );
}
void OVersatileView::setSynchronization( bool sync )
{
_synchronization = sync;
}
bool OVersatileView::synchronization()
{
return _synchronization;
}
void OVersatileView::setDefaultPixmaps( int mode, QPixmap& leaf, QPixmap& opened, QPixmap& closed )
{
if ( mode == Tree )
{
_treeleaf = leaf;
_treeopened = opened;
_treeclosed = closed;
}
else if ( mode == Icons )
{
_iconleaf = leaf;
_iconopened = opened;
_iconclosed = closed;
}
else
{
odebug << "OVersatileView::setDefaultPixmaps(): invalid mode" << oendl;
}
}
QIconView* OVersatileView::iconView() const
{
return _iconview;
}
OListView* OVersatileView::listView() const
{
return _listview;
}
void OVersatileView::setViewMode( int mode )
{
if ( mode == Tree )
{
_viewmode = mode;
raiseWidget( _listview );
}
else if ( mode == Icons )
{
_viewmode = mode;
raiseWidget( _iconview );
}
else
{
odebug << "OVersatileView::setViewMode(): invalid mode" << oendl;
}
}
void OVersatileView::setIconViewMode()
{
setViewMode( Icons );
}
@@ -327,226 +330,226 @@ bool OVersatileView::isValidViewMode( int mode ) const
{
case OVersatileView::None:
{
return true;
}
case OVersatileView::Warn:
{
if ( _viewmode != mode )
{
odebug << "OVersatileView::isValidViewMode(): Requested operation not valid in current mode." << oendl;
return true;
}
}
case OVersatileView::WarnReturn:
{
if ( _viewmode != mode )
{
odebug << "OVersatileView::isValidViewMode(): Requested operation not valid in current mode." << oendl;
return false;
}
}
default:
{
owarn << "OVersatileView::isValidViewMode(): Inconsistent object state!" << oendl;
return true;
}
}
}
void OVersatileView::setWarningPolicy( int policy ) const
{
_warningpolicy = policy;
}
bool OVersatileView::warningPolicy() const
{
return _warningpolicy;
}
//==============================================================================================//
// Stupid Signal forwarders...
// Folks, this is why I like python with its dynamic typing:
// I can code the following dozens of lines C++ in four Python lines...
//==============================================================================================//
void OVersatileView::selectionChanged( QListViewItem * item )
{
emit( selectionChanged( static_cast<OVersatileViewItem*>( item ) ) );
}
void OVersatileView::selectionChanged( QIconViewItem * item )
{
emit( selectionChanged( static_cast<OVersatileViewItem*>( item ) ) );
}
void OVersatileView::currentChanged( QListViewItem * item )
{
emit( currentChanged( static_cast<OVersatileViewItem*>( item ) ) );
}
void OVersatileView::currentChanged( QIconViewItem * item )
{
emit( currentChanged( static_cast<OVersatileViewItem*>( item ) ) );
}
void OVersatileView::clicked( QListViewItem * item )
{
emit( clicked( static_cast<OVersatileViewItem*>( item ) ) );
}
void OVersatileView::clicked( QIconViewItem * item )
{
emit( clicked( static_cast<OVersatileViewItem*>( item ) ) );
}
void OVersatileView::pressed( QListViewItem * item )
{
emit( pressed( static_cast<OVersatileViewItem*>( item ) ) );
}
void OVersatileView::pressed( QIconViewItem * item )
{
emit( pressed( static_cast<OVersatileViewItem*>( item ) ) );
}
void OVersatileView::doubleClicked( QListViewItem * item )
{
emit( doubleClicked( static_cast<OVersatileViewItem*>( item ) ) );
}
void OVersatileView::doubleClicked( QIconViewItem * item )
{
emit( doubleClicked( static_cast<OVersatileViewItem*>( item ) ) );
}
void OVersatileView::returnPressed( QListViewItem * item )
{
emit( returnPressed( static_cast<OVersatileViewItem*>( item ) ) );
}
-
+
void OVersatileView::returnPressed( QIconViewItem * item )
{
emit( returnPressed( static_cast<OVersatileViewItem*>( item ) ) );
}
void OVersatileView::onItem( QListViewItem * item )
{
emit( onItem( static_cast<OVersatileViewItem*>( item ) ) );
}
void OVersatileView::onItem( QIconViewItem * item )
{
emit( onItem( static_cast<OVersatileViewItem*>( item ) ) );
}
void OVersatileView::expanded( QListViewItem *item ) // QListView
{
//odebug << "OVersatileView::expanded(): opening tree..." << oendl;
if ( !_treeopened.isNull() )
item->setPixmap( 0, _treeopened );
emit( expanded( static_cast<OVersatileViewItem*>( item ) ) );
}
void OVersatileView::collapsed( QListViewItem *item ) // QListView
{
if ( !_treeclosed.isNull() )
item->setPixmap( 0, _treeclosed );
emit( collapsed( static_cast<OVersatileViewItem*>( item ) ) );
}
//=============================================================================================//
// OVersatileView Case I - API only existing in QListView or QIconView but not in both!
//==============================================================================================//
-
+
int OVersatileView::treeStepSize() const // QListView
{
if ( !isValidViewMode( Tree ) )
{
return -1;
}
return _listview->treeStepSize();
}
void OVersatileView::setTreeStepSize( int size ) // QListView
{
if ( !isValidViewMode( Tree ) )
{
return;
}
_listview->setTreeStepSize( size );
}
QHeader * OVersatileView::header() const // QListView
{
if ( !isValidViewMode( Tree ) )
{
return 0;
}
return _listview->header();
}
int OVersatileView::addColumn( const QString &label, int size ) // QListView
{
if ( !isValidViewMode( Tree ) )
{
return -1;
}
return _listview->addColumn( label, size );
}
int OVersatileView::addColumn( const QIconSet& iconset, const QString &label, int size ) // QListView
{
if ( !isValidViewMode( Tree ) )
{
return -1;
}
return _listview->addColumn( iconset, label, size );
}
void OVersatileView::removeColumn( int index ) // QListView
{
if ( !isValidViewMode( Tree ) )
{
return;
}
_listview->removeColumn( index );
}
void OVersatileView::setColumnText( int column, const QString &label ) // QListView
{
if ( !isValidViewMode( Tree ) )
{
return;
}
_listview->setColumnText( column, label );
}
void OVersatileView::setColumnText( int column, const QIconSet& iconset, const QString &label ) // QListView
{
if ( !isValidViewMode( Tree ) )
{
return;
}
_listview->setColumnText( column, iconset, label );
}
QString OVersatileView::columnText( int column ) const // QListView
{
if ( !isValidViewMode( Tree ) )
{
return QString::null;
}
return _listview->columnText( column );
}
void OVersatileView::setColumnWidth( int column, int width ) // QListView
{
if ( !isValidViewMode( Tree ) )
{
return;
}
_listview->setColumnWidth( column, width );
}
int OVersatileView::columnWidth( int column ) const // QListView
{
if ( !isValidViewMode( Tree ) )
{
return -1;
}
return _listview->columnWidth( column );
}
void OVersatileView::setColumnWidthMode( int column, WidthMode mode ) // QListView
{
if ( !isValidViewMode( Tree ) )
{
@@ -652,193 +655,193 @@ OVersatileViewItem * OVersatileView::firstChild() const // QListView
{
if ( !isValidViewMode( Tree ) )
{
return 0;
}
return static_cast<OVersatileViewItem*>( _listview->firstChild() );
}
int OVersatileView::childCount() const // QListView
{
if ( !isValidViewMode( Tree ) )
{
return -1;
}
return _listview->childCount();
}
void OVersatileView::setAllColumnsShowFocus( bool focus ) // QListView
{
if ( !isValidViewMode( Tree ) )
{
return;
}
_listview->setAllColumnsShowFocus( focus );
}
bool OVersatileView::allColumnsShowFocus() const // QListView
{
if ( !isValidViewMode( Tree ) )
{
return false;
}
return _listview->allColumnsShowFocus();
}
void OVersatileView::setItemMargin( int margin ) // QListView
{
if ( !isValidViewMode( Tree ) )
{
return;
}
_listview->setItemMargin( margin );
}
int OVersatileView::itemMargin() const // QListView
{
if ( !isValidViewMode( Tree ) )
{
return -1;
}
return _listview->itemMargin();
}
void OVersatileView::setRootIsDecorated( bool decorate ) // QListView
{
if ( !isValidViewMode( Tree ) )
{
return;
}
_listview->setRootIsDecorated( decorate );
}
bool OVersatileView::rootIsDecorated() const // QListView
{
if ( !isValidViewMode( Tree ) )
{
return false;
}
return _listview->rootIsDecorated();
}
void OVersatileView::setShowSortIndicator( bool show ) // QListView
{
if ( !isValidViewMode( Tree ) )
{
return;
}
_listview->setShowSortIndicator( show );
}
bool OVersatileView::showSortIndicator() const // QListView
{
if ( !isValidViewMode( Tree ) )
{
return false;
}
return _listview->showSortIndicator();
}
void OVersatileView::triggerUpdate() // QListView
{
if ( !isValidViewMode( Tree ) )
{
return;
}
_listview->triggerUpdate();
}
//
// only in QIconView
//
-
+
uint OVersatileView::count() const // QIconView
{
if ( !isValidViewMode( Icons ) )
{
return 0;
}
return _iconview->count();
}
int OVersatileView::index( const OVersatileViewItem *item ) const // QIconView
{
if ( !isValidViewMode( Icons ) )
{
return -1;
}
return _iconview->index( item );
}
OVersatileViewItem* OVersatileView::firstItem() const // QIconView
{
if ( !isValidViewMode( Icons ) )
{
return 0;
}
return static_cast<OVersatileViewItem*>( _iconview->firstItem() );
}
OVersatileViewItem* OVersatileView::lastItem() const // QIconView
{
if ( !isValidViewMode( Icons ) )
{
return 0;
}
return static_cast<OVersatileViewItem*>( _iconview->lastItem() );
}
OVersatileViewItem* OVersatileView::findItem( const QPoint &pos ) const // QIconView
{
if ( !isValidViewMode( Icons ) )
{
return 0;
}
return static_cast<OVersatileViewItem*>( _iconview->findItem( pos ) );
}
OVersatileViewItem* OVersatileView::findItem( const QString &text ) const // QIconView
{
if ( !isValidViewMode( Icons ) )
{
return 0;
}
return static_cast<OVersatileViewItem*>( _iconview->findItem( text ) );
}
OVersatileViewItem* OVersatileView::findFirstVisibleItem( const QRect &r ) const // QIconView
{
if ( !isValidViewMode( Icons ) )
{
return 0;
}
return static_cast<OVersatileViewItem*>( _iconview->findFirstVisibleItem( r ) );
}
OVersatileViewItem* OVersatileView::findLastVisibleItem( const QRect &r ) const // QIconView
{
if ( !isValidViewMode( Icons ) )
{
return 0;
}
return static_cast<OVersatileViewItem*>( _iconview->findLastVisibleItem( r ) );
}
void OVersatileView::setGridX( int rx ) // QIconView
{
if ( !isValidViewMode( Icons ) )
{
return;
}
_iconview->setGridX( rx );
}
void OVersatileView::setGridY( int ry ) // QIconView
{
if ( !isValidViewMode( Icons ) )
{
return;
}
_iconview->setGridY( ry );
}
int OVersatileView::gridX() const // QIconView
{
if ( !isValidViewMode( Icons ) )
{
return -1;
}
return _iconview->gridX();
}
int OVersatileView::gridY() const // QIconView
{
if ( !isValidViewMode( Icons ) )
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 @@
/*
                This file is part of the Opie Project
=. (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
.=l.
           .>+-=
 _;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef OVERSATILEVIEW_H
#define OVERSATILEVIEW_H
/* QT */
#include <qwidgetstack.h>
#include <qiconview.h>
/* OPIE */
#include <opie2/oapplication.h>
/* FORWARDS */
class QHeader;
class QIconSet;
class QIconViewItem;
-class OListView;
class QListViewItem;
class QPopupMenu;
class QString;
#ifndef QT_NO_DRAGANDDROP
class QIconDragItem;
#endif
+namespace Opie {
+namespace Ui {
+class OListView;
+
class OVersatileView : public QWidgetStack
{
Q_OBJECT
-
+
friend class OVersatileViewItem;
//==============================================================================================//
// OVersatileView High Level API
//==============================================================================================//
public:
OVersatileView( QWidget* parent = 0, const char* name = 0, int mode = 0 );
~OVersatileView();
QPopupMenu* contextMenu() const;
-
+
void setSynchronization( bool sync );
bool synchronization();
-
+
enum ViewMode { Tree = 0, Icons };
int viewMode();
-
+
QIconView* iconView() const;
OListView* listView() const;
-
+
enum WarningPolicy { None = 0, Warn, WarnReturn };
-
+
void setWarningPolicy( int ) const; // warn, if calling a method which doesn't apply to the current viewmode
bool warningPolicy() const;
-
+
void setDefaultPixmaps( int mode, QPixmap& leaf, QPixmap& opened, QPixmap& closed );
-
+
public slots:
void setViewMode( int mode );
void setIconViewMode();
void setTreeViewMode();
protected:
virtual bool isValidViewMode( int mode ) const;
virtual void popupContextMenu( OVersatileViewItem* item, const QPoint& pos, int col = 0 );
-
+
private:
int _viewmode;
bool _synchronization;
mutable int _warningpolicy;
-
+
OListView* _listview;
QIconView* _iconview;
-
+
QPixmap _treeleaf;
QPixmap _treeopened;
QPixmap _treeclosed;
QPixmap _iconleaf;
QPixmap _iconopened;
QPixmap _iconclosed;
-
+
QPopupMenu* _contextmenu;
-
+
int _iconstyle;
int _treestyle;
-
+
private slots:
-
+
void contextMenuRequested( QListViewItem*, const QPoint&, int );
void contextMenuRequested( QIconViewItem*, const QPoint& );
// type converting signal forwarders
-
+
void selectionChanged( QListViewItem * );
void currentChanged( QListViewItem * );
void clicked( QListViewItem * );
void pressed( QListViewItem * );
void doubleClicked( QListViewItem * );
void returnPressed( QListViewItem * );
void onItem( QListViewItem * );
-
+
void selectionChanged( QIconViewItem * );
void currentChanged( QIconViewItem * );
void clicked( QIconViewItem * );
void pressed( QIconViewItem * );
void doubleClicked( QIconViewItem * );
void returnPressed( QIconViewItem * );
void onItem( QIconViewItem * );
-
+
void expanded( QListViewItem * item ); // QListView
void collapsed( QListViewItem * item ); // QListView
signals:
-
+
void contextMenuRequested( OVersatileViewItem * item, const QPoint& pos, int col );
-
+
/*#ifndef QT_NO_DRAGANDDROP
void dropped( QDropEvent *e, const QValueList<QIconDragItem> &lst ); // QIconView
#endif
void itemRenamed( OVersatileViewItem *item, const QString & ); // QIconView
void itemRenamed( OVersatileViewItem *item ); // QIconView
*/
//==============================================================================================//
// "Derived" API - Case 1: Methods existing either only in QListView or only in QIconView
//==============================================================================================//
public:
/*
enum Arrangement { // QIconView
LeftToRight = 0,
TopToBottom
};
enum ResizeMode { // QIconView
Fixed = 0,
Adjust
};
enum ItemTextPos { // QIconView
Bottom = 0,
Right
};
*/
-
+
//
// only in QListView
//
-
+
int treeStepSize() const; // QListView
virtual void setTreeStepSize( int ); // QListView
QHeader * header() const; // QListView
virtual int addColumn( const QString &label, int size = -1); // QListView
virtual int addColumn( const QIconSet& iconset, const QString &label, int size = -1); // QListView
void removeColumn( int index ); // #### make virtual in next major release! // QListView
virtual void setColumnText( int column, const QString &label ); // QListView
virtual void setColumnText( int column, const QIconSet& iconset, const QString &label ); // QListView
QString columnText( int column ) const; // QListView
virtual void setColumnWidth( int column, int width ); // QListView
int columnWidth( int column ) const; // QListView
enum WidthMode { Manual, Maximum }; // QListView
virtual void setColumnWidthMode( int column, WidthMode ); // QListView
WidthMode columnWidthMode( int column ) const; // QListView
int columns() const; // QListView
virtual void setColumnAlignment( int, int ); // QListView
int columnAlignment( int ) const; // QListView
OVersatileViewItem * itemAt( const QPoint & screenPos ) const; // QListView
QRect itemRect( const OVersatileViewItem * ) const; // QListView
int itemPos( const OVersatileViewItem * ); // QListView
bool isSelected( const OVersatileViewItem * ) const; // QListView // also in QIconViewItem but not in QIconView *shrug*
virtual void setMultiSelection( bool enable ); // QListView
bool isMultiSelection() const; // QListView
OVersatileViewItem * selectedItem() const; // QListView
virtual void setOpen( OVersatileViewItem *, bool ); // QListView
bool isOpen( const OVersatileViewItem * ) const; // QListView
OVersatileViewItem * firstChild() const; // QListView
int childCount() const; // QListView
virtual void setAllColumnsShowFocus( bool ); // QListView
bool allColumnsShowFocus() const; // QListView
virtual void setItemMargin( int ); // QListView
int itemMargin() const; // QListView
virtual void setRootIsDecorated( bool ); // QListView
bool rootIsDecorated() const; // QListView
void setShowSortIndicator( bool show ); // QListView
bool showSortIndicator() const; // QListView
-
+
int index( const OVersatileViewItem *item ) const; // QIconView
public slots:
void triggerUpdate(); // QListView
signals:
void expanded( OVersatileViewItem *item ); // QListView
void collapsed( OVersatileViewItem *item ); // QListView
//
// only in QIconView
//
- public:
+ public:
uint count() const; // QIconView
-
+
OVersatileViewItem *firstItem() const; // QIconView
OVersatileViewItem *lastItem() const; // QIconView
OVersatileViewItem *findItem( const QPoint &pos ) const; // QIconView
OVersatileViewItem *findItem( const QString &text ) const; // QIconView
OVersatileViewItem* findFirstVisibleItem( const QRect &r ) const; // QIconView
OVersatileViewItem* findLastVisibleItem( const QRect &r ) const; // QIconView
virtual void setGridX( int rx ); // QIconView
virtual void setGridY( int ry ); // QIconView
int gridX() const; // QIconView
int gridY() const; // QIconView
virtual void setSpacing( int sp ); // QIconView
int spacing() const; // QIconView
virtual void setItemTextPos( QIconView::ItemTextPos pos ); // QIconView
QIconView::ItemTextPos itemTextPos() const; // QIconView
virtual void setItemTextBackground( const QBrush &b ); // QIconView
QBrush itemTextBackground() const; // QIconView
virtual void setArrangement( QIconView::Arrangement am ); // QIconView
QIconView::Arrangement arrangement() const; // QIconView
virtual void setResizeMode( QIconView::ResizeMode am ); // QIconView
QIconView::ResizeMode resizeMode() const; // QIconView
virtual void setMaxItemWidth( int w ); // QIconView
int maxItemWidth() const; // QIconView
virtual void setMaxItemTextLength( int w ); // QIconView
int maxItemTextLength() const; // QIconView
virtual void setAutoArrange( bool b ); // QIconView
bool autoArrange() const; // QIconView
virtual void setShowToolTips( bool b ); // QIconView
bool showToolTips() const; // QIconView
bool sorting() const; // QIconView
bool sortDirection() const; // QIconView
virtual void setItemsMovable( bool b ); // QIconView
bool itemsMovable() const; // QIconView
virtual void setWordWrapIconText( bool b ); // QIconView
bool wordWrapIconText() const; // QIconView
public slots:
virtual void arrangeItemsInGrid( const QSize &grid, bool update = TRUE ); // QIconView
virtual void arrangeItemsInGrid( bool update = TRUE ); // QIconView
virtual void updateContents(); // QIconView
-
+
signals:
/*#ifndef QT_NO_DRAGANDDROP
void dropped( QDropEvent *e, const QValueList<QIconDragItem> &lst ); // QIconView
#endif
*/
void moved(); // QIconView
void itemRenamed( OVersatileViewItem *item, const QString & ); // QIconView
void itemRenamed( OVersatileViewItem *item ); // QIconView
//==============================================================================================//
// "Derived" API - Case 2: Methods existing in QListView and QIconView with the same signatures
//==============================================================================================//
public:
enum SelectionMode {
Single = 0,
Multi,
Extended,
NoSelection
};
virtual void clear();
virtual void setFont( const QFont & );
virtual void setPalette( const QPalette & );
virtual void takeItem( OVersatileViewItem * );
void setSelectionMode( SelectionMode mode );
SelectionMode selectionMode() const;
virtual void selectAll( bool select );
virtual void clearSelection();
virtual void invertSelection();
-
+
void ensureItemVisible( const OVersatileViewItem * );
virtual void repaintItem( const OVersatileViewItem * ) const;
virtual void setCurrentItem( OVersatileViewItem * );
OVersatileViewItem * currentItem() const;
// bool eventFilter( QObject * o, QEvent * ); // use QWidgetStack implementation
// QSize minimumSizeHint() const; // use QWidgetStack implementation
// QSizePolicy sizePolicy() const; // use QWidgetStack implementation
// QSize sizeHint() const; // use QWidgetStack implementation
signals:
void selectionChanged();
void selectionChanged( OVersatileViewItem * );
void currentChanged( OVersatileViewItem * );
void clicked( OVersatileViewItem * );
void pressed( OVersatileViewItem * );
void doubleClicked( OVersatileViewItem * );
void returnPressed( OVersatileViewItem * );
-
+
void onItem( OVersatileViewItem * );
void onViewport();
-
+
//==============================================================================================//
// "Derived" API - Case 2: Methods existing in QListView and QIconView with differing signatures
//==============================================================================================//
-
+
/*
-
+
public:
virtual void insertItem( OVersatileViewItem * ); // QListView
virtual void insertItem( OVersatileViewItem *item, OVersatileViewItem *after = 0L ); // QIconView
virtual void setSelected( OVersatileViewItem *, bool ); // QListView
virtual void setSelected( OVersatileViewItem *item, bool s, bool cb = FALSE ); // QIconView
virtual void setSorting( int column, bool increasing = TRUE ); // QListView
void setSorting( bool sort, bool ascending = TRUE ); // QIconView
void sort(); // #### make virtual in next major release // QListView
virtual void sort( bool ascending = TRUE ); // QIconView
*/
-
+
signals:
void clicked( OVersatileViewItem *, const QPoint &, int ); // QListView
void clicked( OVersatileViewItem *, const QPoint & ); // QIconView
-
+
void pressed( OVersatileViewItem *, const QPoint &, int ); // QListView
void pressed( OVersatileViewItem *, const QPoint & ); // QIconView
-
+
void rightButtonClicked( OVersatileViewItem* item, const QPoint& pos ); // QIconView
void rightButtonClicked( OVersatileViewItem *, const QPoint&, int ); // QListView
-
- void rightButtonPressed( OVersatileViewItem* item, const QPoint& pos ); // QIconView
+
+ void rightButtonPressed( OVersatileViewItem* item, const QPoint& pos ); // QIconView
void rightButtonPressed( OVersatileViewItem *, const QPoint&, int ); // QListView
-
+
void mouseButtonPressed( int, OVersatileViewItem *, const QPoint& , int ); // QListView
void mouseButtonPressed( int button, OVersatileViewItem* item, const QPoint& pos ); // QIconView
-
+
void mouseButtonClicked( int, OVersatileViewItem *, const QPoint&, int ); // QListView
void mouseButtonClicked( int button, OVersatileViewItem* item, const QPoint& pos ); // QIconView
};
+}
+}
#endif
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,129 +1,131 @@
/*
                This file is part of the Opie Project
=. (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
.=l.
           .>+-=
 _;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include <opie2/oversatileviewitem.h>
#include <opie2/oversatileview.h>
+using namespace Opie::Ui;
+
OVersatileViewItem::OVersatileViewItem( OVersatileView * parent )
:OListViewItem( parent->_listview ), QIconViewItem( parent->_iconview ),
_versatileview( parent )
{
init();
}
OVersatileViewItem::OVersatileViewItem( OVersatileView * parent, OVersatileViewItem * after )
:OListViewItem( parent->_listview, after ), QIconViewItem( parent->_iconview, after ),
_versatileview( parent )
{
init();
}
OVersatileViewItem::OVersatileViewItem( OVersatileView * parent,
QString a, QString b, QString c, QString d,
QString e, QString f, QString g, QString h )
:OListViewItem( parent->_listview, a, b, c, d, e, f, g, h ),
QIconViewItem( parent->_iconview, a ),
_versatileview( parent )
{
init();
}
OVersatileViewItem::OVersatileViewItem( OVersatileView * parent, OVersatileViewItem* after,
QString a, QString b, QString c, QString d,
QString e, QString f, QString g, QString h )
:OListViewItem( parent->_listview, after, a, b, c, d, e, f, g, h ),
QIconViewItem( parent->_iconview, after, a ),
_versatileview( parent )
{
init();
}
OVersatileViewItem::OVersatileViewItem( OVersatileViewItem * parent,
QString a, QString b, QString c, QString d,
QString e, QString f, QString g, QString h )
:OListViewItem( parent, a, b, c, d, e, f, g, h ),
QIconViewItem( parent->_versatileview->_iconview, a ),
_versatileview( parent->_versatileview )
{
init();
}
OVersatileViewItem::OVersatileViewItem( OVersatileViewItem * parent, OVersatileViewItem* after,
QString a, QString b, QString c, QString d,
QString e, QString f, QString g, QString h )
:OListViewItem( parent, after, a, b, c, d, e, f, g, h ),
QIconViewItem( parent->_versatileview->_iconview, after, a ),
_versatileview( parent->_versatileview )
{
init();
}
OVersatileViewItem::~OVersatileViewItem()
{
}
OVersatileView* OVersatileViewItem::versatileView() const
{
return _versatileview;
}
void OVersatileViewItem::init()
{
if ( !firstChild() )
{
// I'm a sweet yellow and browne autumn leaf
OListViewItem::setPixmap( 0, _versatileview->_treeleaf );
QIconViewItem::setPixmap( _versatileview->_iconleaf );
}
else
{
// I'm a node and I have a little baby child
if ( isOpen() )
{
OListViewItem::setPixmap( 0, _versatileview->_treeopened );
QIconViewItem::setPixmap( _versatileview->_iconopened );
}
else
{
OListViewItem::setPixmap( 0, _versatileview->_treeclosed );
QIconViewItem::setPixmap( _versatileview->_iconclosed );
}
}
}
void OVersatileViewItem::setRenameEnabled( bool allow )
{
#if (QT_VERSION >= 0x030000)
OListViewItem::setRenameEnabled( 0, allow ); // TODO: Backport to Qt-Embedded 2.x?
#endif
QIconViewItem::setRenameEnabled( allow );
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 @@
/*
                This file is part of the Opie Project
              Copyright (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
=.
.=l.
           .>+-=
 _;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef OVERSATILEVIEWITEM_H
#define OVERSATILEVIEWITEM_H
/* QT */
#include <qiconview.h>
/* OPIE */
#include <opie2/olistview.h>
+namespace Opie {
+namespace Ui {
+
class OVersatileView;
class OVersatileViewItem : public OListViewItem, public QIconViewItem
{
public:
OVersatileViewItem( OVersatileView * parent );
OVersatileViewItem( OVersatileView * parent, OVersatileViewItem * after );
OVersatileViewItem( OVersatileViewItem * parent, OVersatileViewItem * after );
OVersatileViewItem( OVersatileView * parent, QString,
QString = QString::null, QString = QString::null,
QString = QString::null, QString = QString::null,
QString = QString::null, QString = QString::null,
QString = QString::null );
OVersatileViewItem( OVersatileViewItem * parent, QString,
QString = QString::null, QString = QString::null,
QString = QString::null, QString = QString::null,
QString = QString::null, QString = QString::null,
QString = QString::null );
OVersatileViewItem( OVersatileView * parent, OVersatileViewItem * after, QString,
QString = QString::null, QString = QString::null,
QString = QString::null, QString = QString::null,
QString = QString::null, QString = QString::null,
QString = QString::null );
OVersatileViewItem( OVersatileViewItem * parent, OVersatileViewItem * after, QString,
QString = QString::null, QString = QString::null,
QString = QString::null, QString = QString::null,
QString = QString::null, QString = QString::null,
QString = QString::null );
virtual ~OVersatileViewItem();
OVersatileView* versatileView() const;
// TODO: Implement the remaining constructors from QIconView
/* OIconViewItem( QIconView *parent, const QString &text, const QPixmap &icon );
OIconViewItem( QIconView *parent, QIconViewItem *after, const QString &text, const QPixmap &icon );
*/
virtual void setRenameEnabled( bool );
// TODO: Implement the remaining method multiplexers
private:
OVersatileView* _versatileview;
private:
void init();
};
+}
+}
#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,110 +1,112 @@
/*
                This file is part of the Opie Project
              Copyright (C) 2003 Maximilian Reiss <harlekin@handhelds.org>
=.
.=l.
           .>+-=
 _;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include "owait.h"
/* OPIE */
#include <qpe/qpeapplication.h>
#include <qpe/resource.h>
/* QT */
#include <qlayout.h>
#include <qpainter.h>
+using namespace Opie::Ui;
+
static int frame = 0;
/**
* This will construct a modal dialog.
*
* The default timer length is 10.
*
* @param parent The parent of the widget
* @param msg The name of the object
* @param dispIcon Display Icon?
*/
OWait::OWait( QWidget *parent, const char* msg, bool dispIcon )
:QDialog( parent, msg, TRUE, WStyle_Customize )
{
QHBoxLayout * hbox = new QHBoxLayout( this );
m_lb = new QLabel( this );
m_lb->setBackgroundMode ( NoBackground );
hbox->addWidget( m_lb );
hbox->activate();
m_pix = Resource::loadPixmap( "BigBusy" );
m_aniSize = m_pix.height();
resize( m_aniSize, m_aniSize );
m_timerLength = 10;
m_waitTimer = new QTimer( this );
connect( m_waitTimer, SIGNAL( timeout() ), this, SLOT( hide() ) );
}
void OWait::timerEvent( QTimerEvent * )
{
frame = ( ++frame ) % 4;
repaint();
}
void OWait::paintEvent( QPaintEvent * )
{
QPainter p( m_lb );
p.drawPixmap( 0, 0, m_pix, m_aniSize * frame, 0, m_aniSize, m_aniSize );
}
void OWait::show()
{
move( ( ( qApp->desktop() ->width() ) / 2 ) - ( m_aniSize / 2 ), ( ( qApp->desktop() ->height() ) / 2 ) - ( m_aniSize / 2 ) );
startTimer( 300 );
m_waitTimer->start( m_timerLength * 1000, true );
QDialog::show();
}
void OWait::hide()
{
killTimers();
m_waitTimer->stop();
frame = 0;
QDialog::hide();
}
void OWait::setTimerLength( int length )
{
m_timerLength = length;
}
OWait::~OWait()
{}
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 @@
/*
                This file is part of the Opie Project
              Copyright (C) 2003 Maximilian Reiss <harlekin@handhelds.org>
=.
.=l.
           .>+-=
 _;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef OWAIT_H
#define OWAIT_H
/* QT */
#include <qdialog.h>
#include <qlabel.h>
#include <qpixmap.h>
#include <qtimer.h>
+
+namespace Opie {
+namespace Ui {
/**
* This class displays a animated waiting icon in the middle of the screen.
*
* @short modal hour glass dialog
* @see QDialog
* @author Maximilian Reiß
*/
class OWait : public QDialog
{
Q_OBJECT
public:
OWait( QWidget *parent = 0, const char* name = 0, bool dispIcon = TRUE );
~OWait();
/**
* reimplemented for control reasons
*/
void show();
/**
* Set the time before the icon will be automaticly hidden
* The timer will be started once the widget will be shown.
* @param length - time in seconds
*/
void setTimerLength( int length );
public slots:
/**
* reimplemented for control reasons
*/
void hide();
private:
void timerEvent( QTimerEvent * );
void paintEvent( QPaintEvent * );
QPixmap m_pix;
QLabel *m_lb;
QTimer *m_waitTimer;
int m_timerLength;
int m_aniSize;
class Private;
Private *d;
};
-
+}
+}
#endif