-rw-r--r-- | libopie2/examples/opiecore/onotifydemo/onotifydemo.cpp | 43 |
1 files changed, 34 insertions, 9 deletions
diff --git a/libopie2/examples/opiecore/onotifydemo/onotifydemo.cpp b/libopie2/examples/opiecore/onotifydemo/onotifydemo.cpp index a8a5717..74a8158 100644 --- a/libopie2/examples/opiecore/onotifydemo/onotifydemo.cpp +++ b/libopie2/examples/opiecore/onotifydemo/onotifydemo.cpp | |||
@@ -8,12 +8,13 @@ using namespace Opie::Core; | |||
8 | using namespace Opie::Ui; | 8 | using namespace Opie::Ui; |
9 | 9 | ||
10 | /* QT */ | 10 | /* QT */ |
11 | #include <qcheckbox.h> | ||
11 | #include <qvbox.h> | 12 | #include <qvbox.h> |
12 | #include <qhbox.h> | 13 | #include <qhbox.h> |
13 | #include <qhbuttongroup.h> | 14 | #include <qhbuttongroup.h> |
14 | #include <qvbuttongroup.h> | 15 | #include <qvbuttongroup.h> |
16 | #include <qmessagebox.h> | ||
15 | #include <qpushbutton.h> | 17 | #include <qpushbutton.h> |
16 | #include <qcheckbox.h> | ||
17 | 18 | ||
18 | class DemoApp : public OApplication | 19 | class DemoApp : public OApplication |
19 | { | 20 | { |
@@ -27,7 +28,10 @@ public: | |||
27 | 28 | ||
28 | l = new OListView( vbox ); | 29 | l = new OListView( vbox ); |
29 | l->addColumn( "Notification Path" ); | 30 | l->addColumn( "Notification Path" ); |
30 | l->addColumn( "Trigger" ); | 31 | l->addColumn( "Trigger Type" ); |
32 | l->addColumn( "Trigger Mask" ); | ||
33 | l->setColumnAlignment( 1, AlignCenter ); | ||
34 | l->setColumnAlignment( 2, AlignCenter ); | ||
31 | 35 | ||
32 | QHBox* hbox = new QHBox( vbox ); | 36 | QHBox* hbox = new QHBox( vbox ); |
33 | 37 | ||
@@ -45,6 +49,7 @@ public: | |||
45 | g2->insert( c5, Delete ); | 49 | g2->insert( c5, Delete ); |
46 | g2->insert( c6, Rename ); | 50 | g2->insert( c6, Rename ); |
47 | g2->insert( c7, Attrib ); | 51 | g2->insert( c7, Attrib ); |
52 | connect( g2, SIGNAL( pressed(int) ), this, SLOT( modifierClicked(int) ) ); | ||
48 | 53 | ||
49 | g1 = new QVButtonGroup( "Add/Remove", hbox ); | 54 | g1 = new QVButtonGroup( "Add/Remove", hbox ); |
50 | QPushButton* plus1 = new QPushButton( "Add\n&Single", g1 ); | 55 | QPushButton* plus1 = new QPushButton( "Add\n&Single", g1 ); |
@@ -68,15 +73,26 @@ public: | |||
68 | public: | 73 | public: |
69 | void addTrigger( bool multi = false ) | 74 | void addTrigger( bool multi = false ) |
70 | { | 75 | { |
76 | if ( !m ) | ||
77 | { | ||
78 | QMessageBox::warning( 0, "Add Trigger", "<p>Can't add trigger without at least one selected trigger type</p>", "&Sorry", 0 ); | ||
79 | return; | ||
80 | } | ||
81 | |||
71 | QString filename = OFileDialog::getOpenFileName( OFileSelector::ExtendedAll ); | 82 | QString filename = OFileDialog::getOpenFileName( OFileSelector::ExtendedAll ); |
72 | if ( !filename.isEmpty() ) | 83 | if ( !filename.isEmpty() ) |
73 | { | 84 | { |
74 | odebug << "Filename = " << filename << oendl; | 85 | odebug << "Filename = " << filename << oendl; |
75 | new OListViewItem( l, filename, "Modify" ); | ||
76 | |||
77 | 86 | ||
87 | int fntype = m; | ||
88 | if ( multi ) fntype |=(int) Multi; | ||
78 | 89 | ||
79 | OFileNotifier::singleShot( filename, this, SLOT( trigger() ) ); | 90 | QString modifier = QString().sprintf( " = 0x%08x", fntype ); |
91 | new OListViewItem( l, filename, multi ? "MULTI" : "SINGLE", modifier ); | ||
92 | if ( !multi ) | ||
93 | OFileNotification::singleShot( filename, this, SLOT( trigger() ), (OFileNotificationType) fntype ); | ||
94 | else | ||
95 | OFileNotification::singleShot( filename, this, SLOT( trigger() ), (OFileNotificationType) fntype ); | ||
80 | } | 96 | } |
81 | else | 97 | else |
82 | { | 98 | { |
@@ -85,14 +101,23 @@ public: | |||
85 | } | 101 | } |
86 | 102 | ||
87 | public slots: | 103 | public slots: |
88 | 104 | void modifierClicked( int modifier ) { (int)m ^= modifier; }; | |
89 | void addSingle() { addTrigger(); }; | 105 | void addSingle() { addTrigger(); }; |
90 | void addMulti() { addTrigger( true ); }; | 106 | void addMulti() { addTrigger( true ); }; |
91 | 107 | ||
92 | void delTrigger() | 108 | void delTrigger() |
93 | { | 109 | { |
94 | QString filename( "bla" ); | 110 | QListViewItem* item = l->selectedItem(); |
95 | odebug << "Filename = " << filename << oendl; | 111 | if ( !item ) |
112 | { | ||
113 | QMessageBox::warning( 0, "Del Trigger", "<p>No trigger selected!</p>", "&Sorry", 0 ); | ||
114 | return; | ||
115 | } | ||
116 | else | ||
117 | { | ||
118 | QString filename( item->text( 0 ) ); | ||
119 | odebug << "Filename = " << filename << oendl; | ||
120 | } | ||
96 | } | 121 | } |
97 | 122 | ||
98 | void trigger() | 123 | void trigger() |
@@ -104,7 +129,7 @@ private: | |||
104 | OListView* l; | 129 | OListView* l; |
105 | QButtonGroup* g1; | 130 | QButtonGroup* g1; |
106 | QButtonGroup* g2; | 131 | QButtonGroup* g2; |
107 | int m; | 132 | OFileNotificationType m; |
108 | }; | 133 | }; |
109 | 134 | ||
110 | int main( int argc, char** argv ) | 135 | int main( int argc, char** argv ) |