summaryrefslogtreecommitdiff
path: root/libopie2/examples/opiecore
Unidiff
Diffstat (limited to 'libopie2/examples/opiecore') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/examples/opiecore/.cvsignore6
-rw-r--r--libopie2/examples/opiecore/oconfigdemo/.cvsignore6
-rw-r--r--libopie2/examples/opiecore/oconfigdemo/oconfigdemo.cpp31
-rw-r--r--libopie2/examples/opiecore/oconfigdemo/oconfigdemo.pro14
-rw-r--r--libopie2/examples/opiecore/odebugdemo/.cvsignore6
-rw-r--r--libopie2/examples/opiecore/odebugdemo/odebugdemo.cpp138
-rw-r--r--libopie2/examples/opiecore/odebugdemo/odebugdemo.pro14
-rw-r--r--libopie2/examples/opiecore/oglobalsettingsdemo/.cvsignore6
-rw-r--r--libopie2/examples/opiecore/oglobalsettingsdemo/oglobalsettingsdemo.cpp13
-rw-r--r--libopie2/examples/opiecore/oglobalsettingsdemo/oglobalsettingsdemo.pro14
-rw-r--r--libopie2/examples/opiecore/opiecore.pro3
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 @@
1Makefile*
2moc*
3*moc
4*.o
5~*
6
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 @@
1Makefile*
2moc*
3*moc
4*.o
5~*
6
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 @@
1#include <opie2/oapplication.h>
2#include <opie2/oconfig.h>
3#include <qpe/config.h>
4
5int main( int argc, char** argv )
6{
7 OApplication* app = new OApplication( argc, argv, "MyConfigDemoApplication" );
8
9 OConfigGroupSaver c1( app->config(), "MyGroup" );
10 app->config()->writeEntry( "AnEntry", "InMyGroup" );
11 {
12 OConfigGroupSaver c2( c1.config(), "AnotherGroup" );
13 app->config()->writeEntry( "AnEntry", "InAnotherGroup" );
14 } // closing the scope returns to the last group
15
16 app->config()->writeEntry( "AnotherEntry", "InMyGroup" );
17
18 // do more stuff ...
19
20 // in this (special) case it is necessary to manually call OConfig::write() (see below)
21 app->config()->write();
22
23 // can't delete the app when using the OConfigGroupSaver on top level scope,
24 // because the destructor of the OConfigGroupSaver needs an application object
25 //delete app; // destructor deletes config which writes changes back to disk
26
27 return 0;
28
29}
30
31//#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 @@
1TEMPLATE = app
2CONFIG = qt warn_on debug
3HEADERS =
4SOURCES = oconfigdemo.cpp
5
6INCLUDEPATH += $(OPIEDIR)/include
7DEPENDPATH += $(OPIEDIR)/include
8LIBS += -lopiecore2
9TARGET = oconfigdemo
10MOC_DIR = moc
11OBJECTS_DIR = obj
12
13include ( $(OPIEDIR)/include.pro )
14
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 @@
1Makefile*
2moc*
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
20class DemoApp : public OApplication
21{
22Q_OBJECT
23public:
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
86public 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
123private:
124 QButtonGroup* g;
125 int m;
126 QLineEdit* e;
127};
128
129int 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 @@
1TEMPLATE = app
2CONFIG = qt warn_on debug
3HEADERS =
4SOURCES = odebugdemo.cpp
5INCLUDEPATH += $(OPIEDIR)/include
6DEPENDPATH += $(OPIEDIR)/include
7LIBS += -lopiecore2
8TARGET = odebugdemo
9MOC_DIR = moc
10OBJECTS_DIR = obj
11
12include ( $(OPIEDIR)/include.pro )
13
14
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 @@
1Makefile*
2moc*
3*moc
4*.o
5~*
6
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 @@
1#include <opie2/oglobalsettings.h>
2#include <iostream.h>
3
4int main( int argc, char** argv )
5{
6 printf( "current debugmode seems to be '%d'\n", OGlobalSettings::debugMode() );
7 printf( "output information for this mode is '%s'\n", (const char*) OGlobalSettings::debugOutput() );
8
9 return 0;
10
11}
12
13//#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 @@
1TEMPLATE = app
2CONFIG = qt warn_on debug
3HEADERS =
4SOURCES = oglobalsettingsdemo.cpp
5INCLUDEPATH += $(OPIEDIR)/include
6DEPENDPATH += $(OPIEDIR)/include
7LIBS += -lopiecore2
8TARGET = oglobalsettingsdemo
9MOC_DIR = moc
10OBJECTS_DIR = obj
11
12include ( $(OPIEDIR)/include.pro )
13
14
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 @@
1TEMPLATE = subdirs
2unix:SUBDIRS = odebugdemo oconfigdemo oglobalsettingsdemo
3