author | mickeyl <mickeyl> | 2005-02-04 16:36:03 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2005-02-04 16:36:03 (UTC) |
commit | 5398d63dbd79eb166ab1c36517f60c6e850a2ca7 (patch) (unidiff) | |
tree | 503eb66f8295f4592c1fb2029c6ab0fa2225a2aa | |
parent | 41886a2bfe003d715ad8fe48011d054c2ba0a779 (diff) | |
download | opie-5398d63dbd79eb166ab1c36517f60c6e850a2ca7.zip opie-5398d63dbd79eb166ab1c36517f60c6e850a2ca7.tar.gz opie-5398d63dbd79eb166ab1c36517f60c6e850a2ca7.tar.bz2 |
improve coding style
-rw-r--r-- | examples/opiecore/onotifydemo/onotifydemo.cpp | 30 | ||||
-rw-r--r-- | examples/opiecore/onotifydemo/onotifydemo.h | 29 | ||||
-rw-r--r-- | examples/opiecore/onotifydemo/onotifydemo.pro | 2 |
3 files changed, 39 insertions, 22 deletions
diff --git a/examples/opiecore/onotifydemo/onotifydemo.cpp b/examples/opiecore/onotifydemo/onotifydemo.cpp index b9ff9db..a38ffee 100644 --- a/examples/opiecore/onotifydemo/onotifydemo.cpp +++ b/examples/opiecore/onotifydemo/onotifydemo.cpp | |||
@@ -1,35 +1,33 @@ | |||
1 | #include "onotifydemo.h" | ||
2 | |||
1 | /* OPIE */ | 3 | /* OPIE */ |
2 | #include <opie2/odebug.h> | 4 | #include <opie2/odebug.h> |
3 | #include <opie2/oapplication.h> | 5 | #include <opie2/oapplication.h> |
4 | #include <opie2/ofiledialog.h> | 6 | #include <opie2/ofiledialog.h> |
5 | #include <opie2/olistview.h> | 7 | #include <opie2/olistview.h> |
6 | #include <opie2/ofilenotify.h> | 8 | #include <opie2/ofilenotify.h> |
7 | using namespace Opie::Core; | 9 | using namespace Opie::Core; |
8 | using namespace Opie::Ui; | 10 | using namespace Opie::Ui; |
9 | 11 | ||
10 | /* QT */ | 12 | /* QT */ |
11 | #include <qcheckbox.h> | 13 | #include <qcheckbox.h> |
12 | #include <qvbox.h> | 14 | #include <qvbox.h> |
13 | #include <qhbox.h> | 15 | #include <qhbox.h> |
14 | #include <qhbuttongroup.h> | 16 | #include <qhbuttongroup.h> |
15 | #include <qvbuttongroup.h> | 17 | #include <qvbuttongroup.h> |
16 | #include <qmessagebox.h> | 18 | #include <qmessagebox.h> |
17 | #include <qpushbutton.h> | 19 | #include <qpushbutton.h> |
18 | 20 | ||
19 | class DemoApp : public OApplication | 21 | DemoApp::DemoApp( int argc, char** argv ) : OApplication( argc, argv, "libopie2 notify demo" ) |
20 | { | ||
21 | Q_OBJECT | ||
22 | public: | ||
23 | DemoApp( int argc, char** argv ) : OApplication( argc, argv, "libopie2 notify demo" ) | ||
24 | { | 22 | { |
25 | 23 | ||
26 | QVBox* vbox = new QVBox(); | 24 | QVBox* vbox = new QVBox(); |
27 | setMainWidget( vbox ); | 25 | setMainWidget( vbox ); |
28 | 26 | ||
29 | l = new OListView( vbox ); | 27 | l = new OListView( vbox ); |
30 | l->addColumn( "Notification Path" ); | 28 | l->addColumn( "Notification Path" ); |
31 | l->addColumn( "Trigger Type" ); | 29 | l->addColumn( "Trigger Type" ); |
32 | l->addColumn( "Trigger Mask" ); | 30 | l->addColumn( "Trigger Mask" ); |
33 | l->setColumnAlignment( 1, AlignCenter ); | 31 | l->setColumnAlignment( 1, AlignCenter ); |
34 | l->setColumnAlignment( 2, AlignCenter ); | 32 | l->setColumnAlignment( 2, AlignCenter ); |
35 | 33 | ||
@@ -61,26 +59,25 @@ public: | |||
61 | connect( plus1, SIGNAL( clicked() ), this, SLOT( addSingle() ) ); | 59 | connect( plus1, SIGNAL( clicked() ), this, SLOT( addSingle() ) ); |
62 | connect( plus2, SIGNAL( clicked() ), this, SLOT( addMulti() ) ); | 60 | connect( plus2, SIGNAL( clicked() ), this, SLOT( addMulti() ) ); |
63 | connect( minus, SIGNAL( clicked() ), this, SLOT( delTrigger() ) ); | 61 | connect( minus, SIGNAL( clicked() ), this, SLOT( delTrigger() ) ); |
64 | 62 | ||
65 | g1->show(); | 63 | g1->show(); |
66 | g2->show(); | 64 | g2->show(); |
67 | l->show(); | 65 | l->show(); |
68 | hbox->show(); | 66 | hbox->show(); |
69 | vbox->show(); | 67 | vbox->show(); |
70 | showMainWidget( vbox ); | 68 | showMainWidget( vbox ); |
71 | } | 69 | } |
72 | 70 | ||
73 | public: | 71 | void DemoApp::addTrigger( bool multi ) |
74 | void addTrigger( bool multi = false ) | ||
75 | { | 72 | { |
76 | if ( !m ) | 73 | if ( !m ) |
77 | { | 74 | { |
78 | QMessageBox::warning( 0, "Add Trigger", "<p>Can't add trigger without at least one selected trigger type</p>", "&Sorry", 0 ); | 75 | QMessageBox::warning( 0, "Add Trigger", "<p>Can't add trigger without at least one selected trigger type</p>", "&Sorry", 0 ); |
79 | return; | 76 | return; |
80 | } | 77 | } |
81 | 78 | ||
82 | QString filename = OFileDialog::getOpenFileName( OFileSelector::ExtendedAll ); | 79 | QString filename = OFileDialog::getOpenFileName( OFileSelector::ExtendedAll ); |
83 | if ( !filename.isEmpty() ) | 80 | if ( !filename.isEmpty() ) |
84 | { | 81 | { |
85 | odebug << "Filename = " << filename << oendl; | 82 | odebug << "Filename = " << filename << oendl; |
86 | 83 | ||
@@ -91,54 +88,45 @@ public: | |||
91 | new OListViewItem( l, filename, multi ? "MULTI" : "SINGLE", modifier ); | 88 | new OListViewItem( l, filename, multi ? "MULTI" : "SINGLE", modifier ); |
92 | if ( !multi ) | 89 | if ( !multi ) |
93 | OFileNotification::singleShot( filename, this, SLOT( trigger() ), (OFileNotificationType) fntype ); | 90 | OFileNotification::singleShot( filename, this, SLOT( trigger() ), (OFileNotificationType) fntype ); |
94 | else | 91 | else |
95 | OFileNotification::singleShot( filename, this, SLOT( trigger() ), (OFileNotificationType) fntype ); | 92 | OFileNotification::singleShot( filename, this, SLOT( trigger() ), (OFileNotificationType) fntype ); |
96 | } | 93 | } |
97 | else | 94 | else |
98 | { | 95 | { |
99 | odebug << "cancelled." << oendl; | 96 | odebug << "cancelled." << oendl; |
100 | } | 97 | } |
101 | } | 98 | } |
102 | 99 | ||
103 | public slots: | 100 | void DemoApp::modifierClicked( int modifier ) { m = static_cast<OFileNotificationType>( (int)m ^ int(modifier) ); }; |
104 | void modifierClicked( int modifier ) { m = static_cast<OFileNotificationType>( (int)m ^ int(modifier) ); }; | 101 | void DemoApp::addSingle() { addTrigger(); }; |
105 | void addSingle() { addTrigger(); }; | 102 | void DemoApp::addMulti() { addTrigger( true ); }; |
106 | void addMulti() { addTrigger( true ); }; | ||
107 | 103 | ||
108 | void delTrigger() | 104 | void DemoApp::delTrigger() |
109 | { | 105 | { |
110 | QListViewItem* item = l->selectedItem(); | 106 | QListViewItem* item = l->selectedItem(); |
111 | if ( !item ) | 107 | if ( !item ) |
112 | { | 108 | { |
113 | QMessageBox::warning( 0, "Del Trigger", "<p>No trigger selected!</p>", "&Sorry", 0 ); | 109 | QMessageBox::warning( 0, "Del Trigger", "<p>No trigger selected!</p>", "&Sorry", 0 ); |
114 | return; | 110 | return; |
115 | } | 111 | } |
116 | else | 112 | else |
117 | { | 113 | { |
118 | QString filename( item->text( 0 ) ); | 114 | QString filename( item->text( 0 ) ); |
119 | odebug << "Filename = " << filename << oendl; | 115 | odebug << "Filename = " << filename << oendl; |
120 | } | 116 | } |
121 | } | 117 | } |
122 | 118 | ||
123 | void trigger() | 119 | void DemoApp::trigger() |
124 | { | 120 | { |
125 | owarn << "FIRE!" << oendl; | 121 | owarn << "FIRE!" << oendl; |
126 | } | 122 | } |
127 | 123 | ||
128 | private: | ||
129 | OListView* l; | ||
130 | QButtonGroup* g1; | ||
131 | QButtonGroup* g2; | ||
132 | OFileNotificationType m; | ||
133 | }; | ||
134 | |||
135 | int main( int argc, char** argv ) | 124 | int main( int argc, char** argv ) |
136 | { | 125 | { |
137 | DemoApp* app = new DemoApp( argc, argv ); | 126 | DemoApp* app = new DemoApp( argc, argv ); |
138 | app->exec(); | 127 | app->exec(); |
139 | 128 | ||
140 | return 0; | 129 | return 0; |
141 | 130 | ||
142 | } | 131 | } |
143 | 132 | ||
144 | #include "moc/onotifydemo.moc" | ||
diff --git a/examples/opiecore/onotifydemo/onotifydemo.h b/examples/opiecore/onotifydemo/onotifydemo.h new file mode 100644 index 0000000..c4e3456 --- a/dev/null +++ b/examples/opiecore/onotifydemo/onotifydemo.h | |||
@@ -0,0 +1,29 @@ | |||
1 | /* OPIE */ | ||
2 | #include <opie2/olistview.h> | ||
3 | #include <opie2/odebug.h> | ||
4 | #include <opie2/oapplication.h> | ||
5 | #include <opie2/ofilenotify.h> | ||
6 | |||
7 | class QButtonGroup; | ||
8 | |||
9 | class DemoApp : public Opie::Core::OApplication | ||
10 | { | ||
11 | Q_OBJECT | ||
12 | public: | ||
13 | DemoApp( int argc, char** argv ); | ||
14 | |||
15 | public: | ||
16 | void addTrigger( bool multi = false ); | ||
17 | public slots: | ||
18 | void modifierClicked( int modifier ); | ||
19 | void addSingle(); | ||
20 | void addMulti(); | ||
21 | void delTrigger(); | ||
22 | void trigger(); | ||
23 | |||
24 | private: | ||
25 | Opie::Ui::OListView* l; | ||
26 | QButtonGroup* g1; | ||
27 | QButtonGroup* g2; | ||
28 | Opie::Core::OFileNotificationType m; | ||
29 | }; | ||
diff --git a/examples/opiecore/onotifydemo/onotifydemo.pro b/examples/opiecore/onotifydemo/onotifydemo.pro index 1c1040c..8e7e487 100644 --- a/examples/opiecore/onotifydemo/onotifydemo.pro +++ b/examples/opiecore/onotifydemo/onotifydemo.pro | |||
@@ -1,15 +1,15 @@ | |||
1 | TEMPLATE = app | 1 | TEMPLATE = app |
2 | CONFIG = qt warn_on | 2 | CONFIG = qt warn_on |
3 | HEADERS = | 3 | HEADERS = onotifydemo.h |
4 | SOURCES = onotifydemo.cpp | 4 | SOURCES = onotifydemo.cpp |
5 | INCLUDEPATH += $(OPIEDIR)/include | 5 | INCLUDEPATH += $(OPIEDIR)/include |
6 | DEPENDPATH += $(OPIEDIR)/include | 6 | DEPENDPATH += $(OPIEDIR)/include |
7 | LIBS += -lopiecore2 -lopieui2 | 7 | LIBS += -lopiecore2 -lopieui2 |
8 | TARGET = onotifydemo | 8 | TARGET = onotifydemo |
9 | 9 | ||
10 | !contains( platform, x11 ) { | 10 | !contains( platform, x11 ) { |
11 | include( $(OPIEDIR)/include.pro ) | 11 | include( $(OPIEDIR)/include.pro ) |
12 | } | 12 | } |
13 | 13 | ||
14 | contains( platform, x11 ) { | 14 | contains( platform, x11 ) { |
15 | LIBS += -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib | 15 | LIBS += -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib |