From 555b999359a5aad999eaaf48632ce85f25125b85 Mon Sep 17 00:00:00 2001 From: mickeyl Date: Sat, 29 Jan 2005 14:18:51 +0000 Subject: examples appear here --- (limited to 'examples/opiecore') diff --git a/examples/opiecore/oconfigdemo/.cvsignore b/examples/opiecore/oconfigdemo/.cvsignore new file mode 100644 index 0000000..db3635b --- a/dev/null +++ b/examples/opiecore/oconfigdemo/.cvsignore @@ -0,0 +1,8 @@ +oconfigdemo +Makefile* +obj +moc* +*moc +*.o +~* + diff --git a/examples/opiecore/oconfigdemo/oconfigdemo.cpp b/examples/opiecore/oconfigdemo/oconfigdemo.cpp new file mode 100644 index 0000000..2ee4a65 --- a/dev/null +++ b/examples/opiecore/oconfigdemo/oconfigdemo.cpp @@ -0,0 +1,32 @@ +#include +#include +#include + +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; + +} + diff --git a/examples/opiecore/oconfigdemo/oconfigdemo.pro b/examples/opiecore/oconfigdemo/oconfigdemo.pro new file mode 100644 index 0000000..b29c106 --- a/dev/null +++ b/examples/opiecore/oconfigdemo/oconfigdemo.pro @@ -0,0 +1,18 @@ +TEMPLATE = app +CONFIG = qt warn_on +HEADERS = +SOURCES = oconfigdemo.cpp + +INCLUDEPATH += $(OPIEDIR)/include +DEPENDPATH += $(OPIEDIR)/include +LIBS += -lopiecore2 +TARGET = oconfigdemo + +!contains( platform, x11 ) { + include( $(OPIEDIR)/include.pro ) +} + +contains( platform, x11 ) { + LIBS += -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib +} + diff --git a/examples/opiecore/odebugdemo/.cvsignore b/examples/opiecore/odebugdemo/.cvsignore new file mode 100644 index 0000000..731667d --- a/dev/null +++ b/examples/opiecore/odebugdemo/.cvsignore @@ -0,0 +1,8 @@ +odebugdemo +Makefile* +obj +moc* +*moc +*.o +~* + diff --git a/examples/opiecore/odebugdemo/odebugdemo.cpp b/examples/opiecore/odebugdemo/odebugdemo.cpp new file mode 100644 index 0000000..b046d28 --- a/dev/null +++ b/examples/opiecore/odebugdemo/odebugdemo.cpp @@ -0,0 +1,142 @@ +/* QT */ + +#include +#include +#include +#include +#include +#include +#include + +/* OPIE */ + +#include + +#include +#include +#include +#include + +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 + odebug << "Process-wide OApplication object @ " << oApp << "" << oendl; + + // 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; + odebug << "choosing method: " << method << "" << oendl; + 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; + } + 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 "odebugdemo.moc" diff --git a/examples/opiecore/odebugdemo/odebugdemo.pro b/examples/opiecore/odebugdemo/odebugdemo.pro new file mode 100644 index 0000000..e06053c --- a/dev/null +++ b/examples/opiecore/odebugdemo/odebugdemo.pro @@ -0,0 +1,17 @@ +TEMPLATE = app +CONFIG = qt warn_on +HEADERS = +SOURCES = odebugdemo.cpp +INCLUDEPATH += $(OPIEDIR)/include +DEPENDPATH += $(OPIEDIR)/include +LIBS += -lopiecore2 +TARGET = odebugdemo + +!contains( platform, x11 ) { + include( $(OPIEDIR)/include.pro ) +} + +contains( platform, x11 ) { + LIBS += -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib +} + diff --git a/examples/opiecore/oglobalsettingsdemo/.cvsignore b/examples/opiecore/oglobalsettingsdemo/.cvsignore new file mode 100644 index 0000000..d564c61 --- a/dev/null +++ b/examples/opiecore/oglobalsettingsdemo/.cvsignore @@ -0,0 +1,8 @@ +oglobalsettingsdemo +Makefile* +obj +moc* +*moc +*.o +~* + diff --git a/examples/opiecore/oglobalsettingsdemo/oglobalsettingsdemo.cpp b/examples/opiecore/oglobalsettingsdemo/oglobalsettingsdemo.cpp new file mode 100644 index 0000000..37bcf13 --- a/dev/null +++ b/examples/opiecore/oglobalsettingsdemo/oglobalsettingsdemo.cpp @@ -0,0 +1,15 @@ +#include +#include + +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/examples/opiecore/oglobalsettingsdemo/oglobalsettingsdemo.pro b/examples/opiecore/oglobalsettingsdemo/oglobalsettingsdemo.pro new file mode 100644 index 0000000..d7bed05 --- a/dev/null +++ b/examples/opiecore/oglobalsettingsdemo/oglobalsettingsdemo.pro @@ -0,0 +1,14 @@ +TEMPLATE = app +CONFIG = qt warn_on +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/examples/opiecore/okeyconfigmanager/README b/examples/opiecore/okeyconfigmanager/README new file mode 100644 index 0000000..327b7c2 --- a/dev/null +++ b/examples/opiecore/okeyconfigmanager/README @@ -0,0 +1 @@ +See opieui/okeyconfigwidget for an example of possible usage \ No newline at end of file diff --git a/examples/opiecore/onotifydemo/.cvsignore b/examples/opiecore/onotifydemo/.cvsignore new file mode 100644 index 0000000..8f7300c --- a/dev/null +++ b/examples/opiecore/onotifydemo/.cvsignore @@ -0,0 +1,6 @@ +Makefile* +moc* +*moc +*.o +~* + diff --git a/examples/opiecore/onotifydemo/onotifydemo.cpp b/examples/opiecore/onotifydemo/onotifydemo.cpp new file mode 100644 index 0000000..b9ff9db --- a/dev/null +++ b/examples/opiecore/onotifydemo/onotifydemo.cpp @@ -0,0 +1,144 @@ +/* OPIE */ +#include +#include +#include +#include +#include +using namespace Opie::Core; +using namespace Opie::Ui; + +/* QT */ +#include +#include +#include +#include +#include +#include +#include + +class DemoApp : public OApplication +{ + Q_OBJECT +public: + DemoApp( int argc, char** argv ) : OApplication( argc, argv, "libopie2 notify demo" ) + { + + QVBox* vbox = new QVBox(); + setMainWidget( vbox ); + + l = new OListView( vbox ); + l->addColumn( "Notification Path" ); + l->addColumn( "Trigger Type" ); + l->addColumn( "Trigger Mask" ); + l->setColumnAlignment( 1, AlignCenter ); + l->setColumnAlignment( 2, AlignCenter ); + + QHBox* hbox = new QHBox( vbox ); + + g2 = new QVButtonGroup( "Specify Trigger Type", hbox ); + //QCheckBox* c1 = new QCheckBox( "Multi", g2 ); + QCheckBox* c2 = new QCheckBox( "Access", g2 ); + QCheckBox* c3 = new QCheckBox( "Modify", g2 ); + QCheckBox* c4 = new QCheckBox( "Create", g2 ); + QCheckBox* c5 = new QCheckBox( "Delete", g2 ); + QCheckBox* c6 = new QCheckBox( "Rename", g2 ); + QCheckBox* c7 = new QCheckBox( "Attrib", g2 ); + g2->insert( c2, Access ); + g2->insert( c3, Modify ); + g2->insert( c4, Create ); + g2->insert( c5, Delete ); + g2->insert( c6, Rename ); + g2->insert( c7, Attrib ); + connect( g2, SIGNAL( pressed(int) ), this, SLOT( modifierClicked(int) ) ); + + g1 = new QVButtonGroup( "Add/Remove", hbox ); + QPushButton* plus1 = new QPushButton( "Add\n&Single", g1 ); + QPushButton* plus2 = new QPushButton( "Add\n&Multi", g1 ); + QPushButton* minus = new QPushButton( "&Remove\nIt!", g1 ); + g1->insert( plus1, 0 ); + g1->insert( plus2, 1 ); + g1->insert( minus, 2 ); + connect( plus1, SIGNAL( clicked() ), this, SLOT( addSingle() ) ); + connect( plus2, SIGNAL( clicked() ), this, SLOT( addMulti() ) ); + connect( minus, SIGNAL( clicked() ), this, SLOT( delTrigger() ) ); + + g1->show(); + g2->show(); + l->show(); + hbox->show(); + vbox->show(); + showMainWidget( vbox ); + } + +public: + void addTrigger( bool multi = false ) + { + if ( !m ) + { + QMessageBox::warning( 0, "Add Trigger", "

