author | mickeyl <mickeyl> | 2005-01-29 14:18:51 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2005-01-29 14:18:51 (UTC) |
commit | 555b999359a5aad999eaaf48632ce85f25125b85 (patch) (side-by-side diff) | |
tree | 7414362241e49e06f49486e93a8f504113961b1c /examples/opiecore/odebugdemo | |
parent | 7b06e36fe27adc6a4fde2004eac13aaf8c0f0f02 (diff) | |
download | opie-555b999359a5aad999eaaf48632ce85f25125b85.zip opie-555b999359a5aad999eaaf48632ce85f25125b85.tar.gz opie-555b999359a5aad999eaaf48632ce85f25125b85.tar.bz2 |
examples appear here
-rw-r--r-- | examples/opiecore/odebugdemo/.cvsignore | 8 | ||||
-rw-r--r-- | examples/opiecore/odebugdemo/odebugdemo.cpp | 142 | ||||
-rw-r--r-- | examples/opiecore/odebugdemo/odebugdemo.pro | 17 |
3 files changed, 167 insertions, 0 deletions
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 <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 + 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 +} + |