summaryrefslogtreecommitdiff
path: root/examples
Side-by-side diff
Diffstat (limited to 'examples') (more/less context) (ignore whitespace changes)
-rw-r--r--examples/opiecore/onotifytest/main.cpp18
-rw-r--r--examples/opiecore/onotifytest/main.h10
2 files changed, 22 insertions, 6 deletions
diff --git a/examples/opiecore/onotifytest/main.cpp b/examples/opiecore/onotifytest/main.cpp
index b773da9..7b7b0bc 100644
--- a/examples/opiecore/onotifytest/main.cpp
+++ b/examples/opiecore/onotifytest/main.cpp
@@ -33,7 +33,15 @@ App::App( int argc, char** argv ) : QApplication( argc, argv )
- ODirNotification* tmpfoo = new ODirNotification( 0, 0 );
+ tmpfoo = new ODirNotification( 0, 0 );
int result = tmpfoo->watch( "/tmp/foo", false, CreateFile, 2 );
- QObject::connect( tmpfoo, SIGNAL(triggered(const QString&,unsigned int,const QString&)),
- this, SLOT(triggered(const QString&,unsigned int,const QString&)) );
+
+ if ( result != -1 )
+ {
+ QObject::connect( tmpfoo, SIGNAL(triggered(const QString&,unsigned int,const QString&)),
+ this, SLOT(triggered(const QString&,unsigned int,const QString&)) );
+ }
+ else
+ {
+ QMessageBox::warning( qApp->desktop(), "info", "Couldn't watch /tmp/foo\nDoes it exist?" );
+ }
}
@@ -43,2 +51,3 @@ App::~App()
odebug << "~App()" << oendl;
+ delete tmpfoo;
}
@@ -47,3 +56,4 @@ void App::triggered( const QString& str1, unsigned int id, const QString& str2 )
{
- QMessageBox::information( qApp->desktop(), "info", QString( "%1\n%2\n%3" ).arg( str1 ).arg( id ).arg( str2 ) );
+ QMessageBox::information( qApp->desktop(), "info", QString().sprintf( "%s\n0x%08x\n%s",
+ (const char*) str1, id, (const char*) str2 ) );
}
diff --git a/examples/opiecore/onotifytest/main.h b/examples/opiecore/onotifytest/main.h
index afad947..7ce4b9f 100644
--- a/examples/opiecore/onotifytest/main.h
+++ b/examples/opiecore/onotifytest/main.h
@@ -6,2 +6,5 @@
+/* OPIE */
+#include <opie2/ofilenotify.h>
+
/* QT */
@@ -14,3 +17,3 @@ class App : public QApplication
Q_OBJECT
-public:
+ public:
App( int argc, char** argv );
@@ -18,4 +21,7 @@ public:
-public slots:
+ public slots:
void triggered( const QString&, unsigned int, const QString& );
+
+ private:
+ Opie::Core::ODirNotification* tmpfoo;
};