-rw-r--r-- | examples/opiecore/onotifytest/main.cpp | 14 | ||||
-rw-r--r-- | examples/opiecore/onotifytest/main.h | 6 |
2 files changed, 18 insertions, 2 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 @@ -28,27 +28,37 @@ App::App( int argc, char** argv ) : QApplication( argc, argv ) } QObject::connect( tmpfoo, SIGNAL(accessed(const QString&)), this, SLOT(quit()) ); QObject::connect( tmpfoo, SIGNAL(closed(const QString&,bool)), this, SLOT(quit()) ); #endif - ODirNotification* tmpfoo = new ODirNotification( 0, 0 ); + tmpfoo = new ODirNotification( 0, 0 ); int result = tmpfoo->watch( "/tmp/foo", false, CreateFile, 2 ); + + 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?" ); + } +} App::~App() { odebug << "~App()" << oendl; + delete tmpfoo; } 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 ) ); } int main( int argc, char** argv ) { App* app = new App( argc, argv ); QPushButton* b = new QPushButton( "Click me to close", 0 ); 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 @@ -1,12 +1,15 @@ // (C) Michael 'Mickey' Lauer <mickey@Vanille.de> // LICENSE = "GPLv2" #ifndef MAIN_H #define MAIN_H +/* OPIE */ +#include <opie2/ofilenotify.h> + /* QT */ #include <qapplication.h> #include <qpushbutton.h> #include <qtextstream.h> class App : public QApplication @@ -15,9 +18,12 @@ class App : public QApplication public: App( int argc, char** argv ); ~App(); public slots: void triggered( const QString&, unsigned int, const QString& ); + + private: + Opie::Core::ODirNotification* tmpfoo; }; #endif |