Diffstat (limited to 'libopie2/examples/opiecore/odebugdemo') (more/less context) (show whitespace changes)
-rw-r--r-- | libopie2/examples/opiecore/odebugdemo/.cvsignore | 6 | ||||
-rw-r--r-- | libopie2/examples/opiecore/odebugdemo/odebugdemo.cpp | 138 | ||||
-rw-r--r-- | libopie2/examples/opiecore/odebugdemo/odebugdemo.pro | 14 |
3 files changed, 158 insertions, 0 deletions
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 @@ | |||
1 | Makefile* | ||
2 | moc* | ||
3 | *moc | ||
4 | *.o | ||
5 | ~* | ||
6 | |||
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 @@ | |||
1 | /* QT */ | ||
2 | |||
3 | #include <qvbox.h> | ||
4 | #include <qhbox.h> | ||
5 | #include <qvbuttongroup.h> | ||
6 | #include <qhbuttongroup.h> | ||
7 | #include <qlineedit.h> | ||
8 | #include <qradiobutton.h> | ||
9 | #include <qpushbutton.h> | ||
10 | |||
11 | /* OPIE */ | ||
12 | |||
13 | #include <qpe/config.h> | ||
14 | |||
15 | #include <opie2/odebug.h> | ||
16 | #include <opie2/oapplication.h> | ||
17 | #include <opie2/oglobal.h> | ||
18 | #include <opie2/oglobalsettings.h> | ||
19 | |||
20 | class DemoApp : public OApplication | ||
21 | { | ||
22 | Q_OBJECT | ||
23 | public: | ||
24 | DemoApp( int argc, char** argv ) : OApplication( argc, argv, "libopie2 debug demo" ) | ||
25 | { | ||
26 | // you have access to your OApplication object via oApp | ||
27 | qDebug( "Process-wide OApplication object @ %0x", oApp ); | ||
28 | |||
29 | // you have access to global settings via OGlobalSettings | ||
30 | int mode = OGlobalSettings::debugMode(); | ||
31 | |||
32 | QVBox* vbox = new QVBox(); | ||
33 | setMainWidget( vbox ); | ||
34 | |||
35 | g = new QVButtonGroup( "Output Strategy", vbox ); | ||
36 | QRadioButton* r0 = new QRadioButton( "file", g ); | ||
37 | QRadioButton* r1 = new QRadioButton( "messagebox", g ); | ||
38 | QRadioButton* r2 = new QRadioButton( "stderr", g ); | ||
39 | QRadioButton* r3 = new QRadioButton( "syslog", g ); | ||
40 | QRadioButton* r4 = new QRadioButton( "socket", g ); | ||
41 | g->insert( r0, 0 ); | ||
42 | g->insert( r1, 1 ); | ||
43 | g->insert( r2, 2 ); | ||
44 | g->insert( r3, 3 ); | ||
45 | g->insert( r4, 4 ); | ||
46 | g->setRadioButtonExclusive( true ); | ||
47 | connect( g, SIGNAL( clicked(int) ), this, SLOT( chooseMethod(int) ) ); | ||
48 | |||
49 | if ( mode != -1 ) g->setButton( mode ); | ||
50 | |||
51 | QHButtonGroup* hbox = new QHButtonGroup( "Extra Output Information", vbox ); | ||
52 | e = new QLineEdit( hbox ); | ||
53 | QPushButton* pb = new QPushButton( hbox ); | ||
54 | |||
55 | connect( e, SIGNAL( returnPressed() ), this, SLOT( updateDebugOutput() ) ); | ||
56 | connect( pb, SIGNAL( clicked() ), this, SLOT( updateDebugOutput() ) ); | ||
57 | |||
58 | // show the additional debug mode dependent output information | ||
59 | e->setText( OGlobalSettings::debugOutput() ); | ||
60 | |||
61 | // buttos | ||
62 | QPushButton* info = new QPushButton( "Emit Debug(Info) Output!", vbox ); | ||
63 | connect( info, SIGNAL( clicked() ), this, SLOT( emitInfoOutput() ) ); | ||
64 | QPushButton* warn = new QPushButton( "Emit a Warning Output!", vbox ); | ||
65 | connect( warn, SIGNAL( clicked() ), this, SLOT( emitWarningOutput() ) ); | ||
66 | QPushButton* error = new QPushButton( "Emit an Error Output!", vbox ); | ||
67 | connect( error, SIGNAL( clicked() ), this, SLOT( emitErrorOutput() ) ); | ||
68 | QPushButton* fatal = new QPushButton( "Emit a Fatal Output!", vbox ); | ||
69 | connect( fatal, SIGNAL( clicked() ), this, SLOT( emitFatalOutput() ) ); | ||
70 | |||
71 | QPushButton* tb = new QPushButton( "Emit a Fatal Backtrace!", vbox ); | ||
72 | connect( tb, SIGNAL( clicked() ), this, SLOT( emitTBOutput() ) ); | ||
73 | |||
74 | info->show(); | ||
75 | warn->show(); | ||
76 | error->show(); | ||
77 | fatal->show(); | ||
78 | tb->show(); | ||
79 | g->show(); | ||
80 | hbox->show(); | ||
81 | e->show(); | ||
82 | vbox->show(); | ||
83 | showMainWidget( vbox ); | ||
84 | } | ||
85 | |||
86 | public slots: | ||
87 | void chooseMethod(int method) | ||
88 | { | ||
89 | m = method; | ||
90 | qDebug( "choosing method: %d", method ); | ||
91 | OConfig* g = OGlobal::config(); | ||
92 | g->setGroup( "General" ); | ||
93 | g->writeEntry( "debugMode", m ); | ||
94 | e->setText( OGlobalSettings::debugOutput() ); | ||
95 | } | ||
96 | void updateDebugOutput() | ||
97 | { | ||
98 | OConfig* g = OGlobal::config(); | ||
99 | g->setGroup( "General" ); | ||
100 | g->writeEntry( "debugOutput"+QString::number(OGlobalSettings::debugMode()), e->text() ); | ||
101 | } | ||
102 | void emitInfoOutput() | ||
103 | { | ||
104 | odebug << "This is a debug message" << oendl; | ||
105 | } | ||
106 | void emitWarningOutput() | ||
107 | { | ||
108 | owarn << "This is a warning message" << oendl; | ||
109 | } | ||
110 | void emitErrorOutput() | ||
111 | { | ||
112 | oerr << "This is an errror message" << oendl; | ||
113 | } | ||
114 | void emitFatalOutput() | ||
115 | { | ||
116 | ofatal << "This is a fatal message" << oendl; | ||
117 | } | ||
118 | void emitTBOutput() | ||
119 | { | ||
120 | ofatal << "This is a fatal message + backtrace\n" + odBacktrace(); // odBacktrace includes \n | ||
121 | } | ||
122 | |||
123 | private: | ||
124 | QButtonGroup* g; | ||
125 | int m; | ||
126 | QLineEdit* e; | ||
127 | }; | ||
128 | |||
129 | int main( int argc, char** argv ) | ||
130 | { | ||
131 | DemoApp* app = new DemoApp( argc, argv ); | ||
132 | app->exec(); | ||
133 | |||
134 | return 0; | ||
135 | |||
136 | } | ||
137 | |||
138 | #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 @@ | |||
1 | TEMPLATE = app | ||
2 | CONFIG = qt warn_on debug | ||
3 | HEADERS = | ||
4 | SOURCES = odebugdemo.cpp | ||
5 | INCLUDEPATH += $(OPIEDIR)/include | ||
6 | DEPENDPATH += $(OPIEDIR)/include | ||
7 | LIBS += -lopiecore2 | ||
8 | TARGET = odebugdemo | ||
9 | MOC_DIR = moc | ||
10 | OBJECTS_DIR = obj | ||
11 | |||
12 | include ( $(OPIEDIR)/include.pro ) | ||
13 | |||
14 | |||