Diffstat (limited to 'libopie2/examples/opiecore/oconfigdemo') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/examples/opiecore/oconfigdemo/.cvsignore | 6 | ||||
-rw-r--r-- | libopie2/examples/opiecore/oconfigdemo/oconfigdemo.cpp | 31 | ||||
-rw-r--r-- | libopie2/examples/opiecore/oconfigdemo/oconfigdemo.pro | 14 |
3 files changed, 51 insertions, 0 deletions
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 @@ | |||
1 | Makefile* | ||
2 | moc* | ||
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 | |||
5 | int 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 @@ | |||
1 | TEMPLATE = app | ||
2 | CONFIG = qt warn_on debug | ||
3 | HEADERS = | ||
4 | SOURCES = oconfigdemo.cpp | ||
5 | |||
6 | INCLUDEPATH += $(OPIEDIR)/include | ||
7 | DEPENDPATH += $(OPIEDIR)/include | ||
8 | LIBS += -lopiecore2 | ||
9 | TARGET = oconfigdemo | ||
10 | MOC_DIR = moc | ||
11 | OBJECTS_DIR = obj | ||
12 | |||
13 | include ( $(OPIEDIR)/include.pro ) | ||
14 | |||