Can't add trigger without at least one selected trigger type

", "&Sorry", 0 ); + return; + } + + QString filename = OFileDialog::getOpenFileName( OFileSelector::ExtendedAll ); + if ( !filename.isEmpty() ) + { + odebug << "Filename = " << filename << oendl; + + int fntype = m; + if ( multi ) fntype |=(int) Multi; + + QString modifier = QString().sprintf( " = 0x%08x", fntype ); + new OListViewItem( l, filename, multi ? "MULTI" : "SINGLE", modifier ); + if ( !multi ) + OFileNotification::singleShot( filename, this, SLOT( trigger() ), (OFileNotificationType) fntype ); + else + OFileNotification::singleShot( filename, this, SLOT( trigger() ), (OFileNotificationType) fntype ); + } + else + { + odebug << "cancelled." << oendl; + } + } + +public slots: + void modifierClicked( int modifier ) { m = static_cast( (int)m ^ int(modifier) ); }; + void addSingle() { addTrigger(); }; + void addMulti() { addTrigger( true ); }; + + void delTrigger() + { + QListViewItem* item = l->selectedItem(); + if ( !item ) + { + QMessageBox::warning( 0, "Del Trigger", "

No trigger selected!

", "&Sorry", 0 ); + return; + } + else + { + QString filename( item->text( 0 ) ); + odebug << "Filename = " << filename << oendl; + } + } + + void trigger() + { + owarn << "FIRE!" << oendl; + } + +private: + OListView* l; + QButtonGroup* g1; + QButtonGroup* g2; + OFileNotificationType m; +}; + +int main( int argc, char** argv ) +{ + DemoApp* app = new DemoApp( argc, argv ); + app->exec(); + + return 0; + +} + +#include "moc/onotifydemo.moc" diff --git a/examples/opiecore/onotifydemo/onotifydemo.pro b/examples/opiecore/onotifydemo/onotifydemo.pro new file mode 100644 index 0000000..d2c9138 --- a/dev/null +++ b/examples/opiecore/onotifydemo/onotifydemo.pro @@ -0,0 +1,18 @@ +TEMPLATE = app +CONFIG = qt warn_on +HEADERS = +SOURCES = onotifydemo.cpp +INCLUDEPATH += $(OPIEDIR)/include +DEPENDPATH += $(OPIEDIR)/include +LIBS += -lopiecore2 -lopieui2 +TARGET = onotifydemo + +!contains( platform, x11 ) { + include( $(OPIEDIR)/include.pro ) +} + +contains( platform, x11 ) { + LIBS += -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib +} + +MOC_DIR = moc diff --git a/examples/opiecore/opiecore.pro b/examples/opiecore/opiecore.pro new file mode 100644 index 0000000..39ffd3b --- a/dev/null +++ b/examples/opiecore/opiecore.pro @@ -0,0 +1,2 @@ +TEMPLATE = subdirs +unix:SUBDIRS = odebugdemo oconfigdemo oglobalsettingsdemo onotifydemo oprocessdemo oplugins diff --git a/examples/opiecore/oplugins/.cvsignore b/examples/opiecore/oplugins/.cvsignore new file mode 100644 index 0000000..514e011 --- a/dev/null +++ b/examples/opiecore/oplugins/.cvsignore @@ -0,0 +1,3 @@ +oplugins +Makefile +.moc diff --git a/examples/opiecore/oplugins/oplugins.cpp b/examples/opiecore/oplugins/oplugins.cpp new file mode 100644 index 0000000..26623be --- a/dev/null +++ b/examples/opiecore/oplugins/oplugins.cpp @@ -0,0 +1,47 @@ +/* + * You may copy, modify and or distribute without any limitation + */ +#include +#include + +#include + +using Opie::Core::OPluginItem; +using Opie::Core::OGenericPluginLoader; +using Opie::Core::OPluginLoader; + +void debugLst( const OPluginItem::List& lst ) { + for ( OPluginItem::List::ConstIterator it = lst.begin(); it != lst.end(); ++it ) + odebug << "Name " << (*it).name() << " " << (*it).path() << " " << (*it).position() << oendl; +} + + +int main( void ) { + OGenericPluginLoader loader( "today", true ); + loader.setAutoDelete( true ); + + odebug << "IS in Safe Mode" << loader.isInSafeMode() << oendl; + + OPluginItem::List lst = loader.allAvailable( true ); + debugLst( lst ); + + lst = loader.filtered( true ); + debugLst( lst ); + + for ( OPluginItem::List::Iterator it = lst.begin(); it != lst.end(); ++it ) { + QUnknownInterface* iface = loader.load( *it, IID_TodayPluginInterface ); + } + + OPluginLoader loader2("today",true); + OPluginItem::List lst2 = loader2.allAvailable( true ); + debugLst( lst2 ); + + for( OPluginItem::List::Iterator it = lst.begin(); it != lst.end(); ++it ){ + TodayPluginInterface* iface = loader2.load( *it, IID_TodayPluginInterface ); + } + + + /* + * now it's autodelete so cleaned up for us + */ +} diff --git a/examples/opiecore/oplugins/oplugins.pro b/examples/opiecore/oplugins/oplugins.pro new file mode 100644 index 0000000..03f8e4d --- a/dev/null +++ b/examples/opiecore/oplugins/oplugins.pro @@ -0,0 +1,11 @@ +TEMPLATE = app +CONFIG += qt warn_on + +SOURCES = oplugins.cpp + +INCLUDEPATH += $(OPIEDIR)/include +DEPENDSPATH += $(OPIEDIR)/include + +LIBS += -lopiecore2 + +include( $(OPIEDIR)/include.pro ) diff --git a/examples/opiecore/oprocessdemo/.cvsignore b/examples/opiecore/oprocessdemo/.cvsignore new file mode 100644 index 0000000..ab9cb4d --- a/dev/null +++ b/examples/opiecore/oprocessdemo/.cvsignore @@ -0,0 +1,7 @@ +oprocessdemo +Makefile* +moc* +*moc +*.o +~* + diff --git a/examples/opiecore/oprocessdemo/oprocessdemo.cpp b/examples/opiecore/oprocessdemo/oprocessdemo.cpp new file mode 100644 index 0000000..c5fc328 --- a/dev/null +++ b/examples/opiecore/oprocessdemo/oprocessdemo.cpp @@ -0,0 +1,13 @@ +#include +#include + +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/examples/opiecore/oprocessdemo/oprocessdemo.pro b/examples/opiecore/oprocessdemo/oprocessdemo.pro new file mode 100644 index 0000000..7efc614 --- a/dev/null +++ b/examples/opiecore/oprocessdemo/oprocessdemo.pro @@ -0,0 +1,12 @@ +TEMPLATE = app +CONFIG = qt warn_on +HEADERS = +SOURCES = oprocessdemo.cpp +INCLUDEPATH += $(OPIEDIR)/include +DEPENDPATH += $(OPIEDIR)/include +LIBS += -lopiecore2 +TARGET = oprocessdemo + +include( $(OPIEDIR)/include.pro ) + + -- cgit v0.9.0.2