Diffstat (limited to 'examples/opiecore/onotifydemo/onotifydemo.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | examples/opiecore/onotifydemo/onotifydemo.cpp | 48 |
1 files changed, 43 insertions, 5 deletions
diff --git a/examples/opiecore/onotifydemo/onotifydemo.cpp b/examples/opiecore/onotifydemo/onotifydemo.cpp index 0e84d80..2beda2a 100644 --- a/examples/opiecore/onotifydemo/onotifydemo.cpp +++ b/examples/opiecore/onotifydemo/onotifydemo.cpp | |||
@@ -13,2 +13,3 @@ using namespace Opie::Ui; | |||
13 | #include <qcheckbox.h> | 13 | #include <qcheckbox.h> |
14 | #include <qfileinfo.h> | ||
14 | #include <qvbox.h> | 15 | #include <qvbox.h> |
@@ -91,2 +92,3 @@ DemoApp::DemoApp( int argc, char** argv ) : OApplication( argc, argv, "libopie2 | |||
91 | { | 92 | { |
93 | bool success = true; | ||
92 | odebug << "Filename = " << filename << oendl; | 94 | odebug << "Filename = " << filename << oendl; |
@@ -95,7 +97,38 @@ DemoApp::DemoApp( int argc, char** argv ) : OApplication( argc, argv, "libopie2 | |||
95 | QString modifier = QString().sprintf( " = 0x%08x", fntype ); | 97 | QString modifier = QString().sprintf( " = 0x%08x", fntype ); |
96 | new OListViewItem( l, filename, multi ? "MULTI" : "SINGLE", modifier ); | 98 | |
99 | if ( QFileInfo( filename ).isFile() ) | ||
100 | { | ||
97 | if ( !multi ) | 101 | if ( !multi ) |
98 | OFileNotification::singleShot( filename, this, SLOT( trigger() ), (OFileNotificationType) fntype ); | 102 | { |
103 | success = OFileNotification::singleShot( filename, this, SLOT( unnamedTrigger() ), (OFileNotificationType) fntype ); | ||
104 | } | ||
99 | else | 105 | else |
100 | odebug << "not yet implemented..." << oendl; | 106 | { |
107 | OFileNotification* fn = new OFileNotification(); | ||
108 | success = fn->watch( filename, false, (OFileNotificationType) fntype ); | ||
109 | connect( fn, SIGNAL( triggered( const QString& ) ), this, SLOT( namedTrigger( const QString& ) ) ); | ||
110 | } | ||
111 | } | ||
112 | else if ( QFileInfo( filename ).isDir() ) | ||
113 | { | ||
114 | ODirNotification* dn = new ODirNotification(); | ||
115 | success = dn->watch( filename, !multi, (OFileNotificationType) fntype ); | ||
116 | connect( dn, SIGNAL( triggered( const QString& ) ), this, SLOT( namedTrigger( const QString& ) ) ); | ||
117 | } | ||
118 | else | ||
119 | { | ||
120 | odebug << "Huh!? Neither file nor directory..." << oendl; | ||
121 | return; | ||
122 | } | ||
123 | |||
124 | /* if ( !success ) | ||
125 | { | ||
126 | QMessageBox::warning( 0, "Add Trigger", "<p>Couldn't add trigger :(</p>", "&Sorry", 0 ); | ||
127 | return; | ||
128 | } | ||
129 | else | ||
130 | */ { | ||
131 | new OListViewItem( l, filename, multi ? "MULTI" : "SINGLE", modifier ); | ||
132 | } | ||
133 | return; | ||
101 | } | 134 | } |
@@ -126,5 +159,10 @@ DemoApp::DemoApp( int argc, char** argv ) : OApplication( argc, argv, "libopie2 | |||
126 | 159 | ||
127 | void DemoApp::trigger() | 160 | void DemoApp::unnamedTrigger() |
161 | { | ||
162 | owarn << "DemoApp::singleShotStrigger() : F I R E !!!!!" << oendl; | ||
163 | } | ||
164 | |||
165 | void DemoApp::namedTrigger( const QString& path ) | ||
128 | { | 166 | { |
129 | owarn << "FIRE!" << oendl; | 167 | owarn << "DemoApp::named trigger = " << path << " : F I R E !!!!!" << oendl; |
130 | } | 168 | } |