From 11304d02942e9fa493e4e80943a828f9c65f6772 Mon Sep 17 00:00:00 2001 From: mickeyl Date: Fri, 28 Mar 2003 15:11:52 +0000 Subject: skeleton and the start of libopie2, please read README, ROADMAP and STATUS and comment... --- (limited to 'libopie2/examples') diff --git a/libopie2/examples/.cvsignore b/libopie2/examples/.cvsignore new file mode 100644 index 0000000..8f7300c --- a/dev/null +++ b/libopie2/examples/.cvsignore @@ -0,0 +1,6 @@ +Makefile* +moc* +*moc +*.o +~* + diff --git a/libopie2/examples/config.in b/libopie2/examples/config.in new file mode 100644 index 0000000..d18e479 --- a/dev/null +++ b/libopie2/examples/config.in @@ -0,0 +1,6 @@ + config LIBOPIE2EXAMPLES + boolean "libopie2 examples" + default "n" + depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && LIBOPIE2NET && LIBOPIE2UI && LIBOPIE2PIM && LIBOPIE2UI + comment "the examples need a libqpe, libopie2core, libopie2db, libopie2net, libopie2pim and libopie2ui" + depends !(( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && LIBOPIE2NET && LIBOPIE2UI && LIBOPIE2PIM && LIBOPIE2UI) diff --git a/libopie2/examples/examples.pro b/libopie2/examples/examples.pro new file mode 100644 index 0000000..2ae7eb7 --- a/dev/null +++ b/libopie2/examples/examples.pro @@ -0,0 +1,4 @@ +TEMPLATE = subdirs +unix:SUBDIRS = opieui opienet opiecore + +#include ( ../../../include.pro ) diff --git a/libopie2/examples/opiecore/.cvsignore b/libopie2/examples/opiecore/.cvsignore new file mode 100644 index 0000000..8f7300c --- a/dev/null +++ b/libopie2/examples/opiecore/.cvsignore @@ -0,0 +1,6 @@ +Makefile* +moc* +*moc +*.o +~* + diff --git a/libopie2/examples/opiecore/oconfigdemo/.cvsignore b/libopie2/examples/opiecore/oconfigdemo/.cvsignore new file mode 100644 index 0000000..8f7300c --- a/dev/null +++ b/libopie2/examples/opiecore/oconfigdemo/.cvsignore @@ -0,0 +1,6 @@ +Makefile* +moc* +*moc +*.o +~* + diff --git a/libopie2/examples/opiecore/oconfigdemo/oconfigdemo.cpp b/libopie2/examples/opiecore/oconfigdemo/oconfigdemo.cpp new file mode 100644 index 0000000..a3f8e10 --- a/dev/null +++ b/libopie2/examples/opiecore/oconfigdemo/oconfigdemo.cpp @@ -0,0 +1,31 @@ +#include +#include +#include + +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/oconfigdemo/oconfigdemo.pro b/libopie2/examples/opiecore/oconfigdemo/oconfigdemo.pro new file mode 100644 index 0000000..0109c57 --- a/dev/null +++ b/libopie2/examples/opiecore/oconfigdemo/oconfigdemo.pro @@ -0,0 +1,14 @@ +TEMPLATE = app +CONFIG = qt warn_on debug +HEADERS = +SOURCES = oconfigdemo.cpp + +INCLUDEPATH += $(OPIEDIR)/include +DEPENDPATH += $(OPIEDIR)/include +LIBS += -lopiecore2 +TARGET = oconfigdemo +MOC_DIR = moc +OBJECTS_DIR = obj + +include ( $(OPIEDIR)/include.pro ) + diff --git a/libopie2/examples/opiecore/odebugdemo/.cvsignore b/libopie2/examples/opiecore/odebugdemo/.cvsignore new file mode 100644 index 0000000..8f7300c --- a/dev/null +++ b/libopie2/examples/opiecore/odebugdemo/.cvsignore @@ -0,0 +1,6 @@ +Makefile* +moc* +*moc +*.o +~* + diff --git a/libopie2/examples/opiecore/odebugdemo/odebugdemo.cpp b/libopie2/examples/opiecore/odebugdemo/odebugdemo.cpp new file mode 100644 index 0000000..74886fa --- a/dev/null +++ b/libopie2/examples/opiecore/odebugdemo/odebugdemo.cpp @@ -0,0 +1,138 @@ +/* QT */ + +#include +#include +#include +#include +#include +#include +#include + +/* OPIE */ + +#include + +#include +#include +#include +#include + +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() ); + } + void updateDebugOutput() + { + OConfig* g = OGlobal::config(); + g->setGroup( "General" ); + g->writeEntry( "debugOutput"+QString::number(OGlobalSettings::debugMode()), e->text() ); + } + 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; + } + void emitFatalOutput() + { + ofatal << "This is a fatal message" << oendl; + } + void emitTBOutput() + { + ofatal << "This is a fatal message + backtrace\n" + odBacktrace(); // odBacktrace includes \n + } + +private: + QButtonGroup* g; + int m; + QLineEdit* e; +}; + +int main( int argc, char** argv ) +{ + DemoApp* app = new DemoApp( argc, argv ); + app->exec(); + + return 0; + +} + +#include "moc/odebugdemo.moc" diff --git a/libopie2/examples/opiecore/odebugdemo/odebugdemo.pro b/libopie2/examples/opiecore/odebugdemo/odebugdemo.pro new file mode 100644 index 0000000..a725105 --- a/dev/null +++ b/libopie2/examples/opiecore/odebugdemo/odebugdemo.pro @@ -0,0 +1,14 @@ +TEMPLATE = app +CONFIG = qt warn_on debug +HEADERS = +SOURCES = odebugdemo.cpp +INCLUDEPATH += $(OPIEDIR)/include +DEPENDPATH += $(OPIEDIR)/include +LIBS += -lopiecore2 +TARGET = odebugdemo +MOC_DIR = moc +OBJECTS_DIR = obj + +include ( $(OPIEDIR)/include.pro ) + + diff --git a/libopie2/examples/opiecore/oglobalsettingsdemo/.cvsignore b/libopie2/examples/opiecore/oglobalsettingsdemo/.cvsignore new file mode 100644 index 0000000..8f7300c --- a/dev/null +++ b/libopie2/examples/opiecore/oglobalsettingsdemo/.cvsignore @@ -0,0 +1,6 @@ +Makefile* +moc* +*moc +*.o +~* + diff --git a/libopie2/examples/opiecore/oglobalsettingsdemo/oglobalsettingsdemo.cpp b/libopie2/examples/opiecore/oglobalsettingsdemo/oglobalsettingsdemo.cpp new file mode 100644 index 0000000..2f5220b --- a/dev/null +++ b/libopie2/examples/opiecore/oglobalsettingsdemo/oglobalsettingsdemo.cpp @@ -0,0 +1,13 @@ +#include +#include + +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/oglobalsettingsdemo/oglobalsettingsdemo.pro b/libopie2/examples/opiecore/oglobalsettingsdemo/oglobalsettingsdemo.pro new file mode 100644 index 0000000..7fbecce --- a/dev/null +++ b/libopie2/examples/opiecore/oglobalsettingsdemo/oglobalsettingsdemo.pro @@ -0,0 +1,14 @@ +TEMPLATE = app +CONFIG = qt warn_on debug +HEADERS = +SOURCES = oglobalsettingsdemo.cpp +INCLUDEPATH += $(OPIEDIR)/include +DEPENDPATH += $(OPIEDIR)/include +LIBS += -lopiecore2 +TARGET = oglobalsettingsdemo +MOC_DIR = moc +OBJECTS_DIR = obj + +include ( $(OPIEDIR)/include.pro ) + + diff --git a/libopie2/examples/opiecore/opiecore.pro b/libopie2/examples/opiecore/opiecore.pro new file mode 100644 index 0000000..8f3aedc --- a/dev/null +++ b/libopie2/examples/opiecore/opiecore.pro @@ -0,0 +1,3 @@ +TEMPLATE = subdirs +unix:SUBDIRS = odebugdemo oconfigdemo oglobalsettingsdemo + diff --git a/libopie2/examples/opienet/.cvsignore b/libopie2/examples/opienet/.cvsignore new file mode 100644 index 0000000..8f7300c --- a/dev/null +++ b/libopie2/examples/opienet/.cvsignore @@ -0,0 +1,6 @@ +Makefile* +moc* +*moc +*.o +~* + diff --git a/libopie2/examples/opienet/miniwellenreiter/.cvsignore b/libopie2/examples/opienet/miniwellenreiter/.cvsignore new file mode 100644 index 0000000..8f7300c --- a/dev/null +++ b/libopie2/examples/opienet/miniwellenreiter/.cvsignore @@ -0,0 +1,6 @@ +Makefile* +moc* +*moc +*.o +~* + diff --git a/libopie2/examples/opienet/miniwellenreiter/miniwellenreiter.cpp b/libopie2/examples/opienet/miniwellenreiter/miniwellenreiter.cpp new file mode 100644 index 0000000..aec9cc7 --- a/dev/null +++ b/libopie2/examples/opienet/miniwellenreiter/miniwellenreiter.cpp @@ -0,0 +1,199 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +//======================== 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 stations; + +//======================== Application class =============================== + +class Wellenreiter : public QApplication +{ +Q_OBJECT +public: + Wellenreiter( int argc, char** argv ) : QApplication( argc, argv ) + { + + ONetwork* net = ONetwork::instance(); + + if ( argc < 3 ) + { + printf( "Usage: ./%s \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 (C) 2003 M-M-M *\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 down the interface - this enable more crash-proof + // scanning with drivers like spectrum_cs... + if ( wiface->isUp() ) + { + printf( "Interface status is up... switching to down... " ); + wiface->setUp( false ); + if ( wiface->isUp() ) + { + printf( "failed (%s). Exiting.\n", strerror( errno ) ); + exit( -1 ); + } + else + { + printf( "ok.\n" ); + } + } + else + printf( "Interface status is already down - good.\n" ); + + */ + + // 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 ); + else + { + printf( "Unknown driver. Exiting\n" ); + exit( -1 ); + } + + // enable monitoring mode + printf( "Enabling monitor mode...\n" ); + wiface->setMonitorMode( true ); + + // open a packet capturer + cap = new OPacketCapturer(); + cap->open( interface ); + if ( !cap->isOpen() ) + { + printf( "Unable to open libpcap (%s). Exiting.\n", strerror( errno ) ); + exit( -1 ); + } + + // set capturer to non-blocking mode + cap->setBlocking( false ); + + // start channel hopper + wiface->setChannelHopping( 1000 ); + + // connect + connect( cap, SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); + + } + + ~Wellenreiter() {}; + +public slots: + void receivePacket(OPacket* p) + { + if (!p) + { + printf( "(empty packet received)\n" ); + return; + } + + OWaveLanManagementPacket* beacon = (OWaveLanManagementPacket*) p->child( "802.11 Management" ); + + if ( beacon ) + { + if ( stations.find( beacon->SSID() ) ) + stations[beacon->SSID()]->beacons++; + else + { + printf( "found new network @ channel %d, SSID = '%s'\n", wiface->channel(), (const char*) beacon->SSID() ); + stations.insert( beacon->SSID(), new Station( "unknown", wiface->channel(), + ((OWaveLanPacket*) beacon->parent())->usesWep() ) ); + } + } + } +private: + OPacketCapturer* cap; + OWirelessNetworkInterface* wiface; +}; + + +int main( int argc, char** argv ) +{ + Wellenreiter w( argc, argv ); + w.exec(); + return 0; +} + +#include "miniwellenreiter.moc" + diff --git a/libopie2/examples/opienet/miniwellenreiter/miniwellenreiter.pro b/libopie2/examples/opienet/miniwellenreiter/miniwellenreiter.pro new file mode 100644 index 0000000..7ce535c --- a/dev/null +++ b/libopie2/examples/opienet/miniwellenreiter/miniwellenreiter.pro @@ -0,0 +1,13 @@ +TEMPLATE = app +CONFIG = qt warn_on debug +HEADERS = +SOURCES = miniwellenreiter.cpp +INCLUDEPATH += $(OPIEDIR)/include +DEPENDPATH += $(OPIEDIR)/include +LIBS += -lopiecore2 -lopienet2 +TARGET = miniwellenreiter +MOC_DIR = moc +OBJECTS_DIR = obj + +include ( $(OPIEDIR)/include.pro ) + diff --git a/libopie2/examples/opienet/onetworkdemo/.cvsignore b/libopie2/examples/opienet/onetworkdemo/.cvsignore new file mode 100644 index 0000000..8f7300c --- a/dev/null +++ b/libopie2/examples/opienet/onetworkdemo/.cvsignore @@ -0,0 +1,6 @@ +Makefile* +moc* +*moc +*.o +~* + diff --git a/libopie2/examples/opienet/onetworkdemo/onetworkdemo.cpp b/libopie2/examples/opienet/onetworkdemo/onetworkdemo.cpp new file mode 100644 index 0000000..7703b4c --- a/dev/null +++ b/libopie2/examples/opienet/onetworkdemo/onetworkdemo.cpp @@ -0,0 +1,35 @@ +#include + +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: MAC Address is '%s'", (const char*) it.current()->macAddress().toString() ); + qDebug( "Demo: IPv4 Address is '%s'", (const char*) it.current()->ipV4Address() ); + if ( it.current()->isWireless() ) + { + OWirelessNetworkInterface* iface = static_cast( 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: Current NickName is '%s'", (const char*) iface->nickName() ); + 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() ); + //} + + } + ++it; + } + + return 0; + +} diff --git a/libopie2/examples/opienet/onetworkdemo/onetworkdemo.pro b/libopie2/examples/opienet/onetworkdemo/onetworkdemo.pro new file mode 100644 index 0000000..2d71aa0 --- a/dev/null +++ b/libopie2/examples/opienet/onetworkdemo/onetworkdemo.pro @@ -0,0 +1,12 @@ +TEMPLATE = app +CONFIG = qt warn_on debug +HEADERS = +SOURCES = onetworkdemo.cpp +INCLUDEPATH += $(OPIEDIR)/include +DEPENDPATH += $(OPIEDIR)/include +LIBS += -lopiecore2 -lopienet2 +TARGET = onetworkdemo +MOC_DIR = moc +OBJECTS_DIR = obj + +include ( $(OPIEDIR)/include.pro ) diff --git a/libopie2/examples/opienet/opienet.pro b/libopie2/examples/opienet/opienet.pro new file mode 100644 index 0000000..c7800a9 --- a/dev/null +++ b/libopie2/examples/opienet/opienet.pro @@ -0,0 +1,3 @@ +TEMPLATE = subdirs +SUBDIRS = miniwellenreiter onetworkdemo + diff --git a/libopie2/examples/opieui/.cvsignore b/libopie2/examples/opieui/.cvsignore new file mode 100644 index 0000000..8f7300c --- a/dev/null +++ b/libopie2/examples/opieui/.cvsignore @@ -0,0 +1,6 @@ +Makefile* +moc* +*moc +*.o +~* + diff --git a/libopie2/examples/opieui/oversatileviewdemo/1.png b/libopie2/examples/opieui/oversatileviewdemo/1.png new file mode 100644 index 0000000..0e2e41b --- a/dev/null +++ b/libopie2/examples/opieui/oversatileviewdemo/1.png Binary files differ diff --git a/libopie2/examples/opieui/oversatileviewdemo/1small.png b/libopie2/examples/opieui/oversatileviewdemo/1small.png new file mode 100644 index 0000000..ce6b262 --- a/dev/null +++ b/libopie2/examples/opieui/oversatileviewdemo/1small.png Binary files differ diff --git a/libopie2/examples/opieui/oversatileviewdemo/2.png b/libopie2/examples/opieui/oversatileviewdemo/2.png new file mode 100644 index 0000000..8a0181d --- a/dev/null +++ b/libopie2/examples/opieui/oversatileviewdemo/2.png Binary files differ diff --git a/libopie2/examples/opieui/oversatileviewdemo/2small.png b/libopie2/examples/opieui/oversatileviewdemo/2small.png new file mode 100644 index 0000000..82a4431 --- a/dev/null +++ b/libopie2/examples/opieui/oversatileviewdemo/2small.png Binary files differ diff --git a/libopie2/examples/opieui/oversatileviewdemo/3.png b/libopie2/examples/opieui/oversatileviewdemo/3.png new file mode 100644 index 0000000..8a58d6c --- a/dev/null +++ b/libopie2/examples/opieui/oversatileviewdemo/3.png Binary files differ diff --git a/libopie2/examples/opieui/oversatileviewdemo/3small.png b/libopie2/examples/opieui/oversatileviewdemo/3small.png new file mode 100644 index 0000000..073ba55 --- a/dev/null +++ b/libopie2/examples/opieui/oversatileviewdemo/3small.png Binary files differ diff --git a/libopie2/examples/opieui/oversatileviewdemo/4.png b/libopie2/examples/opieui/oversatileviewdemo/4.png new file mode 100644 index 0000000..198891b --- a/dev/null +++ b/libopie2/examples/opieui/oversatileviewdemo/4.png Binary files differ diff --git a/libopie2/examples/opieui/oversatileviewdemo/4small.png b/libopie2/examples/opieui/oversatileviewdemo/4small.png new file mode 100644 index 0000000..7f1cc01 --- a/dev/null +++ b/libopie2/examples/opieui/oversatileviewdemo/4small.png Binary files differ diff --git a/libopie2/examples/opieui/oversatileviewdemo/5.png b/libopie2/examples/opieui/oversatileviewdemo/5.png new file mode 100644 index 0000000..ee7344a --- a/dev/null +++ b/libopie2/examples/opieui/oversatileviewdemo/5.png Binary files differ diff --git a/libopie2/examples/opieui/oversatileviewdemo/5small.png b/libopie2/examples/opieui/oversatileviewdemo/5small.png new file mode 100644 index 0000000..105b038 --- a/dev/null +++ b/libopie2/examples/opieui/oversatileviewdemo/5small.png Binary files differ diff --git a/libopie2/examples/opieui/oversatileviewdemo/6.png b/libopie2/examples/opieui/oversatileviewdemo/6.png new file mode 100644 index 0000000..72c3692 --- a/dev/null +++ b/libopie2/examples/opieui/oversatileviewdemo/6.png Binary files differ diff --git a/libopie2/examples/opieui/oversatileviewdemo/6small.png b/libopie2/examples/opieui/oversatileviewdemo/6small.png new file mode 100644 index 0000000..1db2a30 --- a/dev/null +++ b/libopie2/examples/opieui/oversatileviewdemo/6small.png Binary files differ diff --git a/libopie2/examples/opieui/oversatileviewdemo/folder_closed.png b/libopie2/examples/opieui/oversatileviewdemo/folder_closed.png new file mode 100644 index 0000000..4157333 --- a/dev/null +++ b/libopie2/examples/opieui/oversatileviewdemo/folder_closed.png Binary files differ diff --git a/libopie2/examples/opieui/oversatileviewdemo/folder_closed32.png b/libopie2/examples/opieui/oversatileviewdemo/folder_closed32.png new file mode 100644 index 0000000..acc992c --- a/dev/null +++ b/libopie2/examples/opieui/oversatileviewdemo/folder_closed32.png Binary files differ diff --git a/libopie2/examples/opieui/oversatileviewdemo/folder_opened.png b/libopie2/examples/opieui/oversatileviewdemo/folder_opened.png new file mode 100644 index 0000000..5e7e37e --- a/dev/null +++ b/libopie2/examples/opieui/oversatileviewdemo/folder_opened.png Binary files differ diff --git a/libopie2/examples/opieui/oversatileviewdemo/folder_opened32.png b/libopie2/examples/opieui/oversatileviewdemo/folder_opened32.png new file mode 100644 index 0000000..acd3265 --- a/dev/null +++ b/libopie2/examples/opieui/oversatileviewdemo/folder_opened32.png Binary files differ diff --git a/libopie2/examples/opieui/oversatileviewdemo/leaf.png b/libopie2/examples/opieui/oversatileviewdemo/leaf.png new file mode 100644 index 0000000..c8435ec --- a/dev/null +++ b/libopie2/examples/opieui/oversatileviewdemo/leaf.png Binary files differ diff --git a/libopie2/examples/opieui/oversatileviewdemo/leaf32.png b/libopie2/examples/opieui/oversatileviewdemo/leaf32.png new file mode 100644 index 0000000..5e90ead --- a/dev/null +++ b/libopie2/examples/opieui/oversatileviewdemo/leaf32.png Binary files differ diff --git a/libopie2/examples/opieui/oversatileviewdemo/main.cpp b/libopie2/examples/opieui/oversatileviewdemo/main.cpp new file mode 100644 index 0000000..d8c01a4 --- a/dev/null +++ b/libopie2/examples/opieui/oversatileviewdemo/main.cpp @@ -0,0 +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 "opieuidemo.h" + +#include + +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/opieui.pro b/libopie2/examples/opieui/oversatileviewdemo/opieui.pro new file mode 100644 index 0000000..8ad5fc9 --- a/dev/null +++ b/libopie2/examples/opieui/oversatileviewdemo/opieui.pro @@ -0,0 +1,17 @@ +TEMPLATE = app +CONFIG = qt warn_on debug +HEADERS = opieuidemo.h \ + oversatileviewdemo.h +SOURCES = opieuidemo.cpp \ + oversatileviewdemo.cpp \ + main.cpp +INCLUDEPATH += $(OPIEDIR)/include +DEPENDPATH += $(OPIEDIR)/include +LIBS += -lopieui2 -lopiecore2 +TARGET = opieuidemo +MOC_DIR = moc +OBJECTS_DIR = obj + +include ( $(OPIEDIR)/include.pro ) + + diff --git a/libopie2/examples/opieui/oversatileviewdemo/opieuidemo.cpp b/libopie2/examples/opieui/oversatileviewdemo/opieuidemo.cpp new file mode 100644 index 0000000..197669c --- a/dev/null +++ b/libopie2/examples/opieui/oversatileviewdemo/opieuidemo.cpp @@ -0,0 +1,205 @@ +/********************************************************************** +** 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 +#include +#include +#include +#include +#include +#include + +// Qtopia + +#ifdef QWS +#include +#include +#endif + +// Opie + +#ifdef QWS +#include +using namespace Opie; +#endif + +#include +#include +#include +#include +#include +#include + +#include +#include "oversatileviewdemo.h" + +// Local + +#include "opieuidemo.h" + +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"; + ilist << "groucho@handhelds.org"; + combo->insertStringList( ilist ); + + QStringList clist; + clist << "mickeyl@handhelds.org"; + clist << "mickey@tm.informatik.uni-frankfurt.de"; + clist << "mickey@vanille.de"; + comp->setItems( clist ); + + combo->show(); + +} + +void OpieUIDemo::demoOEditListBox() +{ + qDebug( "oeditlistbox" ); + + OEditListBox* edit = new OEditListBox( "OEditListBox", 0, "editlistbox" ); + + edit->lineEdit()->setCompletionMode( OGlobalSettings::CompletionPopup ); + OCompletion* comp = edit->lineEdit()->completionObject(); + QStringList clist; + clist << "Completion everywhere"; + clist << "Cool Completion everywhere"; + clist << "History History History"; + comp->setItems( clist ); + + QStringList list; + list << "kergoth@handhelds.org"; + list << "harlekin@handhelds.org"; + list << "groucho@handhelds.org"; + list << "mickeyl@handhelds.org"; + edit->insertStringList( list ); + + edit->show(); + +} + +void OpieUIDemo::demoOSelector() +{ + qDebug( "oselector" ); + + OHSSelector* sel = new OHSSelector( 0, "gradientselector" ); + //#sel->resize( QSize( 200, 30 ) ); + //#sel->setColors( QColor( 90, 190, 60 ), QColor( 200, 55, 255 ) ); + //#sel->setText( "Dark", "Light" ); + + sel->show(); +} + +void OpieUIDemo::messageBox( const QString& text ) +{ + QString info; + info = "You have selected '" + text + "'"; + QMessageBox::information( this, "OpieUIDemo", info ); +} diff --git a/libopie2/examples/opieui/oversatileviewdemo/opieuidemo.h b/libopie2/examples/opieui/oversatileviewdemo/opieuidemo.h new file mode 100644 index 0000000..0519ae6 --- a/dev/null +++ b/libopie2/examples/opieui/oversatileviewdemo/opieuidemo.h @@ -0,0 +1,56 @@ +/********************************************************************** +** 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 + +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; + +}; + + + +#endif diff --git a/libopie2/examples/opieui/oversatileviewdemo/oversatileviewdemo.cpp b/libopie2/examples/opieui/oversatileviewdemo/oversatileviewdemo.cpp new file mode 100644 index 0000000..cf1e443 --- a/dev/null +++ b/libopie2/examples/opieui/oversatileviewdemo/oversatileviewdemo.cpp @@ -0,0 +1,158 @@ +/* +                 This file is part of the Opie Project + +              Copyright (C) 2003 Michael 'Mickey' Lauer + + =. + .=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_,=:_.      -`: 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 +#include + +#include +#include +#include + +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() +{ + qDebug( "received signal onViewport()" ); +} + +void OVersatileViewDemo::expanded( OVersatileViewItem *item ) +{ + qDebug( "received signal expanded( OVersatileViewItem *item )" ); +} + +void OVersatileViewDemo::collapsed( OVersatileViewItem *item ) +{ + qDebug( "received signal collapsed( OVersatileViewItem *item )" ); +} + +void OVersatileViewDemo::moved() +{ + qDebug( "received signal moved( OVersatileViewItem *item )" ); +} + +void OVersatileViewDemo::contextMenuRequested( OVersatileViewItem *item, const QPoint& pos, int col ) +{ + qDebug( "received signal contextMenuRequested( OVersatileViewItem *item )" ); +} diff --git a/libopie2/examples/opieui/oversatileviewdemo/oversatileviewdemo.h b/libopie2/examples/opieui/oversatileviewdemo/oversatileviewdemo.h new file mode 100644 index 0000000..79318d0 --- a/dev/null +++ b/libopie2/examples/opieui/oversatileviewdemo/oversatileviewdemo.h @@ -0,0 +1,73 @@ +/* +                 This file is part of the Opie Project + +              Copyright (C) 2003 Michael 'Mickey' Lauer + =. + .=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_,=:_.      -`: 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 + +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 doubleClicked( OVersatileViewItem *item ); + void returnPressed( OVersatileViewItem *item ); + + void onItem( OVersatileViewItem *item ); + void onViewport(); + + void expanded( OVersatileViewItem *item ); + void collapsed( OVersatileViewItem *item ); + + void moved(); + + void contextMenuRequested( OVersatileViewItem *item, const QPoint&, int col ); + + private: + OVersatileView* vv; + +}; + +#endif -- cgit v0.9.0.2