author | mickeyl <mickeyl> | 2003-03-28 15:11:52 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-03-28 15:11:52 (UTC) |
commit | 11304d02942e9fa493e4e80943a828f9c65f6772 (patch) (side-by-side diff) | |
tree | a0223c10c067e1afc70d15c2b82be3f3c15e41ae /libopie2/examples/opiecore | |
parent | b271d575fa05cf570a1a829136517761bd47e69b (diff) | |
download | opie-11304d02942e9fa493e4e80943a828f9c65f6772.zip opie-11304d02942e9fa493e4e80943a828f9c65f6772.tar.gz opie-11304d02942e9fa493e4e80943a828f9c65f6772.tar.bz2 |
skeleton and the start of libopie2, please read README, ROADMAP and STATUS and comment...
11 files changed, 251 insertions, 0 deletions
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 <opie2/oapplication.h> +#include <opie2/oconfig.h> +#include <qpe/config.h> + +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 <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> + +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 <opie2/oglobalsettings.h> +#include <iostream.h> + +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 + |