Diffstat (limited to 'examples/opiecore/onotifydemo/onotifydemo.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | examples/opiecore/onotifydemo/onotifydemo.cpp | 42 |
1 files changed, 25 insertions, 17 deletions
diff --git a/examples/opiecore/onotifydemo/onotifydemo.cpp b/examples/opiecore/onotifydemo/onotifydemo.cpp index a38ffee..0e84d80 100644 --- a/examples/opiecore/onotifydemo/onotifydemo.cpp +++ b/examples/opiecore/onotifydemo/onotifydemo.cpp | |||
@@ -11,106 +11,114 @@ using namespace Opie::Ui; | |||
11 | 11 | ||
12 | /* QT */ | 12 | /* QT */ |
13 | #include <qcheckbox.h> | 13 | #include <qcheckbox.h> |
14 | #include <qvbox.h> | 14 | #include <qvbox.h> |
15 | #include <qhbox.h> | 15 | #include <qhbox.h> |
16 | #include <qhbuttongroup.h> | 16 | #include <qhbuttongroup.h> |
17 | #include <qvbuttongroup.h> | 17 | #include <qvbuttongroup.h> |
18 | #include <qmessagebox.h> | 18 | #include <qmessagebox.h> |
19 | #include <qpushbutton.h> | 19 | #include <qpushbutton.h> |
20 | 20 | ||
21 | DemoApp::DemoApp( int argc, char** argv ) : OApplication( argc, argv, "libopie2 notify demo" ) | 21 | DemoApp::DemoApp( int argc, char** argv ) : OApplication( argc, argv, "libopie2 notify demo" ) |
22 | { | 22 | { |
23 | 23 | ||
24 | QVBox* vbox = new QVBox(); | 24 | QVBox* vbox = new QVBox(); |
25 | setMainWidget( vbox ); | 25 | setMainWidget( vbox ); |
26 | 26 | ||
27 | l = new OListView( vbox ); | 27 | l = new OListView( vbox ); |
28 | l->addColumn( "Notification Path" ); | 28 | l->addColumn( "Notification Path" ); |
29 | l->addColumn( "Trigger Type" ); | 29 | l->addColumn( "Trigger Type" ); |
30 | l->addColumn( "Trigger Mask" ); | 30 | l->addColumn( "Trigger Mask" ); |
31 | l->setColumnAlignment( 1, AlignCenter ); | 31 | l->setColumnAlignment( 1, AlignCenter ); |
32 | l->setColumnAlignment( 2, AlignCenter ); | 32 | l->setColumnAlignment( 2, AlignCenter ); |
33 | 33 | ||
34 | QHBox* hbox = new QHBox( vbox ); | 34 | QHBox* hbox = new QHBox( vbox ); |
35 | |||
36 | g2 = new QVButtonGroup( "Specify Trigger Type", hbox ); | 35 | g2 = new QVButtonGroup( "Specify Trigger Type", hbox ); |
37 | //QCheckBox* c1 = new QCheckBox( "Multi", g2 ); | 36 | QCheckBox* c1 = new QCheckBox( "Access", g2 ); |
38 | QCheckBox* c2 = new QCheckBox( "Access", g2 ); | 37 | QCheckBox* c2 = new QCheckBox( "Modify", g2 ); |
39 | QCheckBox* c3 = new QCheckBox( "Modify", g2 ); | 38 | QCheckBox* c3 = new QCheckBox( "Attrib", g2 ); |
40 | QCheckBox* c4 = new QCheckBox( "Create", g2 ); | 39 | QCheckBox* c4 = new QCheckBox( "CloseWrite", g2 ); |
41 | QCheckBox* c5 = new QCheckBox( "Delete", g2 ); | 40 | QCheckBox* c5 = new QCheckBox( "CloseNoWrite", g2 ); |
42 | QCheckBox* c6 = new QCheckBox( "Rename", g2 ); | 41 | QCheckBox* c6 = new QCheckBox( "MovedFrom", g2 ); |
43 | QCheckBox* c7 = new QCheckBox( "Attrib", g2 ); | 42 | QCheckBox* c7 = new QCheckBox( "MovedTo", g2 ); |
44 | g2->insert( c2, Access ); | 43 | QCheckBox* c8 = new QCheckBox( "DeleteSubdir", g2 ); |
45 | g2->insert( c3, Modify ); | 44 | QCheckBox* c9 = new QCheckBox( "DeleteFile", g2 ); |
46 | g2->insert( c4, Create ); | 45 | QCheckBox* c10 = new QCheckBox( "CreateSubdir", g2 ); |
47 | g2->insert( c5, Delete ); | 46 | QCheckBox* c11 = new QCheckBox( "CreateFile", g2 ); |
48 | g2->insert( c6, Rename ); | 47 | QCheckBox* c12 = new QCheckBox( "Unmount", g2 ); |
49 | g2->insert( c7, Attrib ); | 48 | g2->insert( c1, Access ); |
49 | g2->insert( c2, Modify ); | ||
50 | g2->insert( c3, Attrib ); | ||
51 | g2->insert( c4, CloseWrite ); | ||
52 | g2->insert( c5, CloseNoWrite ); | ||
53 | g2->insert( c6, MovedFrom ); | ||
54 | g2->insert( c7, MovedTo ); | ||
55 | g2->insert( c8, DeleteSubdir ); | ||
56 | g2->insert( c9, DeleteFile ); | ||
57 | g2->insert( c10, CreateSubdir ); | ||
58 | g2->insert( c11, CreateFile ); | ||
59 | g2->insert( c12, Unmount ); | ||
50 | connect( g2, SIGNAL( pressed(int) ), this, SLOT( modifierClicked(int) ) ); | 60 | connect( g2, SIGNAL( pressed(int) ), this, SLOT( modifierClicked(int) ) ); |
51 | 61 | ||
52 | g1 = new QVButtonGroup( "Add/Remove", hbox ); | 62 | g1 = new QVButtonGroup( "Add/Remove", hbox ); |
53 | QPushButton* plus1 = new QPushButton( "Add\n&Single", g1 ); | 63 | QPushButton* plus1 = new QPushButton( "Add\n&Single", g1 ); |
54 | QPushButton* plus2 = new QPushButton( "Add\n&Multi", g1 ); | 64 | QPushButton* plus2 = new QPushButton( "Add\n&Multi", g1 ); |
55 | QPushButton* minus = new QPushButton( "&Remove\nIt!", g1 ); | 65 | QPushButton* minus = new QPushButton( "&Remove\nIt!", g1 ); |
56 | g1->insert( plus1, 0 ); | 66 | g1->insert( plus1, 0 ); |
57 | g1->insert( plus2, 1 ); | 67 | g1->insert( plus2, 1 ); |
58 | g1->insert( minus, 2 ); | 68 | g1->insert( minus, 2 ); |
59 | connect( plus1, SIGNAL( clicked() ), this, SLOT( addSingle() ) ); | 69 | connect( plus1, SIGNAL( clicked() ), this, SLOT( addSingle() ) ); |
60 | connect( plus2, SIGNAL( clicked() ), this, SLOT( addMulti() ) ); | 70 | connect( plus2, SIGNAL( clicked() ), this, SLOT( addMulti() ) ); |
61 | connect( minus, SIGNAL( clicked() ), this, SLOT( delTrigger() ) ); | 71 | connect( minus, SIGNAL( clicked() ), this, SLOT( delTrigger() ) ); |
62 | 72 | ||
63 | g1->show(); | 73 | g1->show(); |
64 | g2->show(); | 74 | g2->show(); |
65 | l->show(); | 75 | l->show(); |
66 | hbox->show(); | 76 | hbox->show(); |
67 | vbox->show(); | 77 | vbox->show(); |
68 | showMainWidget( vbox ); | 78 | showMainWidget( vbox ); |
69 | } | 79 | } |
70 | 80 | ||
71 | void DemoApp::addTrigger( bool multi ) | 81 | void DemoApp::addTrigger( bool multi ) |
72 | { | 82 | { |
73 | if ( !m ) | 83 | if ( !m ) |
74 | { | 84 | { |
75 | QMessageBox::warning( 0, "Add Trigger", "<p>Can't add trigger without at least one selected trigger type</p>", "&Sorry", 0 ); | 85 | QMessageBox::warning( 0, "Add Trigger", "<p>Can't add trigger without at least one selected trigger type</p>", "&Sorry", 0 ); |
76 | return; | 86 | return; |
77 | } | 87 | } |
78 | 88 | ||
79 | QString filename = OFileDialog::getOpenFileName( OFileSelector::ExtendedAll ); | 89 | QString filename = OFileDialog::getOpenFileName( OFileSelector::ExtendedAll ); |
80 | if ( !filename.isEmpty() ) | 90 | if ( !filename.isEmpty() ) |
81 | { | 91 | { |
82 | odebug << "Filename = " << filename << oendl; | 92 | odebug << "Filename = " << filename << oendl; |
83 | 93 | ||
84 | int fntype = m; | 94 | int fntype = m; |
85 | if ( multi ) fntype |=(int) Multi; | ||
86 | |||
87 | QString modifier = QString().sprintf( " = 0x%08x", fntype ); | 95 | QString modifier = QString().sprintf( " = 0x%08x", fntype ); |
88 | new OListViewItem( l, filename, multi ? "MULTI" : "SINGLE", modifier ); | 96 | new OListViewItem( l, filename, multi ? "MULTI" : "SINGLE", modifier ); |
89 | if ( !multi ) | 97 | if ( !multi ) |
90 | OFileNotification::singleShot( filename, this, SLOT( trigger() ), (OFileNotificationType) fntype ); | 98 | OFileNotification::singleShot( filename, this, SLOT( trigger() ), (OFileNotificationType) fntype ); |
91 | else | 99 | else |
92 | OFileNotification::singleShot( filename, this, SLOT( trigger() ), (OFileNotificationType) fntype ); | 100 | odebug << "not yet implemented..." << oendl; |
93 | } | 101 | } |
94 | else | 102 | else |
95 | { | 103 | { |
96 | odebug << "cancelled." << oendl; | 104 | odebug << "cancelled." << oendl; |
97 | } | 105 | } |
98 | } | 106 | } |
99 | 107 | ||
100 | void DemoApp::modifierClicked( int modifier ) { m = static_cast<OFileNotificationType>( (int)m ^ int(modifier) ); }; | 108 | void DemoApp::modifierClicked( int modifier ) { m = static_cast<OFileNotificationType>( (int)m ^ int(modifier) ); }; |
101 | void DemoApp::addSingle() { addTrigger(); }; | 109 | void DemoApp::addSingle() { addTrigger(); }; |
102 | void DemoApp::addMulti() { addTrigger( true ); }; | 110 | void DemoApp::addMulti() { addTrigger( true ); }; |
103 | 111 | ||
104 | void DemoApp::delTrigger() | 112 | void DemoApp::delTrigger() |
105 | { | 113 | { |
106 | QListViewItem* item = l->selectedItem(); | 114 | QListViewItem* item = l->selectedItem(); |
107 | if ( !item ) | 115 | if ( !item ) |
108 | { | 116 | { |
109 | QMessageBox::warning( 0, "Del Trigger", "<p>No trigger selected!</p>", "&Sorry", 0 ); | 117 | QMessageBox::warning( 0, "Del Trigger", "<p>No trigger selected!</p>", "&Sorry", 0 ); |
110 | return; | 118 | return; |
111 | } | 119 | } |
112 | else | 120 | else |
113 | { | 121 | { |
114 | QString filename( item->text( 0 ) ); | 122 | QString filename( item->text( 0 ) ); |
115 | odebug << "Filename = " << filename << oendl; | 123 | odebug << "Filename = " << filename << oendl; |
116 | } | 124 | } |