summaryrefslogtreecommitdiff
path: root/examples/opiecore/onotifydemo
Unidiff
Diffstat (limited to 'examples/opiecore/onotifydemo') (more/less context) (ignore whitespace changes)
-rw-r--r--examples/opiecore/onotifydemo/onotifydemo.cpp14
-rw-r--r--examples/opiecore/onotifydemo/onotifydemo.h2
2 files changed, 9 insertions, 7 deletions
diff --git a/examples/opiecore/onotifydemo/onotifydemo.cpp b/examples/opiecore/onotifydemo/onotifydemo.cpp
index 2beda2a..e147c6a 100644
--- a/examples/opiecore/onotifydemo/onotifydemo.cpp
+++ b/examples/opiecore/onotifydemo/onotifydemo.cpp
@@ -79,100 +79,102 @@ DemoApp::DemoApp( int argc, char** argv ) : OApplication( argc, argv, "libopie2
79 showMainWidget( vbox ); 79 showMainWidget( vbox );
80 } 80 }
81 81
82 void DemoApp::addTrigger( bool multi ) 82 void DemoApp::addTrigger( bool multi )
83 { 83 {
84 if ( !m ) 84 if ( !m )
85 { 85 {
86 QMessageBox::warning( 0, "Add Trigger", "<p>Can't add trigger without at least one selected trigger type</p>", "&Sorry", 0 ); 86 QMessageBox::warning( 0, "Add Trigger", "<p>Can't add trigger without at least one selected trigger type</p>", "&Sorry", 0 );
87 return; 87 return;
88 } 88 }
89 89
90 QString filename = OFileDialog::getOpenFileName( OFileSelector::ExtendedAll ); 90 QString filename = OFileDialog::getOpenFileName( OFileSelector::ExtendedAll );
91 if ( !filename.isEmpty() ) 91 if ( !filename.isEmpty() )
92 { 92 {
93 bool success = true; 93 bool success = true;
94 odebug << "Filename = " << filename << oendl; 94 odebug << "Filename = " << filename << oendl;
95 95
96 int fntype = m; 96 int fntype = m;
97 QString modifier = QString().sprintf( " = 0x%08x", fntype ); 97 QString modifier = QString().sprintf( " = 0x%08x", fntype );
98 98
99 if ( QFileInfo( filename ).isFile() ) 99 if ( QFileInfo( filename ).isFile() )
100 { 100 {
101 if ( !multi ) 101 if ( !multi )
102 { 102 {
103 success = OFileNotification::singleShot( filename, this, SLOT( unnamedTrigger() ), (OFileNotificationType) fntype ); 103 success = OFileNotification::singleShot( filename, this, SLOT(unnamedTrigger()), (OFileNotificationType) fntype );
104 } 104 }
105 else 105 else
106 { 106 {
107 OFileNotification* fn = new OFileNotification(); 107 OFileNotification* fn = new OFileNotification();
108 success = fn->watch( filename, false, (OFileNotificationType) fntype ); 108 success = fn->watch( filename, false, (OFileNotificationType) fntype );
109 connect( fn, SIGNAL( triggered( const QString& ) ), this, SLOT( namedTrigger( const QString& ) ) ); 109 connect( fn, SIGNAL(triggered(const QString&,unsigned int,const QString&)),
110 } 110 this, SLOT(namedTrigger(const QString&,unsigned int,const QString&)) );
111 }
111 } 112 }
112 else if ( QFileInfo( filename ).isDir() ) 113 else if ( QFileInfo( filename ).isDir() )
113 { 114 {
114 ODirNotification* dn = new ODirNotification(); 115 ODirNotification* dn = new ODirNotification();
115 success = dn->watch( filename, !multi, (OFileNotificationType) fntype ); 116 success = dn->watch( filename, !multi, (OFileNotificationType) fntype );
116 connect( dn, SIGNAL( triggered( const QString& ) ), this, SLOT( namedTrigger( const QString& ) ) ); 117 connect( dn, SIGNAL(triggered(const QString&,unsigned int,const QString&)),
118 this, SLOT(namedTrigger(const QString&,unsigned int,const QString&)) );
117 } 119 }
118 else 120 else
119 { 121 {
120 odebug << "Huh!? Neither file nor directory..." << oendl; 122 odebug << "Huh!? Neither file nor directory..." << oendl;
121 return; 123 return;
122 } 124 }
123 125
124/* if ( !success ) 126/* if ( !success )
125 { 127 {
126 QMessageBox::warning( 0, "Add Trigger", "<p>Couldn't add trigger :(</p>", "&Sorry", 0 ); 128 QMessageBox::warning( 0, "Add Trigger", "<p>Couldn't add trigger :(</p>", "&Sorry", 0 );
127 return; 129 return;
128 } 130 }
129 else 131 else
130*/ { 132*/ {
131 new OListViewItem( l, filename, multi ? "MULTI" : "SINGLE", modifier ); 133 new OListViewItem( l, filename, multi ? "MULTI" : "SINGLE", modifier );
132 } 134 }
133 return; 135 return;
134 } 136 }
135 else 137 else
136 { 138 {
137 odebug << "cancelled." << oendl; 139 odebug << "cancelled." << oendl;
138 } 140 }
139 } 141 }
140 142
141 void DemoApp::modifierClicked( int modifier ) { m = static_cast<OFileNotificationType>( (int)m ^ int(modifier) ); }; 143 void DemoApp::modifierClicked( int modifier ) { m = static_cast<OFileNotificationType>( (int)m ^ int(modifier) ); };
142 void DemoApp::addSingle() { addTrigger(); }; 144 void DemoApp::addSingle() { addTrigger(); };
143 void DemoApp::addMulti() { addTrigger( true ); }; 145 void DemoApp::addMulti() { addTrigger( true ); };
144 146
145 void DemoApp::delTrigger() 147 void DemoApp::delTrigger()
146 { 148 {
147 QListViewItem* item = l->selectedItem(); 149 QListViewItem* item = l->selectedItem();
148 if ( !item ) 150 if ( !item )
149 { 151 {
150 QMessageBox::warning( 0, "Del Trigger", "<p>No trigger selected!</p>", "&Sorry", 0 ); 152 QMessageBox::warning( 0, "Del Trigger", "<p>No trigger selected!</p>", "&Sorry", 0 );
151 return; 153 return;
152 } 154 }
153 else 155 else
154 { 156 {
155 QString filename( item->text( 0 ) ); 157 QString filename( item->text( 0 ) );
156 odebug << "Filename = " << filename << oendl; 158 odebug << "Filename = " << filename << oendl;
157 } 159 }
158 } 160 }
159 161
160 void DemoApp::unnamedTrigger() 162 void DemoApp::unnamedTrigger()
161 { 163 {
162 owarn << "DemoApp::singleShotStrigger() : F I R E !!!!!" << oendl; 164 owarn << "DemoApp::singleShotStrigger() : F I R E !!!!!" << oendl;
163 } 165 }
164 166
165 void DemoApp::namedTrigger( const QString& path ) 167 void DemoApp::namedTrigger( const QString& path, unsigned int type, const QString& name )
166 { 168 {
167 owarn << "DemoApp::named trigger = " << path << " : F I R E !!!!!" << oendl; 169 owarn << "DemoApp::named trigger = ( " << path << ", " << type << ", " << name << " ) : F I R E !!!!!" << oendl;
168 } 170 }
169 171
170int main( int argc, char** argv ) 172int main( int argc, char** argv )
171{ 173{
172 DemoApp* app = new DemoApp( argc, argv ); 174 DemoApp* app = new DemoApp( argc, argv );
173 app->exec(); 175 app->exec();
174 176
175 return 0; 177 return 0;
176 178
177} 179}
178 180
diff --git a/examples/opiecore/onotifydemo/onotifydemo.h b/examples/opiecore/onotifydemo/onotifydemo.h
index f6ac5ea..20019e4 100644
--- a/examples/opiecore/onotifydemo/onotifydemo.h
+++ b/examples/opiecore/onotifydemo/onotifydemo.h
@@ -1,30 +1,30 @@
1/* OPIE */ 1/* OPIE */
2#include <opie2/olistview.h> 2#include <opie2/olistview.h>
3#include <opie2/odebug.h> 3#include <opie2/odebug.h>
4#include <opie2/oapplication.h> 4#include <opie2/oapplication.h>
5#include <opie2/ofilenotify.h> 5#include <opie2/ofilenotify.h>
6 6
7class QButtonGroup; 7class QButtonGroup;
8 8
9class DemoApp : public Opie::Core::OApplication 9class DemoApp : public Opie::Core::OApplication
10{ 10{
11 Q_OBJECT 11 Q_OBJECT
12public: 12public:
13 DemoApp( int argc, char** argv ); 13 DemoApp( int argc, char** argv );
14 14
15public: 15public:
16 void addTrigger( bool multi = false ); 16 void addTrigger( bool multi = false );
17public slots: 17public slots:
18 void modifierClicked( int modifier ); 18 void modifierClicked( int modifier );
19 void addSingle(); 19 void addSingle();
20 void addMulti(); 20 void addMulti();
21 void delTrigger(); 21 void delTrigger();
22 void unnamedTrigger(); 22 void unnamedTrigger();
23 void namedTrigger( const QString& name ); 23 void namedTrigger( const QString&, unsigned int, const QString& );
24 24
25private: 25private:
26 Opie::Ui::OListView* l; 26 Opie::Ui::OListView* l;
27 QButtonGroup* g1; 27 QButtonGroup* g1;
28 QButtonGroup* g2; 28 QButtonGroup* g2;
29 Opie::Core::OFileNotificationType m; 29 Opie::Core::OFileNotificationType m;
30}; 30};