author | eilers <eilers> | 2003-08-08 15:09:29 (UTC) |
---|---|---|
committer | eilers <eilers> | 2003-08-08 15:09:29 (UTC) |
commit | b87b33dc1f6e8e1276a7035ab7a3e53b8ed4bd16 (patch) (unidiff) | |
tree | b0f96db67cfb1b9d2476530ecec9a2ba6eacbab1 | |
parent | 14d394e6c107b037a09a31a92605034fe50f7813 (diff) | |
download | opie-b87b33dc1f6e8e1276a7035ab7a3e53b8ed4bd16.zip opie-b87b33dc1f6e8e1276a7035ab7a3e53b8ed4bd16.tar.gz opie-b87b33dc1f6e8e1276a7035ab7a3e53b8ed4bd16.tar.bz2 |
Merging all changes from BRANCH_1_0.
-rw-r--r-- | libopie/libopie.pro | 3 | ||||
-rw-r--r-- | libopie/libopie1.control | 4 | ||||
-rw-r--r-- | libopie/odevice.cpp | 111 | ||||
-rw-r--r-- | libopie/ofiledialog.cc | 81 | ||||
-rw-r--r-- | libopie/ofiledialog.h | 3 | ||||
-rw-r--r-- | libopie/ofileselector.cc | 1310 | ||||
-rw-r--r-- | libopie/ofileselector.cpp | 856 | ||||
-rw-r--r-- | libopie/ofileselector.h | 362 | ||||
-rw-r--r-- | libopie/ofileselector_p.h | 151 | ||||
-rw-r--r-- | libopie/orecurrancewidget.cpp | 56 | ||||
-rw-r--r-- | libopie/oticker.h | 4 | ||||
-rw-r--r-- | libopie/todayplugininterface.h | 42 |
12 files changed, 1319 insertions, 1664 deletions
diff --git a/libopie/libopie.pro b/libopie/libopie.pro index 4535c4e..6fbd449 100644 --- a/libopie/libopie.pro +++ b/libopie/libopie.pro | |||
@@ -1,120 +1,121 @@ | |||
1 | TEMPLATE = lib | 1 | TEMPLATE = lib |
2 | CONFIG += qte warn_on release | 2 | CONFIG += qte warn_on release |
3 | HEADERS = ofontmenu.h \ | 3 | HEADERS = ofontmenu.h \ |
4 | ocolorbutton.h \ | 4 | ocolorbutton.h \ |
5 | ofiledialog.h ofileselector.h \ | 5 | ofiledialog.h ofileselector.h \ |
6 | ofileselector_p.h \ | ||
6 | ocheckitem.h \ | 7 | ocheckitem.h \ |
7 | xmltree.h \ | 8 | xmltree.h \ |
8 | colordialog.h colorpopupmenu.h \ | 9 | colordialog.h colorpopupmenu.h \ |
9 | oclickablelabel.h oprocctrl.h \ | 10 | oclickablelabel.h oprocctrl.h \ |
10 | oprocess.h odevice.h odevicebutton.h \ | 11 | oprocess.h odevice.h odevicebutton.h \ |
11 | otimepicker.h otabwidget.h \ | 12 | otimepicker.h otabwidget.h \ |
12 | otabbar.h otabinfo.h \ | 13 | otabbar.h otabinfo.h \ |
13 | ofontselector.h \ | 14 | ofontselector.h \ |
14 | pim/opimrecord.h \ | 15 | pim/opimrecord.h \ |
15 | pim/otodo.h \ | 16 | pim/otodo.h \ |
16 | pim/orecordlist.h \ | 17 | pim/orecordlist.h \ |
17 | pim/opimaccesstemplate.h \ | 18 | pim/opimaccesstemplate.h \ |
18 | pim/opimaccessbackend.h \ | 19 | pim/opimaccessbackend.h \ |
19 | pim/otodoaccess.h \ | 20 | pim/otodoaccess.h \ |
20 | pim/otodoaccessbackend.h \ | 21 | pim/otodoaccessbackend.h \ |
21 | pim/oconversion.h \ | 22 | pim/oconversion.h \ |
22 | pim/ocontact.h \ | 23 | pim/ocontact.h \ |
23 | pim/ocontactaccess.h \ | 24 | pim/ocontactaccess.h \ |
24 | pim/ocontactaccessbackend.h \ | 25 | pim/ocontactaccessbackend.h \ |
25 | pim/ocontactaccessbackend_xml.h \ | 26 | pim/ocontactaccessbackend_xml.h \ |
26 | pim/ocontactaccessbackend_vcard.h \ | 27 | pim/ocontactaccessbackend_vcard.h \ |
27 | pim/obackendfactory.h \ | 28 | pim/obackendfactory.h \ |
28 | pim/opimcache.h \ | 29 | pim/opimcache.h \ |
29 | pim/otodoaccessvcal.h \ | 30 | pim/otodoaccessvcal.h \ |
30 | pim/orecur.h \ | 31 | pim/orecur.h \ |
31 | pim/opimstate.h \ | 32 | pim/opimstate.h \ |
32 | pim/opimxrefpartner.h \ | 33 | pim/opimxrefpartner.h \ |
33 | pim/opimxref.h \ | 34 | pim/opimxref.h \ |
34 | pim/opimxrefmanager.h \ | 35 | pim/opimxrefmanager.h \ |
35 | pim/opimmaintainer.h \ | 36 | pim/opimmaintainer.h \ |
36 | pim/opimnotify.h \ | 37 | pim/opimnotify.h \ |
37 | pim/opimnotifymanager.h \ | 38 | pim/opimnotifymanager.h \ |
38 | pim/opimmainwindow.h \ | 39 | pim/opimmainwindow.h \ |
39 | pim/opimresolver.h \ | 40 | pim/opimresolver.h \ |
40 | pim/oevent.h \ | 41 | pim/oevent.h \ |
41 | pim/otimezone.h \ | 42 | pim/otimezone.h \ |
42 | pim/odatebookaccess.h \ | 43 | pim/odatebookaccess.h \ |
43 | pim/odatebookaccessbackend.h \ | 44 | pim/odatebookaccessbackend.h \ |
44 | pim/odatebookaccessbackend_xml.h \ | 45 | pim/odatebookaccessbackend_xml.h \ |
45 | orecurrancewidget.h \ | 46 | orecurrancewidget.h \ |
46 | oticker.h owait.h | 47 | oticker.h owait.h |
47 | 48 | ||
48 | SOURCES = ofontmenu.cc \ | 49 | SOURCES = ofontmenu.cc \ |
49 | ocolorbutton.cpp \ | 50 | ocolorbutton.cpp \ |
50 | sharp_compat.cpp \ | 51 | sharp_compat.cpp \ |
51 | xmltree.cc \ | 52 | xmltree.cc \ |
52 | ofiledialog.cc ofileselector.cc \ | 53 | ofiledialog.cc ofileselector.cpp \ |
53 | ocheckitem.cpp \ | 54 | ocheckitem.cpp \ |
54 | colordialog.cpp \ | 55 | colordialog.cpp \ |
55 | colorpopupmenu.cpp oclickablelabel.cpp \ | 56 | colorpopupmenu.cpp oclickablelabel.cpp \ |
56 | oprocctrl.cpp oprocess.cpp \ | 57 | oprocctrl.cpp oprocess.cpp \ |
57 | odevice.cpp odevicebutton.cpp otimepicker.cpp \ | 58 | odevice.cpp odevicebutton.cpp otimepicker.cpp \ |
58 | otabwidget.cpp otabbar.cpp \ | 59 | otabwidget.cpp otabbar.cpp \ |
59 | ofontselector.cpp \ | 60 | ofontselector.cpp \ |
60 | pim/otodo.cpp \ | 61 | pim/otodo.cpp \ |
61 | pim/opimrecord.cpp \ | 62 | pim/opimrecord.cpp \ |
62 | pim/otodoaccess.cpp \ | 63 | pim/otodoaccess.cpp \ |
63 | pim/otodoaccessbackend.cpp \ | 64 | pim/otodoaccessbackend.cpp \ |
64 | pim/otodoaccessxml.cpp \ | 65 | pim/otodoaccessxml.cpp \ |
65 | pim/oconversion.cpp \ | 66 | pim/oconversion.cpp \ |
66 | pim/ocontact.cpp \ | 67 | pim/ocontact.cpp \ |
67 | pim/ocontactaccess.cpp \ | 68 | pim/ocontactaccess.cpp \ |
68 | pim/ocontactaccessbackend_vcard.cpp \ | 69 | pim/ocontactaccessbackend_vcard.cpp \ |
69 | pim/ocontactaccessbackend_xml.cpp \ | 70 | pim/ocontactaccessbackend_xml.cpp \ |
70 | pim/otodoaccessvcal.cpp \ | 71 | pim/otodoaccessvcal.cpp \ |
71 | pim/orecur.cpp \ | 72 | pim/orecur.cpp \ |
72 | pim/opimstate.cpp \ | 73 | pim/opimstate.cpp \ |
73 | pim/opimxrefpartner.cpp \ | 74 | pim/opimxrefpartner.cpp \ |
74 | pim/opimxref.cpp \ | 75 | pim/opimxref.cpp \ |
75 | pim/opimxrefmanager.cpp \ | 76 | pim/opimxrefmanager.cpp \ |
76 | pim/opimmaintainer.cpp \ | 77 | pim/opimmaintainer.cpp \ |
77 | pim/opimnotify.cpp \ | 78 | pim/opimnotify.cpp \ |
78 | pim/opimnotifymanager.cpp \ | 79 | pim/opimnotifymanager.cpp \ |
79 | pim/opimmainwindow.cpp \ | 80 | pim/opimmainwindow.cpp \ |
80 | pim/opimresolver.cpp \ | 81 | pim/opimresolver.cpp \ |
81 | pim/oevent.cpp \ | 82 | pim/oevent.cpp \ |
82 | pim/otimezone.cpp \ | 83 | pim/otimezone.cpp \ |
83 | pim/odatebookaccess.cpp \ | 84 | pim/odatebookaccess.cpp \ |
84 | pim/odatebookaccessbackend.cpp \ | 85 | pim/odatebookaccessbackend.cpp \ |
85 | pim/odatebookaccessbackend_xml.cpp \ | 86 | pim/odatebookaccessbackend_xml.cpp \ |
86 | orecurrancewidget.cpp \ | 87 | orecurrancewidget.cpp \ |
87 | oticker.cpp owait.cpp | 88 | oticker.cpp owait.cpp |
88 | 89 | ||
89 | TARGET = opie | 90 | TARGET = opie |
90 | INCLUDEPATH += $(OPIEDIR)/include | 91 | INCLUDEPATH += $(OPIEDIR)/include |
91 | DESTDIR = $(OPIEDIR)/lib$(PROJMAK) | 92 | DESTDIR = $(OPIEDIR)/lib$(PROJMAK) |
92 | 93 | ||
93 | LIBS += -lqpe | 94 | LIBS += -lqpe |
94 | 95 | ||
95 | # LIBS += -lopiesql | 96 | # LIBS += -lopiesql |
96 | 97 | ||
97 | INTERFACES = otimepickerbase.ui orecurrancebase.ui | 98 | INTERFACES = otimepickerbase.ui orecurrancebase.ui |
98 | TARGET = opie | 99 | TARGET = opie |
99 | 100 | ||
100 | TRANSLATIONS = ../i18n/de/libopie.ts \ | 101 | TRANSLATIONS = ../i18n/de/libopie.ts \ |
101 | ../i18n/nl/libopie.ts \ | 102 | ../i18n/nl/libopie.ts \ |
102 | ../i18n/xx/libopie.ts \ | 103 | ../i18n/xx/libopie.ts \ |
103 | ../i18n/en/libopie.ts \ | 104 | ../i18n/en/libopie.ts \ |
104 | ../i18n/es/libopie.ts \ | 105 | ../i18n/es/libopie.ts \ |
105 | ../i18n/fr/libopie.ts \ | 106 | ../i18n/fr/libopie.ts \ |
106 | ../i18n/hu/libopie.ts \ | 107 | ../i18n/hu/libopie.ts \ |
107 | ../i18n/ja/libopie.ts \ | 108 | ../i18n/ja/libopie.ts \ |
108 | ../i18n/ko/libopie.ts \ | 109 | ../i18n/ko/libopie.ts \ |
109 | ../i18n/no/libopie.ts \ | 110 | ../i18n/no/libopie.ts \ |
110 | ../i18n/pl/libopie.ts \ | 111 | ../i18n/pl/libopie.ts \ |
111 | ../i18n/pt/libopie.ts \ | 112 | ../i18n/pt/libopie.ts \ |
112 | ../i18n/pt_BR/libopie.ts \ | 113 | ../i18n/pt_BR/libopie.ts \ |
113 | ../i18n/sl/libopie.ts \ | 114 | ../i18n/sl/libopie.ts \ |
114 | ../i18n/zh_CN/libopie.ts \ | 115 | ../i18n/zh_CN/libopie.ts \ |
115 | ../i18n/zh_TW/libopie.ts \ | 116 | ../i18n/zh_TW/libopie.ts \ |
116 | ../i18n/da/libopie.ts | 117 | ../i18n/da/libopie.ts |
117 | 118 | ||
118 | 119 | ||
119 | 120 | ||
120 | include ( $(OPIEDIR)/include.pro ) | 121 | include ( $(OPIEDIR)/include.pro ) |
diff --git a/libopie/libopie1.control b/libopie/libopie1.control index 1e75df3..76e4c7a 100644 --- a/libopie/libopie1.control +++ b/libopie/libopie1.control | |||
@@ -1,11 +1,11 @@ | |||
1 | Package: libopie1 | 1 | Package: libopie1 |
2 | Files: $OPIEDIR/lib/libopie.so.1.0.0 $OPIEDIR/lib/libopie.so.1.0 $OPIEDIR/lib/libopie.so.1 | 2 | Files: $OPIEDIR/lib/libopie.so.1.0.0 $OPIEDIR/lib/libopie.so.1.0 $OPIEDIR/lib/libopie.so.1 |
3 | Priority: optional | 3 | Priority: optional |
4 | Section: opie/system | 4 | Section: opie/system |
5 | Maintainer: Opie Team <opie@handhelds.org> | 5 | Maintainer: Opie Team <opie@handhelds.org> |
6 | Architecture: arm | 6 | Architecture: arm |
7 | Version: $QPE_VERSION-$SUB_VERSION.1 | 7 | Depends: libqte2 (>=$QTE_VERSION), libqpe1, opie-pics |
8 | Depends: libqte2 (>=$QTE_VERSION), libqpe1 | ||
9 | Provides: libopie | 8 | Provides: libopie |
10 | Replaces: libopie | 9 | Replaces: libopie |
11 | Description: Opie library | 10 | Description: Opie library |
11 | Version: $QPE_VERSION$EXTRAVERSION | ||
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp index 62dc9d4..17ae389 100644 --- a/libopie/odevice.cpp +++ b/libopie/odevice.cpp | |||
@@ -91,2053 +91,2068 @@ public: | |||
91 | 91 | ||
92 | virtual QValueList <OLed> ledList ( ) const; | 92 | virtual QValueList <OLed> ledList ( ) const; |
93 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; | 93 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; |
94 | virtual OLedState ledState ( OLed led ) const; | 94 | virtual OLedState ledState ( OLed led ) const; |
95 | virtual bool setLedState ( OLed led, OLedState st ); | 95 | virtual bool setLedState ( OLed led, OLedState st ); |
96 | 96 | ||
97 | virtual bool hasLightSensor ( ) const; | 97 | virtual bool hasLightSensor ( ) const; |
98 | virtual int readLightSensor ( ); | 98 | virtual int readLightSensor ( ); |
99 | virtual int lightSensorResolution ( ) const; | 99 | virtual int lightSensorResolution ( ) const; |
100 | 100 | ||
101 | protected: | 101 | protected: |
102 | virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); | 102 | virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); |
103 | virtual void timerEvent ( QTimerEvent *te ); | 103 | virtual void timerEvent ( QTimerEvent *te ); |
104 | 104 | ||
105 | int m_power_timer; | 105 | int m_power_timer; |
106 | 106 | ||
107 | OLedState m_leds [2]; | 107 | OLedState m_leds [2]; |
108 | }; | 108 | }; |
109 | 109 | ||
110 | class Zaurus : public ODevice { | 110 | class Zaurus : public ODevice { |
111 | protected: | 111 | protected: |
112 | virtual void init ( ); | 112 | virtual void init ( ); |
113 | virtual void initButtons ( ); | 113 | virtual void initButtons ( ); |
114 | 114 | ||
115 | public: | 115 | public: |
116 | virtual bool setSoftSuspend ( bool soft ); | 116 | virtual bool setSoftSuspend ( bool soft ); |
117 | 117 | ||
118 | virtual bool setDisplayBrightness ( int b ); | 118 | virtual bool setDisplayBrightness ( int b ); |
119 | virtual int displayBrightnessResolution ( ) const; | 119 | virtual int displayBrightnessResolution ( ) const; |
120 | 120 | ||
121 | virtual void alarmSound ( ); | 121 | virtual void alarmSound ( ); |
122 | virtual void keySound ( ); | 122 | virtual void keySound ( ); |
123 | virtual void touchSound ( ); | 123 | virtual void touchSound ( ); |
124 | 124 | ||
125 | virtual QValueList <OLed> ledList ( ) const; | 125 | virtual QValueList <OLed> ledList ( ) const; |
126 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; | 126 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; |
127 | virtual OLedState ledState ( OLed led ) const; | 127 | virtual OLedState ledState ( OLed led ) const; |
128 | virtual bool setLedState ( OLed led, OLedState st ); | 128 | virtual bool setLedState ( OLed led, OLedState st ); |
129 | 129 | ||
130 | protected: | 130 | protected: |
131 | virtual void buzzer ( int snd ); | 131 | virtual void buzzer ( int snd ); |
132 | 132 | ||
133 | OLedState m_leds [1]; | 133 | OLedState m_leds [1]; |
134 | }; | 134 | }; |
135 | 135 | ||
136 | class SIMpad : public ODevice, public QWSServer::KeyboardFilter { | 136 | class SIMpad : public ODevice, public QWSServer::KeyboardFilter { |
137 | protected: | 137 | protected: |
138 | virtual void init ( ); | 138 | virtual void init ( ); |
139 | virtual void initButtons ( ); | 139 | virtual void initButtons ( ); |
140 | 140 | ||
141 | public: | 141 | public: |
142 | virtual bool setSoftSuspend ( bool soft ); | 142 | virtual bool setSoftSuspend ( bool soft ); |
143 | virtual bool suspend(); | 143 | virtual bool suspend(); |
144 | 144 | ||
145 | virtual bool setDisplayStatus( bool on ); | 145 | virtual bool setDisplayStatus( bool on ); |
146 | virtual bool setDisplayBrightness ( int b ); | 146 | virtual bool setDisplayBrightness ( int b ); |
147 | virtual int displayBrightnessResolution ( ) const; | 147 | virtual int displayBrightnessResolution ( ) const; |
148 | 148 | ||
149 | virtual void alarmSound ( ); | 149 | virtual void alarmSound ( ); |
150 | 150 | ||
151 | virtual QValueList <OLed> ledList ( ) const; | 151 | virtual QValueList <OLed> ledList ( ) const; |
152 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; | 152 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; |
153 | virtual OLedState ledState ( OLed led ) const; | 153 | virtual OLedState ledState ( OLed led ) const; |
154 | virtual bool setLedState ( OLed led, OLedState st ); | 154 | virtual bool setLedState ( OLed led, OLedState st ); |
155 | 155 | ||
156 | protected: | 156 | protected: |
157 | virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); | 157 | virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); |
158 | virtual void timerEvent ( QTimerEvent *te ); | 158 | virtual void timerEvent ( QTimerEvent *te ); |
159 | 159 | ||
160 | int m_power_timer; | 160 | int m_power_timer; |
161 | 161 | ||
162 | OLedState m_leds [1]; //FIXME check if really only one | 162 | OLedState m_leds [1]; //FIXME check if really only one |
163 | }; | 163 | }; |
164 | 164 | ||
165 | class Ramses : public ODevice, public QWSServer::KeyboardFilter { | 165 | class Ramses : public ODevice, public QWSServer::KeyboardFilter { |
166 | protected: | 166 | protected: |
167 | virtual void init ( ); | 167 | virtual void init ( ); |
168 | 168 | ||
169 | public: | 169 | public: |
170 | virtual bool setSoftSuspend ( bool soft ); | 170 | virtual bool setSoftSuspend ( bool soft ); |
171 | virtual bool suspend ( ); | 171 | virtual bool suspend ( ); |
172 | 172 | ||
173 | virtual bool setDisplayStatus( bool on ); | 173 | virtual bool setDisplayStatus( bool on ); |
174 | virtual bool setDisplayBrightness ( int b ); | 174 | virtual bool setDisplayBrightness ( int b ); |
175 | virtual int displayBrightnessResolution ( ) const; | 175 | virtual int displayBrightnessResolution ( ) const; |
176 | virtual bool setDisplayContrast ( int b ); | 176 | virtual bool setDisplayContrast ( int b ); |
177 | virtual int displayContrastResolution ( ) const; | 177 | virtual int displayContrastResolution ( ) const; |
178 | 178 | ||
179 | protected: | 179 | protected: |
180 | virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); | 180 | virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); |
181 | virtual void timerEvent ( QTimerEvent *te ); | 181 | virtual void timerEvent ( QTimerEvent *te ); |
182 | 182 | ||
183 | int m_power_timer; | 183 | int m_power_timer; |
184 | }; | 184 | }; |
185 | 185 | ||
186 | struct i_button { | 186 | struct i_button { |
187 | uint model; | 187 | uint model; |
188 | Qt::Key code; | 188 | Qt::Key code; |
189 | char *utext; | 189 | char *utext; |
190 | char *pix; | 190 | char *pix; |
191 | char *fpressedservice; | 191 | char *fpressedservice; |
192 | char *fpressedaction; | 192 | char *fpressedaction; |
193 | char *fheldservice; | 193 | char *fheldservice; |
194 | char *fheldaction; | 194 | char *fheldaction; |
195 | } ipaq_buttons [] = { | 195 | } ipaq_buttons [] = { |
196 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, | 196 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, |
197 | Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), | 197 | Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), |
198 | "devicebuttons/ipaq_calendar", | 198 | "devicebuttons/ipaq_calendar", |
199 | "datebook", "nextView()", | 199 | "datebook", "nextView()", |
200 | "today", "raise()" }, | 200 | "today", "raise()" }, |
201 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, | 201 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, |
202 | Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), | 202 | Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), |
203 | "devicebuttons/ipaq_contact", | 203 | "devicebuttons/ipaq_contact", |
204 | "addressbook", "raise()", | 204 | "addressbook", "raise()", |
205 | "addressbook", "beamBusinessCard()" }, | 205 | "addressbook", "beamBusinessCard()" }, |
206 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx, | 206 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx, |
207 | Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), | 207 | Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), |
208 | "devicebuttons/ipaq_menu", | 208 | "devicebuttons/ipaq_menu", |
209 | "QPE/TaskBar", "toggleMenu()", | 209 | "QPE/TaskBar", "toggleMenu()", |
210 | "QPE/TaskBar", "toggleStartMenu()" }, | 210 | "QPE/TaskBar", "toggleStartMenu()" }, |
211 | { Model_iPAQ_H38xx | Model_iPAQ_H39xx, | 211 | { Model_iPAQ_H38xx | Model_iPAQ_H39xx, |
212 | Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), | 212 | Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), |
213 | "devicebuttons/ipaq_mail", | 213 | "devicebuttons/ipaq_mail", |
214 | "mail", "raise()", | 214 | "mail", "raise()", |
215 | "mail", "newMail()" }, | 215 | "mail", "newMail()" }, |
216 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, | 216 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, |
217 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), | 217 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), |
218 | "devicebuttons/ipaq_home", | 218 | "devicebuttons/ipaq_home", |
219 | "QPE/Launcher", "home()", | 219 | "QPE/Launcher", "home()", |
220 | "buttonsettings", "raise()" }, | 220 | "buttonsettings", "raise()" }, |
221 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, | 221 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, |
222 | Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"), | 222 | Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"), |
223 | "devicebuttons/ipaq_record", | 223 | "devicebuttons/ipaq_record", |
224 | "QPE/VMemo", "toggleRecord()", | 224 | "QPE/VMemo", "toggleRecord()", |
225 | "sound", "raise()" }, | 225 | "sound", "raise()" }, |
226 | }; | 226 | }; |
227 | 227 | ||
228 | struct z_button { | 228 | struct z_button { |
229 | Qt::Key code; | 229 | Qt::Key code; |
230 | char *utext; | 230 | char *utext; |
231 | char *pix; | 231 | char *pix; |
232 | char *fpressedservice; | 232 | char *fpressedservice; |
233 | char *fpressedaction; | 233 | char *fpressedaction; |
234 | char *fheldservice; | 234 | char *fheldservice; |
235 | char *fheldaction; | 235 | char *fheldaction; |
236 | } z_buttons [] = { | 236 | } z_buttons [] = { |
237 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), | 237 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), |
238 | "devicebuttons/z_calendar", | 238 | "devicebuttons/z_calendar", |
239 | "datebook", "nextView()", | 239 | "datebook", "nextView()", |
240 | "today", "raise()" }, | 240 | "today", "raise()" }, |
241 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), | 241 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), |
242 | "devicebuttons/z_contact", | 242 | "devicebuttons/z_contact", |
243 | "addressbook", "raise()", | 243 | "addressbook", "raise()", |
244 | "addressbook", "beamBusinessCard()" }, | 244 | "addressbook", "beamBusinessCard()" }, |
245 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), | 245 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), |
246 | "devicebuttons/z_home", | 246 | "devicebuttons/z_home", |
247 | "QPE/Launcher", "home()", | 247 | "QPE/Launcher", "home()", |
248 | "buttonsettings", "raise()" }, | 248 | "buttonsettings", "raise()" }, |
249 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), | 249 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), |
250 | "devicebuttons/z_menu", | 250 | "devicebuttons/z_menu", |
251 | "QPE/TaskBar", "toggleMenu()", | 251 | "QPE/TaskBar", "toggleMenu()", |
252 | "QPE/TaskBar", "toggleStartMenu()" }, | 252 | "QPE/TaskBar", "toggleStartMenu()" }, |
253 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), | 253 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), |
254 | "devicebuttons/z_mail", | 254 | "devicebuttons/z_mail", |
255 | "mail", "raise()", | 255 | "mail", "raise()", |
256 | "mail", "newMail()" }, | 256 | "mail", "newMail()" }, |
257 | }; | 257 | }; |
258 | 258 | ||
259 | struct z_button z_buttons_c700 [] = { | 259 | struct z_button z_buttons_c700 [] = { |
260 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), | 260 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), |
261 | "devicebuttons/z_calendar", | 261 | "devicebuttons/z_calendar", |
262 | "datebook", "nextView()", | 262 | "datebook", "nextView()", |
263 | "today", "raise()" }, | 263 | "today", "raise()" }, |
264 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), | 264 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), |
265 | "devicebuttons/z_contact", | 265 | "devicebuttons/z_contact", |
266 | "addressbook", "raise()", | 266 | "addressbook", "raise()", |
267 | "addressbook", "beamBusinessCard()" }, | 267 | "addressbook", "beamBusinessCard()" }, |
268 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), | 268 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), |
269 | "devicebuttons/z_home", | 269 | "devicebuttons/z_home", |
270 | "QPE/Launcher", "home()", | 270 | "QPE/Launcher", "home()", |
271 | "buttonsettings", "raise()" }, | 271 | "buttonsettings", "raise()" }, |
272 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), | 272 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), |
273 | "devicebuttons/z_menu", | 273 | "devicebuttons/z_menu", |
274 | "QPE/TaskBar", "toggleMenu()", | 274 | "QPE/TaskBar", "toggleMenu()", |
275 | "QPE/TaskBar", "toggleStartMenu()" }, | 275 | "QPE/TaskBar", "toggleStartMenu()" }, |
276 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Display Rotate"), | 276 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Display Rotate"), |
277 | "", | 277 | "", |
278 | "QPE/Rotation", "flip()", | 278 | "QPE/Rotation", "flip()", |
279 | "QPE/Rotation", "flip()" }, | 279 | "QPE/Rotation", "flip()" }, |
280 | }; | 280 | }; |
281 | 281 | ||
282 | struct s_button { | 282 | struct s_button { |
283 | uint model; | 283 | uint model; |
284 | Qt::Key code; | 284 | Qt::Key code; |
285 | char *utext; | 285 | char *utext; |
286 | char *pix; | 286 | char *pix; |
287 | char *fpressedservice; | 287 | char *fpressedservice; |
288 | char *fpressedaction; | 288 | char *fpressedaction; |
289 | char *fheldservice; | 289 | char *fheldservice; |
290 | char *fheldaction; | 290 | char *fheldaction; |
291 | } simpad_buttons [] = { | 291 | } simpad_buttons [] = { |
292 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 292 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
293 | Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Lower+Up"), | 293 | Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Lower+Up"), |
294 | "devicebuttons/simpad_lower_up", | 294 | "devicebuttons/simpad_lower_up", |
295 | "datebook", "nextView()", | 295 | "datebook", "nextView()", |
296 | "today", "raise()" }, | 296 | "today", "raise()" }, |
297 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 297 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
298 | Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Lower+Down"), | 298 | Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Lower+Down"), |
299 | "devicebuttons/simpad_lower_down", | 299 | "devicebuttons/simpad_lower_down", |
300 | "addressbook", "raise()", | 300 | "addressbook", "raise()", |
301 | "addressbook", "beamBusinessCard()" }, | 301 | "addressbook", "beamBusinessCard()" }, |
302 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 302 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
303 | Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Lower+Right"), | 303 | Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Lower+Right"), |
304 | "devicebuttons/simpad_lower_right", | 304 | "devicebuttons/simpad_lower_right", |
305 | "QPE/TaskBar", "toggleMenu()", | 305 | "QPE/TaskBar", "toggleMenu()", |
306 | "QPE/TaskBar", "toggleStartMenu()" }, | 306 | "QPE/TaskBar", "toggleStartMenu()" }, |
307 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 307 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
308 | Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Lower+Left"), | 308 | Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Lower+Left"), |
309 | "devicebuttons/simpad_lower_left", | 309 | "devicebuttons/simpad_lower_left", |
310 | "mail", "raise()", | 310 | "mail", "raise()", |
311 | "mail", "newMail()" }, | 311 | "mail", "newMail()" }, |
312 | 312 | ||
313 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 313 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
314 | Qt::Key_F5, QT_TRANSLATE_NOOP("Button", "Upper+Up"), | 314 | Qt::Key_F5, QT_TRANSLATE_NOOP("Button", "Upper+Up"), |
315 | "devicebuttons/simpad_upper_up", | 315 | "devicebuttons/simpad_upper_up", |
316 | "QPE/Launcher", "home()", | 316 | "QPE/Launcher", "home()", |
317 | "buttonsettings", "raise()" }, | 317 | "buttonsettings", "raise()" }, |
318 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 318 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
319 | Qt::Key_F6, QT_TRANSLATE_NOOP("Button", "Upper+Down"), | 319 | Qt::Key_F6, QT_TRANSLATE_NOOP("Button", "Upper+Down"), |
320 | "devicebuttons/simpad_upper_down", | 320 | "devicebuttons/simpad_upper_down", |
321 | "addressbook", "raise()", | 321 | "addressbook", "raise()", |
322 | "addressbook", "beamBusinessCard()" }, | 322 | "addressbook", "beamBusinessCard()" }, |
323 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 323 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
324 | Qt::Key_F7, QT_TRANSLATE_NOOP("Button", "Upper+Right"), | 324 | Qt::Key_F7, QT_TRANSLATE_NOOP("Button", "Upper+Right"), |
325 | "devicebuttons/simpad_upper_right", | 325 | "devicebuttons/simpad_upper_right", |
326 | "QPE/TaskBar", "toggleMenu()", | 326 | "QPE/TaskBar", "toggleMenu()", |
327 | "QPE/TaskBar", "toggleStartMenu()" }, | 327 | "QPE/TaskBar", "toggleStartMenu()" }, |
328 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 328 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
329 | Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Upper+Left"), | 329 | Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Upper+Left"), |
330 | "devicebuttons/simpad_upper_left", | 330 | "devicebuttons/simpad_upper_left", |
331 | "QPE/Rotation", "flip()", | 331 | "QPE/Rotation", "flip()", |
332 | "QPE/Rotation", "flip()" }, | 332 | "QPE/Rotation", "flip()" }, |
333 | /* | 333 | /* |
334 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 334 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
335 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), | 335 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), |
336 | "devicebuttons/simpad_lower_upper", | 336 | "devicebuttons/simpad_lower_upper", |
337 | "QPE/Launcher", "home()", | 337 | "QPE/Launcher", "home()", |
338 | "buttonsettings", "raise()" }, | 338 | "buttonsettings", "raise()" }, |
339 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 339 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
340 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), | 340 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), |
341 | "devicebuttons/simpad_upper_lower", | 341 | "devicebuttons/simpad_upper_lower", |
342 | "QPE/Launcher", "home()", | 342 | "QPE/Launcher", "home()", |
343 | "buttonsettings", "raise()" }, | 343 | "buttonsettings", "raise()" }, |
344 | */ | 344 | */ |
345 | }; | 345 | }; |
346 | 346 | ||
347 | struct r_button { | 347 | struct r_button { |
348 | uint model; | 348 | uint model; |
349 | Qt::Key code; | 349 | Qt::Key code; |
350 | char *utext; | 350 | char *utext; |
351 | char *pix; | 351 | char *pix; |
352 | char *fpressedservice; | 352 | char *fpressedservice; |
353 | char *fpressedaction; | 353 | char *fpressedaction; |
354 | char *fheldservice; | 354 | char *fheldservice; |
355 | char *fheldaction; | 355 | char *fheldaction; |
356 | } ramses_buttons [] = { | 356 | } ramses_buttons [] = { |
357 | { Model_Ramses_MNCI, | 357 | { Model_Ramses_MNCI, |
358 | Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), | 358 | Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), |
359 | "devicebuttons/z_menu", | 359 | "devicebuttons/z_menu", |
360 | "QPE/TaskBar", "toggleMenu()", | 360 | "QPE/TaskBar", "toggleMenu()", |
361 | "QPE/TaskBar", "toggleStartMenu()" }, | 361 | "QPE/TaskBar", "toggleStartMenu()" }, |
362 | { Model_Ramses_MNCI, | 362 | { Model_Ramses_MNCI, |
363 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), | 363 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), |
364 | "devicebuttons/ipaq_home", | 364 | "devicebuttons/ipaq_home", |
365 | "QPE/Launcher", "home()", | 365 | "QPE/Launcher", "home()", |
366 | "buttonsettings", "raise()" }, | 366 | "buttonsettings", "raise()" }, |
367 | }; | 367 | }; |
368 | 368 | ||
369 | static QCString makeChannel ( const char *str ) | 369 | static QCString makeChannel ( const char *str ) |
370 | { | 370 | { |
371 | if ( str && !::strchr ( str, '/' )) | 371 | if ( str && !::strchr ( str, '/' )) |
372 | return QCString ( "QPE/Application/" ) + str; | 372 | return QCString ( "QPE/Application/" ) + str; |
373 | else | 373 | else |
374 | return str; | 374 | return str; |
375 | } | 375 | } |
376 | 376 | ||
377 | static inline bool isQWS() | 377 | static inline bool isQWS() |
378 | { | 378 | { |
379 | return qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false; | 379 | return qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false; |
380 | } | 380 | } |
381 | 381 | ||
382 | ODevice *ODevice::inst ( ) | 382 | ODevice *ODevice::inst ( ) |
383 | { | 383 | { |
384 | static ODevice *dev = 0; | 384 | static ODevice *dev = 0; |
385 | 385 | ||
386 | if ( !dev ) { | 386 | if ( !dev ) { |
387 | if ( QFile::exists ( "/proc/hal/model" )) | 387 | if ( QFile::exists ( "/proc/hal/model" )) |
388 | dev = new iPAQ ( ); | 388 | dev = new iPAQ ( ); |
389 | else if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" )) | 389 | else if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" )) |
390 | dev = new Zaurus ( ); | 390 | dev = new Zaurus ( ); |
391 | else if ( QFile::exists ( "/proc/ucb1x00" ) && QFile::exists ( "/proc/cs3" )) | 391 | else if ( QFile::exists ( "/proc/ucb1x00" ) && QFile::exists ( "/proc/cs3" )) |
392 | dev = new SIMpad ( ); | 392 | dev = new SIMpad ( ); |
393 | else if ( QFile::exists ( "/proc/sys/board/name" )) | 393 | else if ( QFile::exists ( "/proc/sys/board/name" )) |
394 | dev = new Ramses ( ); | 394 | dev = new Ramses ( ); |
395 | else | 395 | else |
396 | dev = new ODevice ( ); | 396 | dev = new ODevice ( ); |
397 | 397 | ||
398 | dev-> init ( ); | 398 | dev-> init ( ); |
399 | } | 399 | } |
400 | return dev; | 400 | return dev; |
401 | } | 401 | } |
402 | 402 | ||
403 | 403 | ||
404 | /************************************************** | 404 | /************************************************** |
405 | * | 405 | * |
406 | * common | 406 | * common |
407 | * | 407 | * |
408 | **************************************************/ | 408 | **************************************************/ |
409 | 409 | ||
410 | 410 | ||
411 | ODevice::ODevice ( ) | 411 | ODevice::ODevice ( ) |
412 | { | 412 | { |
413 | d = new ODeviceData; | 413 | d = new ODeviceData; |
414 | 414 | ||
415 | d-> m_modelstr = "Unknown"; | 415 | d-> m_modelstr = "Unknown"; |
416 | d-> m_model = Model_Unknown; | 416 | d-> m_model = Model_Unknown; |
417 | d-> m_vendorstr = "Unknown"; | 417 | d-> m_vendorstr = "Unknown"; |
418 | d-> m_vendor = Vendor_Unknown; | 418 | d-> m_vendor = Vendor_Unknown; |
419 | d-> m_systemstr = "Unknown"; | 419 | d-> m_systemstr = "Unknown"; |
420 | d-> m_system = System_Unknown; | 420 | d-> m_system = System_Unknown; |
421 | d-> m_sysverstr = "0.0"; | 421 | d-> m_sysverstr = "0.0"; |
422 | d-> m_rotation = Rot0; | 422 | d-> m_rotation = Rot0; |
423 | d-> m_direction = CW; | 423 | d-> m_direction = CW; |
424 | 424 | ||
425 | d-> m_holdtime = 1000; // 1000ms | 425 | d-> m_holdtime = 1000; // 1000ms |
426 | d-> m_buttons = 0; | 426 | d-> m_buttons = 0; |
427 | d-> m_cpu_frequencies = new QStrList; | 427 | d-> m_cpu_frequencies = new QStrList; |
428 | } | 428 | } |
429 | 429 | ||
430 | void ODevice::systemMessage ( const QCString &msg, const QByteArray & ) | 430 | void ODevice::systemMessage ( const QCString &msg, const QByteArray & ) |
431 | { | 431 | { |
432 | if ( msg == "deviceButtonMappingChanged()" ) { | 432 | if ( msg == "deviceButtonMappingChanged()" ) { |
433 | reloadButtonMapping ( ); | 433 | reloadButtonMapping ( ); |
434 | } | 434 | } |
435 | } | 435 | } |
436 | 436 | ||
437 | void ODevice::init ( ) | 437 | void ODevice::init ( ) |
438 | { | 438 | { |
439 | } | 439 | } |
440 | 440 | ||
441 | /** | 441 | /** |
442 | * This method initialises the button mapping | 442 | * This method initialises the button mapping |
443 | */ | 443 | */ |
444 | void ODevice::initButtons ( ) | 444 | void ODevice::initButtons ( ) |
445 | { | 445 | { |
446 | if ( d-> m_buttons ) | 446 | if ( d-> m_buttons ) |
447 | return; | 447 | return; |
448 | 448 | ||
449 | // Simulation uses iPAQ 3660 device buttons | 449 | // Simulation uses iPAQ 3660 device buttons |
450 | 450 | ||
451 | qDebug ( "init Buttons" ); | 451 | qDebug ( "init Buttons" ); |
452 | d-> m_buttons = new QValueList <ODeviceButton>; | 452 | d-> m_buttons = new QValueList <ODeviceButton>; |
453 | 453 | ||
454 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { | 454 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { |
455 | i_button *ib = ipaq_buttons + i; | 455 | i_button *ib = ipaq_buttons + i; |
456 | ODeviceButton b; | 456 | ODeviceButton b; |
457 | 457 | ||
458 | if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) { | 458 | if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) { |
459 | b. setKeycode ( ib-> code ); | 459 | b. setKeycode ( ib-> code ); |
460 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); | 460 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); |
461 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); | 461 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); |
462 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); | 462 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); |
463 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); | 463 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); |
464 | d-> m_buttons-> append ( b ); | 464 | d-> m_buttons-> append ( b ); |
465 | } | 465 | } |
466 | } | 466 | } |
467 | reloadButtonMapping ( ); | 467 | reloadButtonMapping ( ); |
468 | 468 | ||
469 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); | 469 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); |
470 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); | 470 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); |
471 | } | 471 | } |
472 | 472 | ||
473 | ODevice::~ODevice ( ) | 473 | ODevice::~ODevice ( ) |
474 | { | 474 | { |
475 | // we leak m_devicebuttons and m_cpu_frequency | ||
476 | // but it's a singleton and it is not so importantant | ||
477 | // -zecke | ||
475 | delete d; | 478 | delete d; |
476 | } | 479 | } |
477 | 480 | ||
478 | bool ODevice::setSoftSuspend ( bool /*soft*/ ) | 481 | bool ODevice::setSoftSuspend ( bool /*soft*/ ) |
479 | { | 482 | { |
480 | return false; | 483 | return false; |
481 | } | 484 | } |
482 | 485 | ||
483 | //#include <linux/apm_bios.h> | 486 | //#include <linux/apm_bios.h> |
484 | 487 | ||
485 | #define APM_IOC_SUSPEND OD_IO( 'A', 2 ) | 488 | #define APM_IOC_SUSPEND OD_IO( 'A', 2 ) |
486 | 489 | ||
487 | /** | 490 | /** |
488 | * This method will try to suspend the device | 491 | * This method will try to suspend the device |
489 | * It only works if the user is the QWS Server and the apm application | 492 | * It only works if the user is the QWS Server and the apm application |
490 | * is installed. | 493 | * is installed. |
491 | * It tries to suspend and then waits some time cause some distributions | 494 | * It tries to suspend and then waits some time cause some distributions |
492 | * do have asynchronus apm implementations. | 495 | * do have asynchronus apm implementations. |
493 | * This method will either fail and return false or it'll suspend the | 496 | * This method will either fail and return false or it'll suspend the |
494 | * device and return once the device got woken up | 497 | * device and return once the device got woken up |
495 | * | 498 | * |
496 | * @return if the device got suspended | 499 | * @return if the device got suspended |
497 | */ | 500 | */ |
498 | bool ODevice::suspend ( ) | 501 | bool ODevice::suspend ( ) |
499 | { | 502 | { |
500 | qDebug("ODevice::suspend"); | 503 | qDebug("ODevice::suspend"); |
501 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend | 504 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend |
502 | return false; | 505 | return false; |
503 | 506 | ||
504 | if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices | 507 | if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices |
505 | return false; | 508 | return false; |
506 | 509 | ||
507 | bool res = false; | 510 | bool res = false; |
508 | 511 | ||
509 | struct timeval tvs, tvn; | 512 | struct timeval tvs, tvn; |
510 | ::gettimeofday ( &tvs, 0 ); | 513 | ::gettimeofday ( &tvs, 0 ); |
511 | 514 | ||
512 | ::sync ( ); // flush fs caches | 515 | ::sync ( ); // flush fs caches |
513 | res = ( ::system ( "apm --suspend" ) == 0 ); | 516 | res = ( ::system ( "apm --suspend" ) == 0 ); |
514 | 517 | ||
515 | // This is needed because the iPAQ apm implementation is asynchronous and we | 518 | // This is needed because the iPAQ apm implementation is asynchronous and we |
516 | // can not be sure when exactly the device is really suspended | 519 | // can not be sure when exactly the device is really suspended |
517 | // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. | 520 | // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. |
518 | 521 | ||
519 | if ( res ) { | 522 | if ( res ) { |
520 | do { // wait at most 1.5 sec: either suspend didn't work or the device resumed | 523 | do { // wait at most 1.5 sec: either suspend didn't work or the device resumed |
521 | ::usleep ( 200 * 1000 ); | 524 | ::usleep ( 200 * 1000 ); |
522 | ::gettimeofday ( &tvn, 0 ); | 525 | ::gettimeofday ( &tvn, 0 ); |
523 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); | 526 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); |
524 | } | 527 | } |
525 | 528 | ||
526 | return res; | 529 | return res; |
527 | } | 530 | } |
528 | 531 | ||
529 | //#include <linux/fb.h> better not rely on kernel headers in userspace ... | 532 | //#include <linux/fb.h> better not rely on kernel headers in userspace ... |
530 | 533 | ||
531 | #define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 | 534 | #define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 |
532 | 535 | ||
533 | /* VESA Blanking Levels */ | 536 | /* VESA Blanking Levels */ |
534 | #define VESA_NO_BLANKING 0 | 537 | #define VESA_NO_BLANKING 0 |
535 | #define VESA_VSYNC_SUSPEND 1 | 538 | #define VESA_VSYNC_SUSPEND 1 |
536 | #define VESA_HSYNC_SUSPEND 2 | 539 | #define VESA_HSYNC_SUSPEND 2 |
537 | #define VESA_POWERDOWN 3 | 540 | #define VESA_POWERDOWN 3 |
538 | 541 | ||
539 | /** | 542 | /** |
540 | * This sets the display on or off | 543 | * This sets the display on or off |
541 | */ | 544 | */ |
542 | bool ODevice::setDisplayStatus ( bool on ) | 545 | bool ODevice::setDisplayStatus ( bool on ) |
543 | { | 546 | { |
544 | qDebug("ODevice::setDisplayStatus(%d)", on); | 547 | qDebug("ODevice::setDisplayStatus(%d)", on); |
545 | 548 | ||
546 | if ( d-> m_model == Model_Unknown ) | 549 | if ( d-> m_model == Model_Unknown ) |
547 | return false; | 550 | return false; |
548 | 551 | ||
549 | bool res = false; | 552 | bool res = false; |
550 | int fd; | 553 | int fd; |
551 | 554 | ||
552 | if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { | 555 | if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { |
553 | res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); | 556 | res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); |
554 | ::close ( fd ); | 557 | ::close ( fd ); |
555 | } | 558 | } |
556 | return res; | 559 | return res; |
557 | } | 560 | } |
558 | 561 | ||
559 | /** | 562 | /** |
560 | * This sets the display brightness | 563 | * This sets the display brightness |
561 | * | 564 | * |
562 | * @param p The brightness to be set on a scale from 0 to 255 | 565 | * @param p The brightness to be set on a scale from 0 to 255 |
563 | * @return success or failure | 566 | * @return success or failure |
564 | */ | 567 | */ |
565 | bool ODevice::setDisplayBrightness ( int p) | 568 | bool ODevice::setDisplayBrightness ( int p) |
566 | { | 569 | { |
567 | Q_UNUSED( p ) | 570 | Q_UNUSED( p ) |
568 | return false; | 571 | return false; |
569 | } | 572 | } |
570 | 573 | ||
571 | /** | 574 | /** |
572 | * @return returns the number of steppings on the brightness slider | 575 | * @return returns the number of steppings on the brightness slider |
573 | * in the Light-'n-Power settings. | 576 | * in the Light-'n-Power settings. |
574 | */ | 577 | */ |
575 | int ODevice::displayBrightnessResolution ( ) const | 578 | int ODevice::displayBrightnessResolution ( ) const |
576 | { | 579 | { |
577 | return 16; | 580 | return 16; |
578 | } | 581 | } |
579 | 582 | ||
580 | /** | 583 | /** |
581 | * This sets the display contrast | 584 | * This sets the display contrast |
582 | * @param p The contrast to be set on a scale from 0 to 255 | 585 | * @param p The contrast to be set on a scale from 0 to 255 |
583 | * @return success or failure | 586 | * @return success or failure |
584 | */ | 587 | */ |
585 | bool ODevice::setDisplayContrast ( int p) | 588 | bool ODevice::setDisplayContrast ( int p) |
586 | { | 589 | { |
587 | Q_UNUSED( p ) | 590 | Q_UNUSED( p ) |
588 | return false; | 591 | return false; |
589 | } | 592 | } |
590 | 593 | ||
591 | /** | 594 | /** |
592 | * @return return the max value for the brightness settings slider | 595 | * @return return the max value for the brightness settings slider |
593 | * or 0 if the device doesn't support setting of a contrast | 596 | * or 0 if the device doesn't support setting of a contrast |
594 | */ | 597 | */ |
595 | int ODevice::displayContrastResolution ( ) const | 598 | int ODevice::displayContrastResolution ( ) const |
596 | { | 599 | { |
597 | return 0; | 600 | return 0; |
598 | } | 601 | } |
599 | 602 | ||
600 | /** | 603 | /** |
601 | * This returns the vendor as string | 604 | * This returns the vendor as string |
602 | * @return Vendor as QString | 605 | * @return Vendor as QString |
603 | */ | 606 | */ |
604 | QString ODevice::vendorString ( ) const | 607 | QString ODevice::vendorString ( ) const |
605 | { | 608 | { |
606 | return d-> m_vendorstr; | 609 | return d-> m_vendorstr; |
607 | } | 610 | } |
608 | 611 | ||
609 | /** | 612 | /** |
610 | * This returns the vendor as one of the values of OVendor | 613 | * This returns the vendor as one of the values of OVendor |
611 | * @return OVendor | 614 | * @return OVendor |
612 | */ | 615 | */ |
613 | OVendor ODevice::vendor ( ) const | 616 | OVendor ODevice::vendor ( ) const |
614 | { | 617 | { |
615 | return d-> m_vendor; | 618 | return d-> m_vendor; |
616 | } | 619 | } |
617 | 620 | ||
618 | /** | 621 | /** |
619 | * This returns the model as a string | 622 | * This returns the model as a string |
620 | * @return A string representing the model | 623 | * @return A string representing the model |
621 | */ | 624 | */ |
622 | QString ODevice::modelString ( ) const | 625 | QString ODevice::modelString ( ) const |
623 | { | 626 | { |
624 | return d-> m_modelstr; | 627 | return d-> m_modelstr; |
625 | } | 628 | } |
626 | 629 | ||
627 | /** | 630 | /** |
628 | * This does return the OModel used | 631 | * This does return the OModel used |
629 | */ | 632 | */ |
630 | OModel ODevice::model ( ) const | 633 | OModel ODevice::model ( ) const |
631 | { | 634 | { |
632 | return d-> m_model; | 635 | return d-> m_model; |
633 | } | 636 | } |
634 | 637 | ||
635 | /** | 638 | /** |
636 | * This does return the systen name | 639 | * This does return the systen name |
637 | */ | 640 | */ |
638 | QString ODevice::systemString ( ) const | 641 | QString ODevice::systemString ( ) const |
639 | { | 642 | { |
640 | return d-> m_systemstr; | 643 | return d-> m_systemstr; |
641 | } | 644 | } |
642 | 645 | ||
643 | /** | 646 | /** |
644 | * Return System as OSystem value | 647 | * Return System as OSystem value |
645 | */ | 648 | */ |
646 | OSystem ODevice::system ( ) const | 649 | OSystem ODevice::system ( ) const |
647 | { | 650 | { |
648 | return d-> m_system; | 651 | return d-> m_system; |
649 | } | 652 | } |
650 | 653 | ||
651 | /** | 654 | /** |
652 | * @return the version string of the base system | 655 | * @return the version string of the base system |
653 | */ | 656 | */ |
654 | QString ODevice::systemVersionString ( ) const | 657 | QString ODevice::systemVersionString ( ) const |
655 | { | 658 | { |
656 | return d-> m_sysverstr; | 659 | return d-> m_sysverstr; |
657 | } | 660 | } |
658 | 661 | ||
659 | /** | 662 | /** |
660 | * @return the current Transformation | 663 | * @return the current Transformation |
661 | */ | 664 | */ |
662 | Transformation ODevice::rotation ( ) const | 665 | Transformation ODevice::rotation ( ) const |
663 | { | 666 | { |
664 | return d-> m_rotation; | 667 | return d-> m_rotation; |
665 | } | 668 | } |
666 | 669 | ||
667 | /** | 670 | /** |
668 | * @return the current rotation direction | 671 | * @return the current rotation direction |
669 | */ | 672 | */ |
670 | ODirection ODevice::direction ( ) const | 673 | ODirection ODevice::direction ( ) const |
671 | { | 674 | { |
672 | return d-> m_direction; | 675 | return d-> m_direction; |
673 | } | 676 | } |
674 | 677 | ||
675 | /** | 678 | /** |
676 | * This plays an alarmSound | 679 | * This plays an alarmSound |
677 | */ | 680 | */ |
678 | void ODevice::alarmSound ( ) | 681 | void ODevice::alarmSound ( ) |
679 | { | 682 | { |
680 | #ifndef QT_NO_SOUND | 683 | #ifndef QT_NO_SOUND |
681 | static Sound snd ( "alarm" ); | 684 | static Sound snd ( "alarm" ); |
682 | 685 | ||
683 | if ( snd. isFinished ( )) | 686 | if ( snd. isFinished ( )) |
684 | snd. play ( ); | 687 | snd. play ( ); |
685 | #endif | 688 | #endif |
686 | } | 689 | } |
687 | 690 | ||
688 | /** | 691 | /** |
689 | * This plays a key sound | 692 | * This plays a key sound |
690 | */ | 693 | */ |
691 | void ODevice::keySound ( ) | 694 | void ODevice::keySound ( ) |
692 | { | 695 | { |
693 | #ifndef QT_NO_SOUND | 696 | #ifndef QT_NO_SOUND |
694 | static Sound snd ( "keysound" ); | 697 | static Sound snd ( "keysound" ); |
695 | 698 | ||
696 | if ( snd. isFinished ( )) | 699 | if ( snd. isFinished ( )) |
697 | snd. play ( ); | 700 | snd. play ( ); |
698 | #endif | 701 | #endif |
699 | } | 702 | } |
700 | 703 | ||
701 | /** | 704 | /** |
702 | * This plays a touch sound | 705 | * This plays a touch sound |
703 | */ | 706 | */ |
704 | void ODevice::touchSound ( ) | 707 | void ODevice::touchSound ( ) |
705 | { | 708 | { |
706 | #ifndef QT_NO_SOUND | 709 | #ifndef QT_NO_SOUND |
707 | static Sound snd ( "touchsound" ); | 710 | static Sound snd ( "touchsound" ); |
708 | 711 | ||
709 | if ( snd. isFinished ( )) | 712 | if ( snd. isFinished ( )) |
710 | snd. play ( ); | 713 | snd. play ( ); |
711 | #endif | 714 | #endif |
712 | } | 715 | } |
713 | 716 | ||
714 | /** | 717 | /** |
715 | * This method will return a list of leds | 718 | * This method will return a list of leds |
716 | * available on this device | 719 | * available on this device |
717 | * @return a list of LEDs. | 720 | * @return a list of LEDs. |
718 | */ | 721 | */ |
719 | QValueList <OLed> ODevice::ledList ( ) const | 722 | QValueList <OLed> ODevice::ledList ( ) const |
720 | { | 723 | { |
721 | return QValueList <OLed> ( ); | 724 | return QValueList <OLed> ( ); |
722 | } | 725 | } |
723 | 726 | ||
724 | /** | 727 | /** |
725 | * This does return the state of the LEDs | 728 | * This does return the state of the LEDs |
726 | */ | 729 | */ |
727 | QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const | 730 | QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const |
728 | { | 731 | { |
729 | return QValueList <OLedState> ( ); | 732 | return QValueList <OLedState> ( ); |
730 | } | 733 | } |
731 | 734 | ||
732 | /** | 735 | /** |
733 | * @return the state for a given OLed | 736 | * @return the state for a given OLed |
734 | */ | 737 | */ |
735 | OLedState ODevice::ledState ( OLed /*which*/ ) const | 738 | OLedState ODevice::ledState ( OLed /*which*/ ) const |
736 | { | 739 | { |
737 | return Led_Off; | 740 | return Led_Off; |
738 | } | 741 | } |
739 | 742 | ||
740 | /** | 743 | /** |
741 | * Set the state for a LED | 744 | * Set the state for a LED |
742 | * @param which Which OLed to use | 745 | * @param which Which OLed to use |
743 | * @param st The state to set | 746 | * @param st The state to set |
744 | * @return success or failure | 747 | * @return success or failure |
745 | */ | 748 | */ |
746 | bool ODevice::setLedState ( OLed which, OLedState st ) | 749 | bool ODevice::setLedState ( OLed which, OLedState st ) |
747 | { | 750 | { |
748 | Q_UNUSED( which ) | 751 | Q_UNUSED( which ) |
749 | Q_UNUSED( st ) | 752 | Q_UNUSED( st ) |
750 | return false; | 753 | return false; |
751 | } | 754 | } |
752 | 755 | ||
753 | /** | 756 | /** |
754 | * @return if the device has a light sensor | 757 | * @return if the device has a light sensor |
755 | */ | 758 | */ |
756 | bool ODevice::hasLightSensor ( ) const | 759 | bool ODevice::hasLightSensor ( ) const |
757 | { | 760 | { |
758 | return false; | 761 | return false; |
759 | } | 762 | } |
760 | 763 | ||
761 | /** | 764 | /** |
762 | * @return a value from the light senso | 765 | * @return a value from the light senso |
763 | */ | 766 | */ |
764 | int ODevice::readLightSensor ( ) | 767 | int ODevice::readLightSensor ( ) |
765 | { | 768 | { |
766 | return -1; | 769 | return -1; |
767 | } | 770 | } |
768 | 771 | ||
769 | /** | 772 | /** |
770 | * @return the light sensor resolution whatever that is ;) | 773 | * @return the light sensor resolution whatever that is ;) |
771 | */ | 774 | */ |
772 | int ODevice::lightSensorResolution ( ) const | 775 | int ODevice::lightSensorResolution ( ) const |
773 | { | 776 | { |
774 | return 0; | 777 | return 0; |
775 | } | 778 | } |
776 | 779 | ||
777 | /** | 780 | /** |
778 | * @return a list with CPU frequencies supported by the hardware | 781 | * @return a list with CPU frequencies supported by the hardware |
779 | */ | 782 | */ |
780 | const QStrList &ODevice::allowedCpuFrequencies ( ) const | 783 | const QStrList &ODevice::allowedCpuFrequencies ( ) const |
781 | { | 784 | { |
782 | return *d->m_cpu_frequencies; | 785 | return *d->m_cpu_frequencies; |
783 | } | 786 | } |
784 | 787 | ||
785 | 788 | ||
786 | /** | 789 | /** |
787 | * Set desired CPU frequency | 790 | * Set desired CPU frequency |
788 | * | 791 | * |
789 | * @param index index into d->m_cpu_frequencies of the frequency to be set | 792 | * @param index index into d->m_cpu_frequencies of the frequency to be set |
790 | */ | 793 | */ |
791 | bool ODevice::setCurrentCpuFrequency(uint index) | 794 | bool ODevice::setCurrentCpuFrequency(uint index) |
792 | { | 795 | { |
793 | if (index >= d->m_cpu_frequencies->count()) | 796 | if (index >= d->m_cpu_frequencies->count()) |
794 | return false; | 797 | return false; |
795 | 798 | ||
796 | char *freq = d->m_cpu_frequencies->at(index); | 799 | char *freq = d->m_cpu_frequencies->at(index); |
797 | qWarning("set freq to %s", freq); | 800 | qWarning("set freq to %s", freq); |
798 | 801 | ||
799 | int fd; | 802 | int fd; |
800 | 803 | ||
801 | if ((fd = ::open("/proc/sys/cpu/0/speed", O_WRONLY)) >= 0) { | 804 | if ((fd = ::open("/proc/sys/cpu/0/speed", O_WRONLY)) >= 0) { |
802 | char writeCommand[50]; | 805 | char writeCommand[50]; |
803 | const int count = sprintf(writeCommand, "%s\n", freq); | 806 | const int count = sprintf(writeCommand, "%s\n", freq); |
804 | int res = (::write(fd, writeCommand, count) != -1); | 807 | int res = (::write(fd, writeCommand, count) != -1); |
805 | ::close(fd); | 808 | ::close(fd); |
806 | return res; | 809 | return res; |
807 | } | 810 | } |
808 | 811 | ||
809 | return false; | 812 | return false; |
810 | } | 813 | } |
811 | 814 | ||
812 | 815 | ||
813 | /** | 816 | /** |
814 | * @return a list of hardware buttons | 817 | * @return a list of hardware buttons |
815 | */ | 818 | */ |
816 | const QValueList <ODeviceButton> &ODevice::buttons ( ) | 819 | const QValueList <ODeviceButton> &ODevice::buttons ( ) |
817 | { | 820 | { |
818 | initButtons ( ); | 821 | initButtons ( ); |
819 | 822 | ||
820 | return *d-> m_buttons; | 823 | return *d-> m_buttons; |
821 | } | 824 | } |
822 | 825 | ||
823 | /** | 826 | /** |
824 | * @return The amount of time that would count as a hold | 827 | * @return The amount of time that would count as a hold |
825 | */ | 828 | */ |
826 | uint ODevice::buttonHoldTime ( ) const | 829 | uint ODevice::buttonHoldTime ( ) const |
827 | { | 830 | { |
828 | return d-> m_holdtime; | 831 | return d-> m_holdtime; |
829 | } | 832 | } |
830 | 833 | ||
831 | /** | 834 | /** |
832 | * This method return a ODeviceButton for a key code | 835 | * This method return a ODeviceButton for a key code |
833 | * or 0 if no special hardware button is available for the device | 836 | * or 0 if no special hardware button is available for the device |
834 | * | 837 | * |
835 | * @return The devicebutton or 0l | 838 | * @return The devicebutton or 0l |
836 | * @see ODeviceButton | 839 | * @see ODeviceButton |
837 | */ | 840 | */ |
838 | const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) | 841 | const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) |
839 | { | 842 | { |
840 | initButtons ( ); | 843 | initButtons ( ); |
841 | 844 | ||
842 | for ( QValueListConstIterator<ODeviceButton> it = d-> m_buttons-> begin ( ); it != d-> m_buttons-> end ( ); ++it ) { | 845 | for ( QValueListConstIterator<ODeviceButton> it = d-> m_buttons-> begin ( ); it != d-> m_buttons-> end ( ); ++it ) { |
843 | if ( (*it). keycode ( ) == code ) | 846 | if ( (*it). keycode ( ) == code ) |
844 | return &(*it); | 847 | return &(*it); |
845 | } | 848 | } |
846 | return 0; | 849 | return 0; |
847 | } | 850 | } |
848 | 851 | ||
849 | void ODevice::reloadButtonMapping ( ) | 852 | void ODevice::reloadButtonMapping ( ) |
850 | { | 853 | { |
851 | initButtons ( ); | 854 | initButtons ( ); |
852 | 855 | ||
853 | Config cfg ( "ButtonSettings" ); | 856 | Config cfg ( "ButtonSettings" ); |
854 | 857 | ||
855 | for ( uint i = 0; i < d-> m_buttons-> count ( ); i++ ) { | 858 | for ( uint i = 0; i < d-> m_buttons-> count ( ); i++ ) { |
856 | ODeviceButton &b = ( *d-> m_buttons ) [i]; | 859 | ODeviceButton &b = ( *d-> m_buttons ) [i]; |
857 | QString group = "Button" + QString::number ( i ); | 860 | QString group = "Button" + QString::number ( i ); |
858 | 861 | ||
859 | QCString pch, hch; | 862 | QCString pch, hch; |
860 | QCString pm, hm; | 863 | QCString pm, hm; |
861 | QByteArray pdata, hdata; | 864 | QByteArray pdata, hdata; |
862 | 865 | ||
863 | if ( cfg. hasGroup ( group )) { | 866 | if ( cfg. hasGroup ( group )) { |
864 | cfg. setGroup ( group ); | 867 | cfg. setGroup ( group ); |
865 | pch = cfg. readEntry ( "PressedActionChannel" ). latin1 ( ); | 868 | pch = cfg. readEntry ( "PressedActionChannel" ). latin1 ( ); |
866 | pm = cfg. readEntry ( "PressedActionMessage" ). latin1 ( ); | 869 | pm = cfg. readEntry ( "PressedActionMessage" ). latin1 ( ); |
867 | // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" )); | 870 | // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" )); |
868 | 871 | ||
869 | hch = cfg. readEntry ( "HeldActionChannel" ). latin1 ( ); | 872 | hch = cfg. readEntry ( "HeldActionChannel" ). latin1 ( ); |
870 | hm = cfg. readEntry ( "HeldActionMessage" ). latin1 ( ); | 873 | hm = cfg. readEntry ( "HeldActionMessage" ). latin1 ( ); |
871 | // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" )); | 874 | // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" )); |
872 | } | 875 | } |
873 | 876 | ||
874 | b. setPressedAction ( OQCopMessage ( pch, pm, pdata )); | 877 | b. setPressedAction ( OQCopMessage ( pch, pm, pdata )); |
875 | 878 | ||
876 | b. setHeldAction ( OQCopMessage ( hch, hm, hdata )); | 879 | b. setHeldAction ( OQCopMessage ( hch, hm, hdata )); |
877 | } | 880 | } |
878 | } | 881 | } |
879 | 882 | ||
880 | void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) | 883 | void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) |
881 | { | 884 | { |
882 | initButtons ( ); | 885 | initButtons ( ); |
883 | 886 | ||
884 | QString mb_chan; | 887 | QString mb_chan; |
885 | 888 | ||
886 | if ( button >= (int) d-> m_buttons-> count ( )) | 889 | if ( button >= (int) d-> m_buttons-> count ( )) |
887 | return; | 890 | return; |
888 | 891 | ||
889 | ODeviceButton &b = ( *d-> m_buttons ) [button]; | 892 | ODeviceButton &b = ( *d-> m_buttons ) [button]; |
890 | b. setPressedAction ( action ); | 893 | b. setPressedAction ( action ); |
891 | 894 | ||
892 | mb_chan=b. pressedAction ( ). channel ( ); | 895 | mb_chan=b. pressedAction ( ). channel ( ); |
893 | 896 | ||
894 | Config buttonFile ( "ButtonSettings" ); | 897 | Config buttonFile ( "ButtonSettings" ); |
895 | buttonFile. setGroup ( "Button" + QString::number ( button )); | 898 | buttonFile. setGroup ( "Button" + QString::number ( button )); |
896 | buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan); | 899 | buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan); |
897 | buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction ( ). message ( )); | 900 | buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction ( ). message ( )); |
898 | 901 | ||
899 | //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction ( ). data ( ))); | 902 | //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction ( ). data ( ))); |
900 | 903 | ||
901 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); | 904 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); |
902 | } | 905 | } |
903 | 906 | ||
904 | void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) | 907 | void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) |
905 | { | 908 | { |
906 | initButtons ( ); | 909 | initButtons ( ); |
907 | 910 | ||
908 | if ( button >= (int) d-> m_buttons-> count ( )) | 911 | if ( button >= (int) d-> m_buttons-> count ( )) |
909 | return; | 912 | return; |
910 | 913 | ||
911 | ODeviceButton &b = ( *d-> m_buttons ) [button]; | 914 | ODeviceButton &b = ( *d-> m_buttons ) [button]; |
912 | b. setHeldAction ( action ); | 915 | b. setHeldAction ( action ); |
913 | 916 | ||
914 | Config buttonFile ( "ButtonSettings" ); | 917 | Config buttonFile ( "ButtonSettings" ); |
915 | buttonFile. setGroup ( "Button" + QString::number ( button )); | 918 | buttonFile. setGroup ( "Button" + QString::number ( button )); |
916 | buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( )); | 919 | buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( )); |
917 | buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( )); | 920 | buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( )); |
918 | 921 | ||
919 | //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction ( ). data ( ))); | 922 | //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction ( ). data ( ))); |
920 | 923 | ||
921 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); | 924 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); |
922 | } | 925 | } |
923 | void ODevice::virtual_hook( int id, void* data ) { | 926 | void ODevice::virtual_hook(int, void* ){ |
924 | Q_UNUSED(id); | ||
925 | Q_UNUSED(data); | ||
926 | } | ||
927 | 927 | ||
928 | } | ||
928 | 929 | ||
929 | 930 | ||
930 | /************************************************** | 931 | /************************************************** |
931 | * | 932 | * |
932 | * iPAQ | 933 | * iPAQ |
933 | * | 934 | * |
934 | **************************************************/ | 935 | **************************************************/ |
935 | 936 | ||
936 | void iPAQ::init ( ) | 937 | void iPAQ::init ( ) |
937 | { | 938 | { |
938 | d-> m_vendorstr = "HP"; | 939 | d-> m_vendorstr = "HP"; |
939 | d-> m_vendor = Vendor_HP; | 940 | d-> m_vendor = Vendor_HP; |
940 | 941 | ||
941 | QFile f ( "/proc/hal/model" ); | 942 | QFile f ( "/proc/hal/model" ); |
942 | 943 | ||
943 | if ( f. open ( IO_ReadOnly )) { | 944 | if ( f. open ( IO_ReadOnly )) { |
944 | QTextStream ts ( &f ); | 945 | QTextStream ts ( &f ); |
945 | 946 | ||
946 | d-> m_modelstr = "H" + ts. readLine ( ); | 947 | d-> m_modelstr = "H" + ts. readLine ( ); |
947 | 948 | ||
948 | if ( d-> m_modelstr == "H3100" ) | 949 | if ( d-> m_modelstr == "H3100" ) |
949 | d-> m_model = Model_iPAQ_H31xx; | 950 | d-> m_model = Model_iPAQ_H31xx; |
950 | else if ( d-> m_modelstr == "H3600" ) | 951 | else if ( d-> m_modelstr == "H3600" ) |
951 | d-> m_model = Model_iPAQ_H36xx; | 952 | d-> m_model = Model_iPAQ_H36xx; |
952 | else if ( d-> m_modelstr == "H3700" ) | 953 | else if ( d-> m_modelstr == "H3700" ) |
953 | d-> m_model = Model_iPAQ_H37xx; | 954 | d-> m_model = Model_iPAQ_H37xx; |
954 | else if ( d-> m_modelstr == "H3800" ) | 955 | else if ( d-> m_modelstr == "H3800" ) |
955 | d-> m_model = Model_iPAQ_H38xx; | 956 | d-> m_model = Model_iPAQ_H38xx; |
956 | else if ( d-> m_modelstr == "H3900" ) | 957 | else if ( d-> m_modelstr == "H3900" ) |
957 | d-> m_model = Model_iPAQ_H39xx; | 958 | d-> m_model = Model_iPAQ_H39xx; |
958 | else | 959 | else |
959 | d-> m_model = Model_Unknown; | 960 | d-> m_model = Model_Unknown; |
960 | 961 | ||
961 | f. close ( ); | 962 | f. close ( ); |
962 | } | 963 | } |
963 | 964 | ||
964 | switch ( d-> m_model ) { | 965 | switch ( d-> m_model ) { |
965 | case Model_iPAQ_H31xx: | 966 | case Model_iPAQ_H31xx: |
966 | case Model_iPAQ_H38xx: | 967 | case Model_iPAQ_H38xx: |
967 | d-> m_rotation = Rot90; | 968 | d-> m_rotation = Rot90; |
968 | break; | 969 | break; |
969 | case Model_iPAQ_H36xx: | 970 | case Model_iPAQ_H36xx: |
970 | case Model_iPAQ_H37xx: | 971 | case Model_iPAQ_H37xx: |
971 | case Model_iPAQ_H39xx: | 972 | case Model_iPAQ_H39xx: |
972 | default: | 973 | default: |
973 | d-> m_rotation = Rot270; | 974 | d-> m_rotation = Rot270; |
974 | break; | 975 | break; |
975 | } | 976 | } |
976 | 977 | ||
977 | f. setName ( "/etc/familiar-version" ); | 978 | f. setName ( "/etc/familiar-version" ); |
978 | if ( f. open ( IO_ReadOnly )) { | 979 | if ( f. open ( IO_ReadOnly )) { |
979 | d-> m_systemstr = "Familiar"; | 980 | d-> m_systemstr = "Familiar"; |
980 | d-> m_system = System_Familiar; | 981 | d-> m_system = System_Familiar; |
981 | 982 | ||
982 | QTextStream ts ( &f ); | 983 | QTextStream ts ( &f ); |
983 | d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); | 984 | d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); |
984 | 985 | ||
985 | f. close ( ); | 986 | f. close ( ); |
986 | } else { | 987 | } else { |
987 | f. setName ( "/etc/oz_version" ); | 988 | f. setName ( "/etc/oz_version" ); |
988 | 989 | ||
989 | if ( f. open ( IO_ReadOnly )) { | 990 | if ( f. open ( IO_ReadOnly )) { |
990 | d-> m_systemstr = "OpenEmbedded/iPaq"; | 991 | d-> m_systemstr = "OpenEmbedded/iPaq"; |
991 | d-> m_system = System_Familiar; | 992 | d-> m_system = System_Familiar; |
992 | 993 | ||
993 | QTextStream ts ( &f ); | 994 | QTextStream ts ( &f ); |
994 | ts.setDevice ( &f ); | 995 | ts.setDevice ( &f ); |
995 | d-> m_sysverstr = ts. readLine ( ); | 996 | d-> m_sysverstr = ts. readLine ( ); |
996 | f. close ( ); | 997 | f. close ( ); |
997 | } | 998 | } |
998 | } | 999 | } |
999 | 1000 | ||
1000 | 1001 | ||
1001 | 1002 | ||
1002 | 1003 | ||
1003 | 1004 | ||
1004 | m_leds [0] = m_leds [1] = Led_Off; | 1005 | m_leds [0] = m_leds [1] = Led_Off; |
1005 | 1006 | ||
1006 | m_power_timer = 0; | 1007 | m_power_timer = 0; |
1007 | 1008 | ||
1008 | } | 1009 | } |
1009 | 1010 | ||
1010 | void iPAQ::initButtons ( ) | 1011 | void iPAQ::initButtons ( ) |
1011 | { | 1012 | { |
1012 | if ( d-> m_buttons ) | 1013 | if ( d-> m_buttons ) |
1013 | return; | 1014 | return; |
1014 | 1015 | ||
1015 | if ( isQWS( ) ) | 1016 | if ( isQWS( ) ) |
1016 | QWSServer::setKeyboardFilter ( this ); | 1017 | QWSServer::setKeyboardFilter ( this ); |
1017 | 1018 | ||
1018 | d-> m_buttons = new QValueList <ODeviceButton>; | 1019 | d-> m_buttons = new QValueList <ODeviceButton>; |
1019 | 1020 | ||
1020 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { | 1021 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { |
1021 | i_button *ib = ipaq_buttons + i; | 1022 | i_button *ib = ipaq_buttons + i; |
1022 | ODeviceButton b; | 1023 | ODeviceButton b; |
1023 | 1024 | ||
1024 | if (( ib-> model & d-> m_model ) == d-> m_model ) { | 1025 | if (( ib-> model & d-> m_model ) == d-> m_model ) { |
1025 | b. setKeycode ( ib-> code ); | 1026 | b. setKeycode ( ib-> code ); |
1026 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); | 1027 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); |
1027 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); | 1028 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); |
1028 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); | 1029 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); |
1029 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); | 1030 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); |
1030 | 1031 | ||
1031 | d-> m_buttons-> append ( b ); | 1032 | d-> m_buttons-> append ( b ); |
1032 | } | 1033 | } |
1033 | } | 1034 | } |
1034 | reloadButtonMapping ( ); | 1035 | reloadButtonMapping ( ); |
1035 | 1036 | ||
1036 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); | 1037 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); |
1037 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); | 1038 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); |
1038 | } | 1039 | } |
1039 | 1040 | ||
1040 | 1041 | ||
1041 | //#include <linux/h3600_ts.h> // including kernel headers is evil ... | 1042 | //#include <linux/h3600_ts.h> // including kernel headers is evil ... |
1042 | 1043 | ||
1043 | typedef struct { | 1044 | typedef struct { |
1044 | unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ | 1045 | unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ |
1045 | unsigned char TotalTime; /* Units of 5 seconds */ | 1046 | unsigned char TotalTime; /* Units of 5 seconds */ |
1046 | unsigned char OnTime; /* units of 100m/s */ | 1047 | unsigned char OnTime; /* units of 100m/s */ |
1047 | unsigned char OffTime; /* units of 100m/s */ | 1048 | unsigned char OffTime; /* units of 100m/s */ |
1048 | } LED_IN; | 1049 | } LED_IN; |
1049 | 1050 | ||
1050 | typedef struct { | 1051 | typedef struct { |
1051 | unsigned char mode; | 1052 | unsigned char mode; |
1052 | unsigned char pwr; | 1053 | unsigned char pwr; |
1053 | unsigned char brightness; | 1054 | unsigned char brightness; |
1054 | } FLITE_IN; | 1055 | } FLITE_IN; |
1055 | 1056 | ||
1056 | #define LED_ON OD_IOW( 'f', 5, LED_IN ) | 1057 | #define LED_ON OD_IOW( 'f', 5, LED_IN ) |
1057 | #define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) | 1058 | #define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) |
1058 | 1059 | ||
1059 | 1060 | ||
1060 | QValueList <OLed> iPAQ::ledList ( ) const | 1061 | QValueList <OLed> iPAQ::ledList ( ) const |
1061 | { | 1062 | { |
1062 | QValueList <OLed> vl; | 1063 | QValueList <OLed> vl; |
1063 | vl << Led_Power; | 1064 | vl << Led_Power; |
1064 | 1065 | ||
1065 | if ( d-> m_model == Model_iPAQ_H38xx ) | 1066 | if ( d-> m_model == Model_iPAQ_H38xx ) |
1066 | vl << Led_BlueTooth; | 1067 | vl << Led_BlueTooth; |
1067 | return vl; | 1068 | return vl; |
1068 | } | 1069 | } |
1069 | 1070 | ||
1070 | QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const | 1071 | QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const |
1071 | { | 1072 | { |
1072 | QValueList <OLedState> vl; | 1073 | QValueList <OLedState> vl; |
1073 | 1074 | ||
1074 | if ( l == Led_Power ) | 1075 | if ( l == Led_Power ) |
1075 | vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast; | 1076 | vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast; |
1076 | else if ( l == Led_BlueTooth && d-> m_model == Model_iPAQ_H38xx ) | 1077 | else if ( l == Led_BlueTooth && d-> m_model == Model_iPAQ_H38xx ) |
1077 | vl << Led_Off; // << Led_On << ??? | 1078 | vl << Led_Off; // << Led_On << ??? |
1078 | 1079 | ||
1079 | return vl; | 1080 | return vl; |
1080 | } | 1081 | } |
1081 | 1082 | ||
1082 | OLedState iPAQ::ledState ( OLed l ) const | 1083 | OLedState iPAQ::ledState ( OLed l ) const |
1083 | { | 1084 | { |
1084 | switch ( l ) { | 1085 | switch ( l ) { |
1085 | case Led_Power: | 1086 | case Led_Power: |
1086 | return m_leds [0]; | 1087 | return m_leds [0]; |
1087 | case Led_BlueTooth: | 1088 | case Led_BlueTooth: |
1088 | return m_leds [1]; | 1089 | return m_leds [1]; |
1089 | default: | 1090 | default: |
1090 | return Led_Off; | 1091 | return Led_Off; |
1091 | } | 1092 | } |
1092 | } | 1093 | } |
1093 | 1094 | ||
1094 | bool iPAQ::setLedState ( OLed l, OLedState st ) | 1095 | bool iPAQ::setLedState ( OLed l, OLedState st ) |
1095 | { | 1096 | { |
1096 | static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK ); | 1097 | static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK ); |
1097 | 1098 | ||
1098 | if ( l == Led_Power ) { | 1099 | if ( l == Led_Power ) { |
1099 | if ( fd >= 0 ) { | 1100 | if ( fd >= 0 ) { |
1100 | LED_IN leds; | 1101 | LED_IN leds; |
1101 | ::memset ( &leds, 0, sizeof( leds )); | 1102 | ::memset ( &leds, 0, sizeof( leds )); |
1102 | leds. TotalTime = 0; | 1103 | leds. TotalTime = 0; |
1103 | leds. OnTime = 0; | 1104 | leds. OnTime = 0; |
1104 | leds. OffTime = 1; | 1105 | leds. OffTime = 1; |
1105 | leds. OffOnBlink = 2; | 1106 | leds. OffOnBlink = 2; |
1106 | 1107 | ||
1107 | switch ( st ) { | 1108 | switch ( st ) { |
1108 | case Led_Off : leds. OffOnBlink = 0; break; | 1109 | case Led_Off : leds. OffOnBlink = 0; break; |
1109 | case Led_On : leds. OffOnBlink = 1; break; | 1110 | case Led_On : leds. OffOnBlink = 1; break; |
1110 | case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; | 1111 | case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; |
1111 | case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; | 1112 | case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; |
1112 | } | 1113 | } |
1113 | 1114 | ||
1114 | if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { | 1115 | if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { |
1115 | m_leds [0] = st; | 1116 | m_leds [0] = st; |
1116 | return true; | 1117 | return true; |
1117 | } | 1118 | } |
1118 | } | 1119 | } |
1119 | } | 1120 | } |
1120 | return false; | 1121 | return false; |
1121 | } | 1122 | } |
1122 | 1123 | ||
1123 | 1124 | ||
1124 | bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) | 1125 | bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) |
1125 | { | 1126 | { |
1126 | int newkeycode = keycode; | 1127 | int newkeycode = keycode; |
1127 | 1128 | ||
1128 | switch ( keycode ) { | 1129 | switch ( keycode ) { |
1129 | // H38xx/H39xx have no "Q" key anymore - this is now the Mail key | 1130 | // H38xx/H39xx have no "Q" key anymore - this is now the Mail key |
1130 | case HardKey_Menu: { | 1131 | case HardKey_Menu: { |
1131 | if (( d-> m_model == Model_iPAQ_H38xx ) || | 1132 | if (( d-> m_model == Model_iPAQ_H38xx ) || |
1132 | ( d-> m_model == Model_iPAQ_H39xx )) { | 1133 | ( d-> m_model == Model_iPAQ_H39xx )) { |
1133 | newkeycode = HardKey_Mail; | 1134 | newkeycode = HardKey_Mail; |
1134 | } | 1135 | } |
1135 | break; | 1136 | break; |
1136 | } | 1137 | } |
1137 | 1138 | ||
1138 | // Rotate cursor keys 180° | 1139 | // Rotate cursor keys 180° |
1139 | case Key_Left : | 1140 | case Key_Left : |
1140 | case Key_Right: | 1141 | case Key_Right: |
1141 | case Key_Up : | 1142 | case Key_Up : |
1142 | case Key_Down : { | 1143 | case Key_Down : { |
1143 | if (( d-> m_model == Model_iPAQ_H31xx ) || | 1144 | if (( d-> m_model == Model_iPAQ_H31xx ) || |
1144 | ( d-> m_model == Model_iPAQ_H38xx )) { | 1145 | ( d-> m_model == Model_iPAQ_H38xx )) { |
1145 | newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4; | 1146 | newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4; |
1146 | } | 1147 | } |
1147 | break; | 1148 | break; |
1148 | } | 1149 | } |
1149 | 1150 | ||
1150 | // map Power Button short/long press to F34/F35 | 1151 | // map Power Button short/long press to F34/F35 |
1151 | case Key_SysReq: { | 1152 | case Key_SysReq: { |
1152 | if ( isPress ) { | 1153 | if ( isPress ) { |
1153 | if ( m_power_timer ) | 1154 | if ( m_power_timer ) |
1154 | killTimer ( m_power_timer ); | 1155 | killTimer ( m_power_timer ); |
1155 | m_power_timer = startTimer ( 500 ); | 1156 | m_power_timer = startTimer ( 500 ); |
1156 | } | 1157 | } |
1157 | else if ( m_power_timer ) { | 1158 | else if ( m_power_timer ) { |
1158 | killTimer ( m_power_timer ); | 1159 | killTimer ( m_power_timer ); |
1159 | m_power_timer = 0; | 1160 | m_power_timer = 0; |
1160 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); | 1161 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); |
1161 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); | 1162 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); |
1162 | } | 1163 | } |
1163 | newkeycode = Key_unknown; | 1164 | newkeycode = Key_unknown; |
1164 | break; | 1165 | break; |
1165 | } | 1166 | } |
1166 | } | 1167 | } |
1167 | 1168 | ||
1168 | if ( newkeycode != keycode ) { | 1169 | if ( newkeycode != keycode ) { |
1169 | if ( newkeycode != Key_unknown ) | 1170 | if ( newkeycode != Key_unknown ) |
1170 | QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); | 1171 | QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); |
1171 | return true; | 1172 | return true; |
1172 | } | 1173 | } |
1173 | else | 1174 | else |
1174 | return false; | 1175 | return false; |
1175 | } | 1176 | } |
1176 | 1177 | ||
1177 | void iPAQ::timerEvent ( QTimerEvent * ) | 1178 | void iPAQ::timerEvent ( QTimerEvent * ) |
1178 | { | 1179 | { |
1179 | killTimer ( m_power_timer ); | 1180 | killTimer ( m_power_timer ); |
1180 | m_power_timer = 0; | 1181 | m_power_timer = 0; |
1181 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); | 1182 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); |
1182 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); | 1183 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); |
1183 | } | 1184 | } |
1184 | 1185 | ||
1185 | 1186 | ||
1186 | void iPAQ::alarmSound ( ) | 1187 | void iPAQ::alarmSound ( ) |
1187 | { | 1188 | { |
1188 | #ifndef QT_NO_SOUND | 1189 | #ifndef QT_NO_SOUND |
1189 | static Sound snd ( "alarm" ); | 1190 | static Sound snd ( "alarm" ); |
1190 | int fd; | 1191 | int fd; |
1191 | int vol; | 1192 | int vol; |
1192 | bool vol_reset = false; | 1193 | bool vol_reset = false; |
1193 | 1194 | ||
1194 | if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { | 1195 | if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { |
1195 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { | 1196 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { |
1196 | Config cfg ( "qpe" ); | 1197 | Config cfg ( "qpe" ); |
1197 | cfg. setGroup ( "Volume" ); | 1198 | cfg. setGroup ( "Volume" ); |
1198 | 1199 | ||
1199 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); | 1200 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); |
1200 | if ( volalarm < 0 ) | 1201 | if ( volalarm < 0 ) |
1201 | volalarm = 0; | 1202 | volalarm = 0; |
1202 | else if ( volalarm > 100 ) | 1203 | else if ( volalarm > 100 ) |
1203 | volalarm = 100; | 1204 | volalarm = 100; |
1204 | volalarm |= ( volalarm << 8 ); | 1205 | volalarm |= ( volalarm << 8 ); |
1205 | 1206 | ||
1206 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) | 1207 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) |
1207 | vol_reset = true; | 1208 | vol_reset = true; |
1208 | } | 1209 | } |
1209 | } | 1210 | } |
1210 | 1211 | ||
1211 | snd. play ( ); | 1212 | snd. play ( ); |
1212 | while ( !snd. isFinished ( )) | 1213 | while ( !snd. isFinished ( )) |
1213 | qApp-> processEvents ( ); | 1214 | qApp-> processEvents ( ); |
1214 | 1215 | ||
1215 | if ( fd >= 0 ) { | 1216 | if ( fd >= 0 ) { |
1216 | if ( vol_reset ) | 1217 | if ( vol_reset ) |
1217 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); | 1218 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); |
1218 | ::close ( fd ); | 1219 | ::close ( fd ); |
1219 | } | 1220 | } |
1220 | #endif | 1221 | #endif |
1221 | } | 1222 | } |
1222 | 1223 | ||
1223 | 1224 | ||
1224 | bool iPAQ::setSoftSuspend ( bool soft ) | 1225 | bool iPAQ::setSoftSuspend ( bool soft ) |
1225 | { | 1226 | { |
1226 | bool res = false; | 1227 | bool res = false; |
1227 | int fd; | 1228 | int fd; |
1228 | 1229 | ||
1229 | if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { | 1230 | if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { |
1230 | if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) | 1231 | if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) |
1231 | res = true; | 1232 | res = true; |
1232 | else | 1233 | else |
1233 | ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); | 1234 | ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); |
1234 | 1235 | ||
1235 | ::close ( fd ); | 1236 | ::close ( fd ); |
1236 | } | 1237 | } |
1237 | else | 1238 | else |
1238 | ::perror ( "/proc/sys/ts/suspend_button_mode" ); | 1239 | ::perror ( "/proc/sys/ts/suspend_button_mode" ); |
1239 | 1240 | ||
1240 | return res; | 1241 | return res; |
1241 | } | 1242 | } |
1242 | 1243 | ||
1243 | 1244 | ||
1244 | bool iPAQ::setDisplayBrightness ( int bright ) | 1245 | bool iPAQ::setDisplayBrightness ( int bright ) |
1245 | { | 1246 | { |
1246 | bool res = false; | 1247 | bool res = false; |
1247 | int fd; | 1248 | int fd; |
1248 | 1249 | ||
1249 | if ( bright > 255 ) | 1250 | if ( bright > 255 ) |
1250 | bright = 255; | 1251 | bright = 255; |
1251 | if ( bright < 0 ) | 1252 | if ( bright < 0 ) |
1252 | bright = 0; | 1253 | bright = 0; |
1253 | 1254 | ||
1254 | if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { | 1255 | if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { |
1255 | FLITE_IN bl; | 1256 | FLITE_IN bl; |
1256 | bl. mode = 1; | 1257 | bl. mode = 1; |
1257 | bl. pwr = bright ? 1 : 0; | 1258 | bl. pwr = bright ? 1 : 0; |
1258 | bl. brightness = ( bright * ( displayBrightnessResolution ( ) - 1 ) + 127 ) / 255; | 1259 | bl. brightness = ( bright * ( displayBrightnessResolution ( ) - 1 ) + 127 ) / 255; |
1259 | res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); | 1260 | res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); |
1260 | ::close ( fd ); | 1261 | ::close ( fd ); |
1261 | } | 1262 | } |
1262 | return res; | 1263 | return res; |
1263 | } | 1264 | } |
1264 | 1265 | ||
1265 | int iPAQ::displayBrightnessResolution ( ) const | 1266 | int iPAQ::displayBrightnessResolution ( ) const |
1266 | { | 1267 | { |
1267 | switch ( model ( )) { | 1268 | switch ( model ( )) { |
1268 | case Model_iPAQ_H31xx: | 1269 | case Model_iPAQ_H31xx: |
1269 | case Model_iPAQ_H36xx: | 1270 | case Model_iPAQ_H36xx: |
1270 | case Model_iPAQ_H37xx: | 1271 | case Model_iPAQ_H37xx: |
1271 | return 128; // really 256, but >128 could damage the LCD | 1272 | return 128; // really 256, but >128 could damage the LCD |
1272 | 1273 | ||
1273 | case Model_iPAQ_H38xx: | 1274 | case Model_iPAQ_H38xx: |
1274 | case Model_iPAQ_H39xx: | 1275 | case Model_iPAQ_H39xx: |
1275 | return 64; | 1276 | return 64; |
1276 | 1277 | ||
1277 | default: | 1278 | default: |
1278 | return 2; | 1279 | return 2; |
1279 | } | 1280 | } |
1280 | } | 1281 | } |
1281 | 1282 | ||
1282 | 1283 | ||
1283 | bool iPAQ::hasLightSensor ( ) const | 1284 | bool iPAQ::hasLightSensor ( ) const |
1284 | { | 1285 | { |
1285 | return true; | 1286 | return true; |
1286 | } | 1287 | } |
1287 | 1288 | ||
1288 | int iPAQ::readLightSensor ( ) | 1289 | int iPAQ::readLightSensor ( ) |
1289 | { | 1290 | { |
1290 | int fd; | 1291 | int fd; |
1291 | int val = -1; | 1292 | int val = -1; |
1292 | 1293 | ||
1293 | if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) { | 1294 | if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) { |
1294 | char buffer [8]; | 1295 | char buffer [8]; |
1295 | 1296 | ||
1296 | if ( ::read ( fd, buffer, 5 ) == 5 ) { | 1297 | if ( ::read ( fd, buffer, 5 ) == 5 ) { |
1297 | char *endptr; | 1298 | char *endptr; |
1298 | 1299 | ||
1299 | buffer [4] = 0; | 1300 | buffer [4] = 0; |
1300 | val = ::strtol ( buffer + 2, &endptr, 16 ); | 1301 | val = ::strtol ( buffer + 2, &endptr, 16 ); |
1301 | 1302 | ||
1302 | if ( *endptr != 0 ) | 1303 | if ( *endptr != 0 ) |
1303 | val = -1; | 1304 | val = -1; |
1304 | } | 1305 | } |
1305 | ::close ( fd ); | 1306 | ::close ( fd ); |
1306 | } | 1307 | } |
1307 | 1308 | ||
1308 | return val; | 1309 | return val; |
1309 | } | 1310 | } |
1310 | 1311 | ||
1311 | int iPAQ::lightSensorResolution ( ) const | 1312 | int iPAQ::lightSensorResolution ( ) const |
1312 | { | 1313 | { |
1313 | return 256; | 1314 | return 256; |
1314 | } | 1315 | } |
1315 | 1316 | ||
1316 | /************************************************** | 1317 | /************************************************** |
1317 | * | 1318 | * |
1318 | * Zaurus | 1319 | * Zaurus |
1319 | * | 1320 | * |
1320 | **************************************************/ | 1321 | **************************************************/ |
1321 | 1322 | ||
1322 | 1323 | ||
1323 | 1324 | ||
1324 | void Zaurus::init ( ) | 1325 | void Zaurus::init ( ) |
1325 | { | 1326 | { |
1326 | d-> m_vendorstr = "Sharp"; | 1327 | d-> m_vendorstr = "Sharp"; |
1327 | d-> m_vendor = Vendor_Sharp; | 1328 | d-> m_vendor = Vendor_Sharp; |
1328 | 1329 | ||
1329 | QFile f ( "/proc/filesystems" ); | 1330 | QFile f ( "/proc/filesystems" ); |
1330 | QString model; | 1331 | QString model; |
1331 | 1332 | ||
1332 | if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) { | 1333 | if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) { |
1333 | d-> m_vendorstr = "OpenZaurus Team"; | 1334 | d-> m_vendorstr = "OpenZaurus Team"; |
1334 | d-> m_systemstr = "OpenZaurus"; | 1335 | d-> m_systemstr = "OpenZaurus"; |
1335 | d-> m_system = System_OpenZaurus; | 1336 | d-> m_system = System_OpenZaurus; |
1336 | 1337 | ||
1337 | f. close ( ); | 1338 | f. close ( ); |
1338 | 1339 | ||
1339 | f. setName ( "/etc/oz_version" ); | 1340 | f. setName ( "/etc/oz_version" ); |
1340 | if ( f. open ( IO_ReadOnly )) { | 1341 | if ( f. open ( IO_ReadOnly )) { |
1341 | QTextStream ts ( &f ); | 1342 | QTextStream ts ( &f ); |
1342 | d-> m_sysverstr = ts. readLine ( );//. mid ( 10 ); | 1343 | d-> m_sysverstr = ts. readLine ( );//. mid ( 10 ); |
1343 | f. close ( ); | 1344 | f. close ( ); |
1344 | } | 1345 | } |
1345 | } | 1346 | } |
1346 | else { | 1347 | else { |
1347 | d-> m_systemstr = "Zaurus"; | 1348 | d-> m_systemstr = "Zaurus"; |
1348 | d-> m_system = System_Zaurus; | 1349 | d-> m_system = System_Zaurus; |
1349 | } | 1350 | } |
1350 | 1351 | ||
1351 | f. setName ( "/proc/cpuinfo" ); | 1352 | f. setName ( "/proc/cpuinfo" ); |
1352 | if ( f. open ( IO_ReadOnly ) ) { | 1353 | if ( f. open ( IO_ReadOnly ) ) { |
1353 | QTextStream ts ( &f ); | 1354 | QTextStream ts ( &f ); |
1354 | QString line; | 1355 | QString line; |
1355 | while( line = ts. readLine ( ) ) { | 1356 | while( line = ts. readLine ( ) ) { |
1356 | if ( line. left ( 8 ) == "Hardware" ) | 1357 | if ( line. left ( 8 ) == "Hardware" ) |
1357 | break; | 1358 | break; |
1358 | } | 1359 | } |
1359 | int loc = line. find ( ":" ); | 1360 | int loc = line. find ( ":" ); |
1360 | if ( loc != -1 ) | 1361 | if ( loc != -1 ) |
1361 | model = line. mid ( loc + 2 ). simplifyWhiteSpace( ); | 1362 | model = line. mid ( loc + 2 ). simplifyWhiteSpace( ); |
1362 | } | 1363 | } |
1363 | 1364 | ||
1364 | if ( model == "SHARP Corgi" ) { | 1365 | if ( model == "SHARP Corgi" ) { |
1365 | d-> m_model = Model_Zaurus_SLC700; | 1366 | d-> m_model = Model_Zaurus_SLC700; |
1366 | d-> m_modelstr = "Zaurus SL-C700"; | 1367 | d-> m_modelstr = "Zaurus SL-C700"; |
1367 | } else if ( model == "SHARP Poodle" ) { | 1368 | } else if ( model == "SHARP Poodle" ) { |
1368 | d-> m_model = Model_Zaurus_SLB600; | 1369 | d-> m_model = Model_Zaurus_SLB600; |
1369 | d-> m_modelstr = "Zaurus SL-B500 or SL-5600"; | 1370 | d-> m_modelstr = "Zaurus SL-B500 or SL-5600"; |
1370 | } else if ( model = "Sharp-Collie" ) { | 1371 | } else if ( model = "Sharp-Collie" ) { |
1371 | d-> m_model = Model_Zaurus_SL5500; | 1372 | d-> m_model = Model_Zaurus_SL5500; |
1372 | d-> m_modelstr = "Zaurus SL-5500 or SL-5000d"; | 1373 | d-> m_modelstr = "Zaurus SL-5500 or SL-5000d"; |
1373 | } else { | 1374 | } else { |
1374 | d-> m_model = Model_Zaurus_SL5500; | 1375 | d-> m_model = Model_Zaurus_SL5500; |
1375 | d-> m_modelstr = "Zaurus (Model unknown)"; | 1376 | d-> m_modelstr = "Zaurus (Model unknown)"; |
1376 | } | 1377 | } |
1377 | 1378 | ||
1378 | bool flipstate = false; | 1379 | bool flipstate = false; |
1379 | switch ( d-> m_model ) { | 1380 | switch ( d-> m_model ) { |
1380 | case Model_Zaurus_SLA300: | 1381 | case Model_Zaurus_SLA300: |
1381 | d-> m_rotation = Rot0; | 1382 | d-> m_rotation = Rot0; |
1382 | break; | 1383 | break; |
1383 | case Model_Zaurus_SLC700: | 1384 | case Model_Zaurus_SLC700: |
1384 | // Note: need to 1) set flipstate based on physical screen orientation | 1385 | // Note: need to 1) set flipstate based on physical screen orientation |
1385 | // and 2) check to see if the user overrode the rotation direction | 1386 | // and 2) check to see if the user overrode the rotation direction |
1386 | // using appearance, and if so, remove that item from the Config to | 1387 | // using appearance, and if so, remove that item from the Config to |
1387 | // ensure the rotate applet flips us back to the previous state. | 1388 | // ensure the rotate applet flips us back to the previous state. |
1388 | if ( flipstate ) { | 1389 | if ( flipstate ) { |
1389 | // 480x640 | 1390 | // 480x640 |
1390 | d-> m_rotation = Rot0; | 1391 | d-> m_rotation = Rot0; |
1391 | d-> m_direction = CW; | 1392 | d-> m_direction = CW; |
1392 | } else { | 1393 | } else { |
1393 | // 640x480 | 1394 | // 640x480 |
1394 | d-> m_rotation = Rot270; | 1395 | d-> m_rotation = Rot270; |
1395 | d-> m_direction = CCW; | 1396 | d-> m_direction = CCW; |
1396 | } | 1397 | } |
1397 | break; | 1398 | break; |
1398 | case Model_Zaurus_SLB600: | 1399 | case Model_Zaurus_SLB600: |
1399 | case Model_Zaurus_SL5500: | 1400 | case Model_Zaurus_SL5500: |
1400 | case Model_Zaurus_SL5000: | 1401 | case Model_Zaurus_SL5000: |
1401 | default: | 1402 | default: |
1402 | d-> m_rotation = Rot270; | 1403 | d-> m_rotation = Rot270; |
1403 | break; | 1404 | break; |
1404 | } | 1405 | } |
1405 | m_leds [0] = Led_Off; | 1406 | m_leds [0] = Led_Off; |
1406 | } | 1407 | } |
1407 | 1408 | ||
1408 | void Zaurus::initButtons ( ) | 1409 | void Zaurus::initButtons ( ) |
1409 | { | 1410 | { |
1410 | if ( d-> m_buttons ) | 1411 | if ( d-> m_buttons ) |
1411 | return; | 1412 | return; |
1412 | 1413 | ||
1413 | d-> m_buttons = new QValueList <ODeviceButton>; | 1414 | d-> m_buttons = new QValueList <ODeviceButton>; |
1414 | 1415 | ||
1415 | struct z_button * pz_buttons; | 1416 | struct z_button * pz_buttons; |
1416 | int buttoncount; | 1417 | int buttoncount; |
1417 | switch ( d-> m_model ) { | 1418 | switch ( d-> m_model ) { |
1418 | case Model_Zaurus_SLC700: | 1419 | case Model_Zaurus_SLC700: |
1419 | pz_buttons = z_buttons_c700; | 1420 | pz_buttons = z_buttons_c700; |
1420 | buttoncount = ARRAY_SIZE(z_buttons_c700); | 1421 | buttoncount = ARRAY_SIZE(z_buttons_c700); |
1421 | break; | 1422 | break; |
1422 | default: | 1423 | default: |
1423 | pz_buttons = z_buttons; | 1424 | pz_buttons = z_buttons; |
1424 | buttoncount = ARRAY_SIZE(z_buttons); | 1425 | buttoncount = ARRAY_SIZE(z_buttons); |
1425 | break; | 1426 | break; |
1426 | } | 1427 | } |
1427 | 1428 | ||
1428 | for ( int i = 0; i < buttoncount; i++ ) { | 1429 | for ( int i = 0; i < buttoncount; i++ ) { |
1429 | struct z_button *zb = pz_buttons + i; | 1430 | struct z_button *zb = pz_buttons + i; |
1430 | ODeviceButton b; | 1431 | ODeviceButton b; |
1431 | 1432 | ||
1432 | b. setKeycode ( zb-> code ); | 1433 | b. setKeycode ( zb-> code ); |
1433 | b. setUserText ( QObject::tr ( "Button", zb-> utext )); | 1434 | b. setUserText ( QObject::tr ( "Button", zb-> utext )); |
1434 | b. setPixmap ( Resource::loadPixmap ( zb-> pix )); | 1435 | b. setPixmap ( Resource::loadPixmap ( zb-> pix )); |
1435 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb-> fpressedservice ), zb-> fpressedaction )); | 1436 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb-> fpressedservice ), zb-> fpressedaction )); |
1436 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb-> fheldservice ), zb-> fheldaction )); | 1437 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb-> fheldservice ), zb-> fheldaction )); |
1437 | 1438 | ||
1438 | d-> m_buttons-> append ( b ); | 1439 | d-> m_buttons-> append ( b ); |
1439 | } | 1440 | } |
1440 | 1441 | ||
1441 | reloadButtonMapping ( ); | 1442 | reloadButtonMapping ( ); |
1442 | 1443 | ||
1443 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); | 1444 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); |
1444 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); | 1445 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); |
1445 | } | 1446 | } |
1446 | 1447 | ||
1447 | #include <unistd.h> | 1448 | #include <unistd.h> |
1448 | #include <fcntl.h> | 1449 | #include <fcntl.h> |
1449 | #include <sys/ioctl.h> | 1450 | #include <sys/ioctl.h> |
1450 | 1451 | ||
1451 | //#include <asm/sharp_char.h> // including kernel headers is evil ... | 1452 | //#include <asm/sharp_char.h> // including kernel headers is evil ... |
1452 | 1453 | ||
1453 | #define SHARP_DEV_IOCTL_COMMAND_START 0x5680 | 1454 | #define SHARP_DEV_IOCTL_COMMAND_START 0x5680 |
1454 | 1455 | ||
1455 | #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 1456 | #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
1456 | #define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) | 1457 | #define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) |
1457 | 1458 | ||
1458 | #define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ | 1459 | #define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ |
1459 | #define SHARP_BUZ_KEYSOUND 2 /* key sound */ | 1460 | #define SHARP_BUZ_KEYSOUND 2 /* key sound */ |
1460 | #define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ | 1461 | #define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ |
1461 | 1462 | ||
1462 | /* --- for SHARP_BUZZER device --- */ | 1463 | /* --- for SHARP_BUZZER device --- */ |
1463 | 1464 | ||
1464 | //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 1465 | //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
1465 | //#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) | 1466 | //#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) |
1466 | 1467 | ||
1467 | #define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) | 1468 | #define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) |
1468 | #define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) | 1469 | #define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) |
1469 | #define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) | 1470 | #define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) |
1470 | #define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) | 1471 | #define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) |
1471 | #define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) | 1472 | #define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) |
1472 | 1473 | ||
1473 | //#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ | 1474 | //#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ |
1474 | //#define SHARP_BUZ_KEYSOUND 2 /* key sound */ | 1475 | //#define SHARP_BUZ_KEYSOUND 2 /* key sound */ |
1475 | 1476 | ||
1476 | //#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */ | 1477 | //#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */ |
1477 | //#define SHARP_PDA_WARNSOUND 4 /* warning occurred */ | 1478 | //#define SHARP_PDA_WARNSOUND 4 /* warning occurred */ |
1478 | //#define SHARP_PDA_ERRORSOUND 5 /* error occurred */ | 1479 | //#define SHARP_PDA_ERRORSOUND 5 /* error occurred */ |
1479 | //#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */ | 1480 | //#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */ |
1480 | //#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */ | 1481 | //#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */ |
1481 | //#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */ | 1482 | //#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */ |
1482 | //#define SHARP_PDA_APPSTART 9 /* application start */ | 1483 | //#define SHARP_PDA_APPSTART 9 /* application start */ |
1483 | //#define SHARP_PDA_APPQUIT 10 /* application ends */ | 1484 | //#define SHARP_PDA_APPQUIT 10 /* application ends */ |
1484 | 1485 | ||
1485 | //#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ | 1486 | //#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ |
1486 | //#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */ | 1487 | //#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */ |
1487 | //#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */ | 1488 | //#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */ |
1488 | //#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */ | 1489 | //#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */ |
1489 | // | 1490 | // |
1490 | 1491 | ||
1491 | #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 1492 | #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
1492 | #define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) | 1493 | #define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) |
1493 | 1494 | ||
1494 | typedef struct sharp_led_status { | 1495 | typedef struct sharp_led_status { |
1495 | int which; /* select which LED status is wanted. */ | 1496 | int which; /* select which LED status is wanted. */ |
1496 | int status; /* set new led status if you call SHARP_LED_SETSTATUS */ | 1497 | int status; /* set new led status if you call SHARP_LED_SETSTATUS */ |
1497 | } sharp_led_status; | 1498 | } sharp_led_status; |
1498 | 1499 | ||
1499 | #define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ | 1500 | #define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ |
1500 | 1501 | ||
1501 | #define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ | 1502 | #define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ |
1502 | #define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ | 1503 | #define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ |
1503 | #define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ | 1504 | #define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ |
1504 | 1505 | ||
1505 | // #include <asm/sharp_apm.h> // including kernel headers is evil ... | 1506 | // #include <asm/sharp_apm.h> // including kernel headers is evil ... |
1506 | 1507 | ||
1507 | #define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) | 1508 | #define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) |
1508 | #define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) | 1509 | #define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) |
1509 | #define APM_EVT_POWER_BUTTON (1 << 0) | 1510 | #define APM_EVT_POWER_BUTTON (1 << 0) |
1510 | 1511 | ||
1511 | #define FL_IOCTL_STEP_CONTRAST 100 | 1512 | #define FL_IOCTL_STEP_CONTRAST 100 |
1512 | 1513 | ||
1513 | 1514 | ||
1514 | void Zaurus::buzzer ( int sound ) | 1515 | void Zaurus::buzzer ( int sound ) |
1515 | { | 1516 | { |
1516 | int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); | 1517 | int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); |
1517 | 1518 | ||
1518 | if ( fd >= 0 ) { | 1519 | if ( fd >= 0 ) { |
1519 | ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); | 1520 | ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); |
1520 | ::close ( fd ); | 1521 | ::close ( fd ); |
1521 | } | 1522 | } |
1522 | } | 1523 | } |
1523 | 1524 | ||
1524 | 1525 | ||
1525 | void Zaurus::alarmSound ( ) | 1526 | void Zaurus::alarmSound ( ) |
1526 | { | 1527 | { |
1527 | buzzer ( SHARP_BUZ_SCHEDULE_ALARM ); | 1528 | buzzer ( SHARP_BUZ_SCHEDULE_ALARM ); |
1528 | } | 1529 | } |
1529 | 1530 | ||
1530 | void Zaurus::touchSound ( ) | 1531 | void Zaurus::touchSound ( ) |
1531 | { | 1532 | { |
1532 | buzzer ( SHARP_BUZ_TOUCHSOUND ); | 1533 | buzzer ( SHARP_BUZ_TOUCHSOUND ); |
1533 | } | 1534 | } |
1534 | 1535 | ||
1535 | void Zaurus::keySound ( ) | 1536 | void Zaurus::keySound ( ) |
1536 | { | 1537 | { |
1537 | buzzer ( SHARP_BUZ_KEYSOUND ); | 1538 | buzzer ( SHARP_BUZ_KEYSOUND ); |
1538 | } | 1539 | } |
1539 | 1540 | ||
1540 | 1541 | ||
1541 | QValueList <OLed> Zaurus::ledList ( ) const | 1542 | QValueList <OLed> Zaurus::ledList ( ) const |
1542 | { | 1543 | { |
1543 | QValueList <OLed> vl; | 1544 | QValueList <OLed> vl; |
1544 | vl << Led_Mail; | 1545 | vl << Led_Mail; |
1545 | return vl; | 1546 | return vl; |
1546 | } | 1547 | } |
1547 | 1548 | ||
1548 | QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const | 1549 | QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const |
1549 | { | 1550 | { |
1550 | QValueList <OLedState> vl; | 1551 | QValueList <OLedState> vl; |
1551 | 1552 | ||
1552 | if ( l == Led_Mail ) | 1553 | if ( l == Led_Mail ) |
1553 | vl << Led_Off << Led_On << Led_BlinkSlow; | 1554 | vl << Led_Off << Led_On << Led_BlinkSlow; |
1554 | return vl; | 1555 | return vl; |
1555 | } | 1556 | } |
1556 | 1557 | ||
1557 | OLedState Zaurus::ledState ( OLed which ) const | 1558 | OLedState Zaurus::ledState ( OLed which ) const |
1558 | { | 1559 | { |
1559 | if ( which == Led_Mail ) | 1560 | if ( which == Led_Mail ) |
1560 | return m_leds [0]; | 1561 | return m_leds [0]; |
1561 | else | 1562 | else |
1562 | return Led_Off; | 1563 | return Led_Off; |
1563 | } | 1564 | } |
1564 | 1565 | ||
1565 | bool Zaurus::setLedState ( OLed which, OLedState st ) | 1566 | bool Zaurus::setLedState ( OLed which, OLedState st ) |
1566 | { | 1567 | { |
1567 | static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); | 1568 | static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); |
1568 | 1569 | ||
1569 | if ( which == Led_Mail ) { | 1570 | if ( which == Led_Mail ) { |
1570 | if ( fd >= 0 ) { | 1571 | if ( fd >= 0 ) { |
1571 | struct sharp_led_status leds; | 1572 | struct sharp_led_status leds; |
1572 | ::memset ( &leds, 0, sizeof( leds )); | 1573 | ::memset ( &leds, 0, sizeof( leds )); |
1573 | leds. which = SHARP_LED_MAIL_EXISTS; | 1574 | leds. which = SHARP_LED_MAIL_EXISTS; |
1574 | bool ok = true; | 1575 | bool ok = true; |
1575 | 1576 | ||
1576 | switch ( st ) { | 1577 | switch ( st ) { |
1577 | case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; | 1578 | case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; |
1578 | case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; | 1579 | case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; |
1579 | case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; | 1580 | case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; |
1580 | default : ok = false; | 1581 | default : ok = false; |
1581 | } | 1582 | } |
1582 | 1583 | ||
1583 | if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) { | 1584 | if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) { |
1584 | m_leds [0] = st; | 1585 | m_leds [0] = st; |
1585 | return true; | 1586 | return true; |
1586 | } | 1587 | } |
1587 | } | 1588 | } |
1588 | } | 1589 | } |
1589 | return false; | 1590 | return false; |
1590 | } | 1591 | } |
1591 | 1592 | ||
1592 | bool Zaurus::setSoftSuspend ( bool soft ) | 1593 | bool Zaurus::setSoftSuspend ( bool soft ) |
1593 | { | 1594 | { |
1594 | bool res = false; | 1595 | bool res = false; |
1595 | int fd; | 1596 | int fd; |
1596 | 1597 | ||
1597 | if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || | 1598 | if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || |
1598 | (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { | 1599 | (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { |
1599 | 1600 | ||
1600 | int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources | 1601 | int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources |
1601 | 1602 | ||
1602 | if ( sources >= 0 ) { | 1603 | if ( sources >= 0 ) { |
1603 | if ( soft ) | 1604 | if ( soft ) |
1604 | sources &= ~APM_EVT_POWER_BUTTON; | 1605 | sources &= ~APM_EVT_POWER_BUTTON; |
1605 | else | 1606 | else |
1606 | sources |= APM_EVT_POWER_BUTTON; | 1607 | sources |= APM_EVT_POWER_BUTTON; |
1607 | 1608 | ||
1608 | if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources | 1609 | if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources |
1609 | res = true; | 1610 | res = true; |
1610 | else | 1611 | else |
1611 | perror ( "APM_IOCGEVTSRC" ); | 1612 | perror ( "APM_IOCGEVTSRC" ); |
1612 | } | 1613 | } |
1613 | else | 1614 | else |
1614 | perror ( "APM_IOCGEVTSRC" ); | 1615 | perror ( "APM_IOCGEVTSRC" ); |
1615 | 1616 | ||
1616 | ::close ( fd ); | 1617 | ::close ( fd ); |
1617 | } | 1618 | } |
1618 | else | 1619 | else |
1619 | perror ( "/dev/apm_bios or /dev/misc/apm_bios" ); | 1620 | perror ( "/dev/apm_bios or /dev/misc/apm_bios" ); |
1620 | 1621 | ||
1621 | return res; | 1622 | return res; |
1622 | } | 1623 | } |
1623 | 1624 | ||
1624 | 1625 | ||
1625 | bool Zaurus::setDisplayBrightness ( int bright ) | 1626 | bool Zaurus::setDisplayBrightness ( int bright ) |
1626 | { | 1627 | { |
1627 | bool res = false; | 1628 | bool res = false; |
1628 | int fd; | 1629 | int fd; |
1629 | 1630 | ||
1630 | if ( bright > 255 ) | 1631 | if ( bright > 255 ) |
1631 | bright = 255; | 1632 | bright = 255; |
1632 | if ( bright < 0 ) | 1633 | if ( bright < 0 ) |
1633 | bright = 0; | 1634 | bright = 0; |
1634 | 1635 | ||
1635 | if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) { | 1636 | if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) { |
1636 | int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus | 1637 | int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus |
1637 | if ( bright && !bl ) | 1638 | if ( bright && !bl ) |
1638 | bl = 1; | 1639 | bl = 1; |
1639 | res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 ); | 1640 | res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 ); |
1640 | ::close ( fd ); | 1641 | ::close ( fd ); |
1641 | } | 1642 | } |
1642 | return res; | 1643 | return res; |
1643 | } | 1644 | } |
1644 | 1645 | ||
1645 | 1646 | ||
1646 | int Zaurus::displayBrightnessResolution ( ) const | 1647 | int Zaurus::displayBrightnessResolution ( ) const |
1647 | { | 1648 | { |
1648 | return 5; | 1649 | return 5; |
1649 | } | 1650 | } |
1650 | 1651 | ||
1651 | |||
1652 | /************************************************** | 1652 | /************************************************** |
1653 | * | 1653 | * |
1654 | * SIMpad | 1654 | * SIMpad |
1655 | * | 1655 | * |
1656 | **************************************************/ | 1656 | **************************************************/ |
1657 | 1657 | ||
1658 | void SIMpad::init ( ) | 1658 | void SIMpad::init ( ) |
1659 | { | 1659 | { |
1660 | d-> m_vendorstr = "SIEMENS"; | 1660 | d-> m_vendorstr = "SIEMENS"; |
1661 | d-> m_vendor = Vendor_SIEMENS; | 1661 | d-> m_vendor = Vendor_SIEMENS; |
1662 | 1662 | ||
1663 | QFile f ( "/proc/hal/model" ); | 1663 | QFile f ( "/proc/hal/model" ); |
1664 | 1664 | ||
1665 | //TODO Implement model checking | 1665 | //TODO Implement model checking |
1666 | //FIXME For now we assume an SL4 | 1666 | //FIXME For now we assume an SL4 |
1667 | 1667 | ||
1668 | d-> m_modelstr = "SL4"; | 1668 | d-> m_modelstr = "SL4"; |
1669 | d-> m_model = Model_SIMpad_SL4; | 1669 | d-> m_model = Model_SIMpad_SL4; |
1670 | 1670 | ||
1671 | switch ( d-> m_model ) { | 1671 | switch ( d-> m_model ) { |
1672 | default: | 1672 | default: |
1673 | d-> m_rotation = Rot0; | 1673 | d-> m_rotation = Rot0; |
1674 | d-> m_direction = CCW; | 1674 | d-> m_direction = CCW; |
1675 | d-> m_holdtime = 1000; // 1000ms | 1675 | d-> m_holdtime = 1000; // 1000ms |
1676 | 1676 | ||
1677 | break; | 1677 | break; |
1678 | } | 1678 | } |
1679 | 1679 | ||
1680 | f. setName ( "/etc/familiar-version" ); | 1680 | f. setName ( "/etc/familiar-version" ); |
1681 | if ( f. open ( IO_ReadOnly )) { | 1681 | if ( f. open ( IO_ReadOnly )) { |
1682 | d-> m_systemstr = "Familiar"; | 1682 | d-> m_systemstr = "Familiar"; |
1683 | d-> m_system = System_Familiar; | 1683 | d-> m_system = System_Familiar; |
1684 | 1684 | ||
1685 | QTextStream ts ( &f ); | 1685 | QTextStream ts ( &f ); |
1686 | d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); | 1686 | d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); |
1687 | 1687 | ||
1688 | f. close ( ); | 1688 | f. close ( ); |
1689 | } else { | 1689 | } else { |
1690 | f. setName ( "/etc/oz_version" ); | 1690 | f. setName ( "/etc/oz_version" ); |
1691 | 1691 | ||
1692 | if ( f. open ( IO_ReadOnly )) { | 1692 | if ( f. open ( IO_ReadOnly )) { |
1693 | d-> m_systemstr = "OpenEmbedded/SIMpad"; | 1693 | d-> m_systemstr = "OpenEmbedded/SIMpad"; |
1694 | d-> m_system = System_OpenZaurus; | 1694 | d-> m_system = System_OpenZaurus; |
1695 | 1695 | ||
1696 | QTextStream ts ( &f ); | 1696 | QTextStream ts ( &f ); |
1697 | ts.setDevice ( &f ); | 1697 | ts.setDevice ( &f ); |
1698 | d-> m_sysverstr = ts. readLine ( ); | 1698 | d-> m_sysverstr = ts. readLine ( ); |
1699 | f. close ( ); | 1699 | f. close ( ); |
1700 | } | 1700 | } |
1701 | } | 1701 | } |
1702 | 1702 | ||
1703 | m_leds [0] = m_leds [1] = Led_Off; | 1703 | m_leds [0] = m_leds [1] = Led_Off; |
1704 | 1704 | ||
1705 | m_power_timer = 0; | 1705 | m_power_timer = 0; |
1706 | 1706 | ||
1707 | } | 1707 | } |
1708 | 1708 | ||
1709 | void SIMpad::initButtons ( ) | 1709 | void SIMpad::initButtons ( ) |
1710 | { | 1710 | { |
1711 | if ( d-> m_buttons ) | 1711 | if ( d-> m_buttons ) |
1712 | return; | 1712 | return; |
1713 | 1713 | ||
1714 | if ( isQWS( ) ) | 1714 | if ( isQWS( ) ) |
1715 | QWSServer::setKeyboardFilter ( this ); | 1715 | QWSServer::setKeyboardFilter ( this ); |
1716 | 1716 | ||
1717 | d-> m_buttons = new QValueList <ODeviceButton>; | 1717 | d-> m_buttons = new QValueList <ODeviceButton>; |
1718 | 1718 | ||
1719 | for ( uint i = 0; i < ( sizeof( simpad_buttons ) / sizeof( s_button )); i++ ) { | 1719 | for ( uint i = 0; i < ( sizeof( simpad_buttons ) / sizeof( s_button )); i++ ) { |
1720 | s_button *sb = simpad_buttons + i; | 1720 | s_button *sb = simpad_buttons + i; |
1721 | ODeviceButton b; | 1721 | ODeviceButton b; |
1722 | 1722 | ||
1723 | if (( sb-> model & d-> m_model ) == d-> m_model ) { | 1723 | if (( sb-> model & d-> m_model ) == d-> m_model ) { |
1724 | b. setKeycode ( sb-> code ); | 1724 | b. setKeycode ( sb-> code ); |
1725 | b. setUserText ( QObject::tr ( "Button", sb-> utext )); | 1725 | b. setUserText ( QObject::tr ( "Button", sb-> utext )); |
1726 | b. setPixmap ( Resource::loadPixmap ( sb-> pix )); | 1726 | b. setPixmap ( Resource::loadPixmap ( sb-> pix )); |
1727 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( sb-> fpressedservice ), sb-> fpressedaction )); | 1727 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( sb-> fpressedservice ), sb-> fpressedaction )); |
1728 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( sb-> fheldservice ), sb-> fheldaction )); | 1728 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( sb-> fheldservice ), sb-> fheldaction )); |
1729 | 1729 | ||
1730 | d-> m_buttons-> append ( b ); | 1730 | d-> m_buttons-> append ( b ); |
1731 | } | 1731 | } |
1732 | } | 1732 | } |
1733 | reloadButtonMapping ( ); | 1733 | reloadButtonMapping ( ); |
1734 | 1734 | ||
1735 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); | 1735 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); |
1736 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); | 1736 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); |
1737 | } | 1737 | } |
1738 | 1738 | ||
1739 | // SIMpad boardcontrol register CS3 | 1739 | // SIMpad boardcontrol register CS3 |
1740 | #define SIMPAD_BOARDCONTROL "/proc/cs3" | 1740 | #define SIMPAD_BOARDCONTROL "/proc/cs3" |
1741 | #define SIMPAD_VCC_5V_EN 0x0001 // For 5V PCMCIA | 1741 | #define SIMPAD_VCC_5V_EN 0x0001 // For 5V PCMCIA |
1742 | #define SIMPAD_VCC_3V_EN 0x0002 // FOR 3.3V PCMCIA | 1742 | #define SIMPAD_VCC_3V_EN 0x0002 // FOR 3.3V PCMCIA |
1743 | #define SIMPAD_EN1 0x0004 // This is only for EPROM's | 1743 | #define SIMPAD_EN1 0x0004 // This is only for EPROM's |
1744 | #define SIMPAD_EN0 0x0008 // Both should be enable for 3.3V or 5V | 1744 | #define SIMPAD_EN0 0x0008 // Both should be enable for 3.3V or 5V |
1745 | #define SIMPAD_DISPLAY_ON 0x0010 | 1745 | #define SIMPAD_DISPLAY_ON 0x0010 |
1746 | #define SIMPAD_PCMCIA_BUFF_DIS 0x0020 | 1746 | #define SIMPAD_PCMCIA_BUFF_DIS 0x0020 |
1747 | #define SIMPAD_MQ_RESET 0x0040 | 1747 | #define SIMPAD_MQ_RESET 0x0040 |
1748 | #define SIMPAD_PCMCIA_RESET 0x0080 | 1748 | #define SIMPAD_PCMCIA_RESET 0x0080 |
1749 | #define SIMPAD_DECT_POWER_ON 0x0100 | 1749 | #define SIMPAD_DECT_POWER_ON 0x0100 |
1750 | #define SIMPAD_IRDA_SD 0x0200 // Shutdown for powersave | 1750 | #define SIMPAD_IRDA_SD 0x0200 // Shutdown for powersave |
1751 | #define SIMPAD_RS232_ON 0x0400 | 1751 | #define SIMPAD_RS232_ON 0x0400 |
1752 | #define SIMPAD_SD_MEDIAQ 0x0800 // Shutdown for powersave | 1752 | #define SIMPAD_SD_MEDIAQ 0x0800 // Shutdown for powersave |
1753 | #define SIMPAD_LED2_ON 0x1000 | 1753 | #define SIMPAD_LED2_ON 0x1000 |
1754 | #define SIMPAD_IRDA_MODE 0x2000 // Fast/Slow IrDA mode | 1754 | #define SIMPAD_IRDA_MODE 0x2000 // Fast/Slow IrDA mode |
1755 | #define SIMPAD_ENABLE_5V 0x4000 // Enable 5V circuit | 1755 | #define SIMPAD_ENABLE_5V 0x4000 // Enable 5V circuit |
1756 | #define SIMPAD_RESET_SIMCARD 0x8000 | 1756 | #define SIMPAD_RESET_SIMCARD 0x8000 |
1757 | 1757 | ||
1758 | //SIMpad touchscreen backlight strength control | 1758 | //SIMpad touchscreen backlight strength control |
1759 | #define SIMPAD_BACKLIGHT_CONTROL "/proc/driver/mq200/registers/PWM_CONTROL" | 1759 | #define SIMPAD_BACKLIGHT_CONTROL "/proc/driver/mq200/registers/PWM_CONTROL" |
1760 | #define SIMPAD_BACKLIGHT_MASK 0x00a10044 | 1760 | #define SIMPAD_BACKLIGHT_MASK 0x00a10044 |
1761 | 1761 | ||
1762 | QValueList <OLed> SIMpad::ledList ( ) const | 1762 | QValueList <OLed> SIMpad::ledList ( ) const |
1763 | { | 1763 | { |
1764 | QValueList <OLed> vl; | 1764 | QValueList <OLed> vl; |
1765 | vl << Led_Power; //FIXME which LED is LED2 ? The green one or the amber one? | 1765 | vl << Led_Power; //FIXME which LED is LED2 ? The green one or the amber one? |
1766 | //vl << Led_Mail; //TODO find out if LED1 is accessible anyway | 1766 | //vl << Led_Mail; //TODO find out if LED1 is accessible anyway |
1767 | return vl; | 1767 | return vl; |
1768 | } | 1768 | } |
1769 | 1769 | ||
1770 | QValueList <OLedState> SIMpad::ledStateList ( OLed l ) const | 1770 | QValueList <OLedState> SIMpad::ledStateList ( OLed l ) const |
1771 | { | 1771 | { |
1772 | QValueList <OLedState> vl; | 1772 | QValueList <OLedState> vl; |
1773 | 1773 | ||
1774 | if ( l == Led_Power ) //FIXME which LED is LED2 ? The green one or the amber one? | 1774 | if ( l == Led_Power ) //FIXME which LED is LED2 ? The green one or the amber one? |
1775 | vl << Led_Off << Led_On; | 1775 | vl << Led_Off << Led_On; |
1776 | //else if ( l == Led_Mail ) //TODO find out if LED1 is accessible anyway | 1776 | //else if ( l == Led_Mail ) //TODO find out if LED1 is accessible anyway |
1777 | //vl << Led_Off; | 1777 | //vl << Led_Off; |
1778 | return vl; | 1778 | return vl; |
1779 | } | 1779 | } |
1780 | 1780 | ||
1781 | OLedState SIMpad::ledState ( OLed l ) const | 1781 | OLedState SIMpad::ledState ( OLed l ) const |
1782 | { | 1782 | { |
1783 | switch ( l ) { | 1783 | switch ( l ) { |
1784 | case Led_Power: | 1784 | case Led_Power: |
1785 | return m_leds [0]; | 1785 | return m_leds [0]; |
1786 | //case Led_Mail: | 1786 | //case Led_Mail: |
1787 | //return m_leds [1]; | 1787 | //return m_leds [1]; |
1788 | default: | 1788 | default: |
1789 | return Led_Off; | 1789 | return Led_Off; |
1790 | } | 1790 | } |
1791 | } | 1791 | } |
1792 | 1792 | ||
1793 | bool SIMpad::setLedState ( OLed l, OLedState st ) | 1793 | bool SIMpad::setLedState ( OLed l, OLedState st ) |
1794 | { | 1794 | { |
1795 | static int fd = ::open ( SIMPAD_BOARDCONTROL, O_RDWR | O_NONBLOCK ); | 1795 | static int fd = ::open ( SIMPAD_BOARDCONTROL, O_RDWR | O_NONBLOCK ); |
1796 | 1796 | ||
1797 | if ( l == Led_Power ) { | 1797 | if ( l == Led_Power ) { |
1798 | if ( fd >= 0 ) { | 1798 | if ( fd >= 0 ) { |
1799 | LED_IN leds; | 1799 | LED_IN leds; |
1800 | ::memset ( &leds, 0, sizeof( leds )); | 1800 | ::memset ( &leds, 0, sizeof( leds )); |
1801 | leds. TotalTime = 0; | 1801 | leds. TotalTime = 0; |
1802 | leds. OnTime = 0; | 1802 | leds. OnTime = 0; |
1803 | leds. OffTime = 1; | 1803 | leds. OffTime = 1; |
1804 | leds. OffOnBlink = 2; | 1804 | leds. OffOnBlink = 2; |
1805 | 1805 | ||
1806 | switch ( st ) { | 1806 | switch ( st ) { |
1807 | case Led_Off : leds. OffOnBlink = 0; break; | 1807 | case Led_Off : leds. OffOnBlink = 0; break; |
1808 | case Led_On : leds. OffOnBlink = 1; break; | 1808 | case Led_On : leds. OffOnBlink = 1; break; |
1809 | case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; | 1809 | case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; |
1810 | case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; | 1810 | case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; |
1811 | } | 1811 | } |
1812 | 1812 | ||
1813 | { | 1813 | { |
1814 | /*TODO Implement this like that: | 1814 | /*TODO Implement this like that: |
1815 | read from cs3 | 1815 | read from cs3 |
1816 | && with SIMPAD_LED2_ON | 1816 | && with SIMPAD_LED2_ON |
1817 | write to cs3 */ | 1817 | write to cs3 */ |
1818 | m_leds [0] = st; | 1818 | m_leds [0] = st; |
1819 | return true; | 1819 | return true; |
1820 | } | 1820 | } |
1821 | } | 1821 | } |
1822 | } | 1822 | } |
1823 | return false; | 1823 | return false; |
1824 | } | 1824 | } |
1825 | 1825 | ||
1826 | 1826 | ||
1827 | bool SIMpad::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) | 1827 | bool SIMpad::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) |
1828 | { | 1828 | { |
1829 | //TODO | 1829 | //TODO |
1830 | return false; | 1830 | return false; |
1831 | } | 1831 | } |
1832 | 1832 | ||
1833 | void SIMpad::timerEvent ( QTimerEvent * ) | 1833 | void SIMpad::timerEvent ( QTimerEvent * ) |
1834 | { | 1834 | { |
1835 | killTimer ( m_power_timer ); | 1835 | killTimer ( m_power_timer ); |
1836 | m_power_timer = 0; | 1836 | m_power_timer = 0; |
1837 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); | 1837 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); |
1838 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); | 1838 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); |
1839 | } | 1839 | } |
1840 | 1840 | ||
1841 | 1841 | ||
1842 | void SIMpad::alarmSound ( ) | 1842 | void SIMpad::alarmSound ( ) |
1843 | { | 1843 | { |
1844 | #ifndef QT_NO_SOUND | 1844 | #ifndef QT_NO_SOUND |
1845 | static Sound snd ( "alarm" ); | 1845 | static Sound snd ( "alarm" ); |
1846 | int fd; | 1846 | int fd; |
1847 | int vol; | 1847 | int vol; |
1848 | bool vol_reset = false; | 1848 | bool vol_reset = false; |
1849 | 1849 | ||
1850 | if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { | 1850 | if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { |
1851 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { | 1851 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { |
1852 | Config cfg ( "qpe" ); | 1852 | Config cfg ( "qpe" ); |
1853 | cfg. setGroup ( "Volume" ); | 1853 | cfg. setGroup ( "Volume" ); |
1854 | 1854 | ||
1855 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); | 1855 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); |
1856 | if ( volalarm < 0 ) | 1856 | if ( volalarm < 0 ) |
1857 | volalarm = 0; | 1857 | volalarm = 0; |
1858 | else if ( volalarm > 100 ) | 1858 | else if ( volalarm > 100 ) |
1859 | volalarm = 100; | 1859 | volalarm = 100; |
1860 | volalarm |= ( volalarm << 8 ); | 1860 | volalarm |= ( volalarm << 8 ); |
1861 | 1861 | ||
1862 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) | 1862 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) |
1863 | vol_reset = true; | 1863 | vol_reset = true; |
1864 | } | 1864 | } |
1865 | } | 1865 | } |
1866 | 1866 | ||
1867 | snd. play ( ); | 1867 | snd. play ( ); |
1868 | while ( !snd. isFinished ( )) | 1868 | while ( !snd. isFinished ( )) |
1869 | qApp-> processEvents ( ); | 1869 | qApp-> processEvents ( ); |
1870 | 1870 | ||
1871 | if ( fd >= 0 ) { | 1871 | if ( fd >= 0 ) { |
1872 | if ( vol_reset ) | 1872 | if ( vol_reset ) |
1873 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); | 1873 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); |
1874 | ::close ( fd ); | 1874 | ::close ( fd ); |
1875 | } | 1875 | } |
1876 | #endif | 1876 | #endif |
1877 | } | 1877 | } |
1878 | 1878 | ||
1879 | 1879 | ||
1880 | bool SIMpad::suspend ( ) // Must override because SIMpad does NOT have apm | 1880 | bool SIMpad::suspend ( ) // Must override because SIMpad does NOT have apm |
1881 | { | 1881 | { |
1882 | qDebug( "ODevice for SIMpad: suspend()" ); | 1882 | qDebug( "ODevice for SIMpad: suspend()" ); |
1883 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend | 1883 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend |
1884 | return false; | 1884 | return false; |
1885 | 1885 | ||
1886 | bool res = false; | 1886 | bool res = false; |
1887 | 1887 | ||
1888 | struct timeval tvs, tvn; | 1888 | struct timeval tvs, tvn; |
1889 | ::gettimeofday ( &tvs, 0 ); | 1889 | ::gettimeofday ( &tvs, 0 ); |
1890 | 1890 | ||
1891 | ::sync ( ); // flush fs caches | 1891 | ::sync ( ); // flush fs caches |
1892 | res = ( ::system ( "echo > /proc/sys/pm/suspend" ) == 0 ); //TODO make better :) | 1892 | res = ( ::system ( "cat /dev/fb/0 >/tmp/.buffer; echo > /proc/sys/pm/suspend; cat /tmp/.buffer >/dev/fb/0" ) == 0 ); //TODO make better :) |
1893 | 1893 | ||
1894 | return res; | 1894 | return res; |
1895 | } | 1895 | } |
1896 | 1896 | ||
1897 | 1897 | ||
1898 | bool SIMpad::setSoftSuspend ( bool soft ) | 1898 | bool SIMpad::setSoftSuspend ( bool soft ) |
1899 | { | 1899 | { |
1900 | qDebug( "ODevice for SIMpad: UNHANDLED setSoftSuspend(%s)", soft? "on" : "off" ); | 1900 | qDebug( "ODevice for SIMpad: UNHANDLED setSoftSuspend(%s)", soft? "on" : "off" ); |
1901 | return false; | 1901 | return false; |
1902 | } | 1902 | } |
1903 | 1903 | ||
1904 | 1904 | ||
1905 | bool SIMpad::setDisplayStatus ( bool on ) | 1905 | bool SIMpad::setDisplayStatus ( bool on ) |
1906 | { | 1906 | { |
1907 | qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" ); | 1907 | qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" ); |
1908 | 1908 | ||
1909 | bool res = false; | 1909 | bool res = false; |
1910 | int fd; | 1910 | int fd; |
1911 | 1911 | ||
1912 | QString cmdline = QString().sprintf( "echo %s > /proc/cs3", on ? "0xd41a" : "0xd40a" ); //TODO make better :) | 1912 | QString cmdline = QString().sprintf( "echo %s > /proc/cs3", on ? "0xd41a" : "0xd40a" ); //TODO make better :) |
1913 | 1913 | ||
1914 | if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { | 1914 | res = ( ::system( (const char*) cmdline ) == 0 ); |
1915 | res = ( ::system( (const char*) cmdline ) == 0 ); | 1915 | |
1916 | ::close ( fd ); | ||
1917 | } | ||
1918 | return res; | 1916 | return res; |
1919 | } | 1917 | } |
1920 | 1918 | ||
1921 | 1919 | ||
1922 | bool SIMpad::setDisplayBrightness ( int bright ) | 1920 | bool SIMpad::setDisplayBrightness ( int bright ) |
1923 | { | 1921 | { |
1924 | qDebug( "ODevice for SIMpad: setDisplayBrightness( %d )", bright ); | 1922 | qDebug( "ODevice for SIMpad: setDisplayBrightness( %d )", bright ); |
1925 | bool res = false; | 1923 | bool res = false; |
1926 | int fd; | 1924 | int fd; |
1927 | 1925 | ||
1928 | if ( bright > 255 ) | 1926 | if ( bright > 255 ) |
1929 | bright = 255; | 1927 | bright = 255; |
1930 | if ( bright < 0 ) | 1928 | if ( bright < 1 ) |
1931 | bright = 0; | 1929 | bright = 0; |
1932 | 1930 | ||
1933 | if (( fd = ::open ( SIMPAD_BACKLIGHT_CONTROL, O_WRONLY )) >= 0 ) { | 1931 | if (( fd = ::open ( SIMPAD_BACKLIGHT_CONTROL, O_WRONLY )) >= 0 ) { |
1934 | int value = 255 - bright; | 1932 | int value = 255 - bright; |
1935 | const int mask = SIMPAD_BACKLIGHT_MASK; | 1933 | const int mask = SIMPAD_BACKLIGHT_MASK; |
1936 | value = value << 8; | 1934 | value = value << 8; |
1937 | value += mask; | 1935 | value += mask; |
1938 | char writeCommand[100]; | 1936 | char writeCommand[100]; |
1939 | const int count = sprintf( writeCommand, "0x%x\n", value ); | 1937 | const int count = sprintf( writeCommand, "0x%x\n", value ); |
1940 | res = ( ::write ( fd, writeCommand, count ) != -1 ); | 1938 | res = ( ::write ( fd, writeCommand, count ) != -1 ); |
1941 | ::close ( fd ); | 1939 | ::close ( fd ); |
1942 | } | 1940 | } |
1943 | return res; | 1941 | return res; |
1944 | } | 1942 | } |
1945 | 1943 | ||
1946 | 1944 | ||
1947 | int SIMpad::displayBrightnessResolution ( ) const | 1945 | int SIMpad::displayBrightnessResolution ( ) const |
1948 | { | 1946 | { |
1949 | switch ( model ( )) { | 1947 | return 255; // All SIMpad models share the same display |
1950 | case Model_SIMpad_CL4: | ||
1951 | case Model_SIMpad_SL4: | ||
1952 | case Model_SIMpad_SLC: | ||
1953 | case Model_SIMpad_TSinus: | ||
1954 | return 255; //TODO find out if this is save | ||
1955 | |||
1956 | default: | ||
1957 | return 2; | ||
1958 | } | ||
1959 | } | 1948 | } |
1960 | 1949 | ||
1961 | /************************************************** | 1950 | /************************************************** |
1962 | * | 1951 | * |
1963 | * Ramses | 1952 | * Ramses |
1964 | * | 1953 | * |
1965 | **************************************************/ | 1954 | **************************************************/ |
1966 | 1955 | ||
1967 | void Ramses::init() | 1956 | void Ramses::init() |
1968 | { | 1957 | { |
1969 | d->m_vendorstr = "M und N"; | 1958 | d->m_vendorstr = "M und N"; |
1970 | d->m_vendor = Vendor_MundN; | 1959 | d->m_vendor = Vendor_MundN; |
1971 | 1960 | ||
1972 | QFile f("/proc/sys/board/ramses"); | 1961 | QFile f("/proc/sys/board/ramses"); |
1973 | 1962 | ||
1974 | d->m_modelstr = "Ramses"; | 1963 | d->m_modelstr = "Ramses"; |
1975 | d->m_model = Model_Ramses_MNCI; | 1964 | d->m_model = Model_Ramses_MNCI; |
1976 | 1965 | ||
1977 | d->m_rotation = Rot180; | 1966 | d->m_rotation = Rot0; |
1978 | d->m_direction = CW; | 1967 | d->m_holdtime = 1000; |
1979 | d->m_holdtime = 1000; | ||
1980 | 1968 | ||
1981 | f.setName("/etc/oz_version"); | 1969 | f.setName("/etc/oz_version"); |
1982 | 1970 | ||
1983 | if (f.open(IO_ReadOnly)) { | 1971 | if (f.open(IO_ReadOnly)) { |
1984 | d->m_systemstr = "OpenEmbedded/Ramses"; | 1972 | d->m_systemstr = "OpenEmbedded/Ramses"; |
1985 | d->m_system = System_OpenZaurus; | 1973 | d->m_system = System_OpenZaurus; |
1986 | 1974 | ||
1987 | QTextStream ts(&f); | 1975 | QTextStream ts(&f); |
1988 | ts.setDevice(&f); | 1976 | ts.setDevice(&f); |
1989 | d->m_sysverstr = ts.readLine(); | 1977 | d->m_sysverstr = ts.readLine(); |
1990 | f.close(); | 1978 | f.close(); |
1991 | } | 1979 | } |
1992 | 1980 | ||
1993 | m_power_timer = 0; | 1981 | m_power_timer = 0; |
1994 | 1982 | ||
1995 | #ifdef QT_QWS_ALLOW_OVERCLOCK | 1983 | #ifdef QT_QWS_ALLOW_OVERCLOCK |
1996 | #warning *** Overclocking enabled - this may fry your hardware - you have been warned *** | 1984 | #warning *** Overclocking enabled - this may fry your hardware - you have been warned *** |
1997 | #define OC(x...) x | 1985 | #define OC(x...) x |
1998 | #else | 1986 | #else |
1999 | #define OC(x...) | 1987 | #define OC(x...) |
2000 | #endif | 1988 | #endif |
2001 | 1989 | ||
2002 | 1990 | ||
2003 | // This table is true for a Intel XScale PXA 255 | 1991 | // This table is true for a Intel XScale PXA 255 |
2004 | 1992 | ||
2005 | d->m_cpu_frequencies->append("99000"); // mem= 99, run= 99, turbo= 99, PXbus= 50 | 1993 | d->m_cpu_frequencies->append("99000"); // mem= 99, run= 99, turbo= 99, PXbus= 50 |
2006 | OC(d->m_cpu_frequencies->append("118000"); ) // mem=118, run=118, turbo=118, PXbus= 59 OC'd mem | 1994 | OC(d->m_cpu_frequencies->append("118000"); ) // mem=118, run=118, turbo=118, PXbus= 59 OC'd mem |
2007 | d->m_cpu_frequencies->append("199100"); // mem= 99, run=199, turbo=199, PXbus= 99 | 1995 | d->m_cpu_frequencies->append("199100"); // mem= 99, run=199, turbo=199, PXbus= 99 |
2008 | OC(d->m_cpu_frequencies->append("236000"); ) // mem=118, run=236, turbo=236, PXbus=118 OC'd mem | 1996 | OC(d->m_cpu_frequencies->append("236000"); ) // mem=118, run=236, turbo=236, PXbus=118 OC'd mem |
2009 | d->m_cpu_frequencies->append("298600"); // mem= 99, run=199, turbo=298, PXbus= 99 | 1997 | d->m_cpu_frequencies->append("298600"); // mem= 99, run=199, turbo=298, PXbus= 99 |
2010 | OC(d->m_cpu_frequencies->append("354000"); ) // mem=118, run=236, turbo=354, PXbus=118 OC'd mem | 1998 | OC(d->m_cpu_frequencies->append("354000"); ) // mem=118, run=236, turbo=354, PXbus=118 OC'd mem |
2011 | d->m_cpu_frequencies->append("398099"); // mem= 99, run=199, turbo=398, PXbus= 99 | 1999 | d->m_cpu_frequencies->append("398099"); // mem= 99, run=199, turbo=398, PXbus= 99 |
2012 | d->m_cpu_frequencies->append("398100"); // mem= 99, run=398, turbo=398, PXbus=196 | 2000 | d->m_cpu_frequencies->append("398100"); // mem= 99, run=398, turbo=398, PXbus=196 |
2013 | OC(d->m_cpu_frequencies->append("471000"); ) // mem=118, run=471, turbo=471, PXbus=236 OC'd mem/core/bus | 2001 | OC(d->m_cpu_frequencies->append("471000"); ) // mem=118, run=471, turbo=471, PXbus=236 OC'd mem/core/bus |
2014 | 2002 | ||
2015 | } | 2003 | } |
2016 | 2004 | ||
2017 | bool Ramses::filter(int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat) | 2005 | bool Ramses::filter(int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat) |
2018 | { | 2006 | { |
2019 | Q_UNUSED( keycode ); | 2007 | Q_UNUSED( keycode ); |
2020 | Q_UNUSED( modifiers ); | 2008 | Q_UNUSED( modifiers ); |
2021 | Q_UNUSED( isPress ); | 2009 | Q_UNUSED( isPress ); |
2022 | Q_UNUSED( autoRepeat ); | 2010 | Q_UNUSED( autoRepeat ); |
2023 | return false; | 2011 | return false; |
2024 | } | 2012 | } |
2025 | 2013 | ||
2026 | void Ramses::timerEvent(QTimerEvent *) | 2014 | void Ramses::timerEvent(QTimerEvent *) |
2027 | { | 2015 | { |
2028 | killTimer(m_power_timer); | 2016 | killTimer(m_power_timer); |
2029 | m_power_timer = 0; | 2017 | m_power_timer = 0; |
2030 | QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, true, false); | 2018 | QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, true, false); |
2031 | QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, false, false); | 2019 | QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, false, false); |
2032 | } | 2020 | } |
2033 | 2021 | ||
2034 | 2022 | ||
2035 | bool Ramses::setSoftSuspend(bool soft) | 2023 | bool Ramses::setSoftSuspend(bool soft) |
2036 | { | 2024 | { |
2037 | Q_UNUSED(soft); | 2025 | qDebug("Ramses::setSoftSuspend(%d)", soft); |
2038 | return true; | 2026 | #if 0 |
2039 | } | ||
2040 | |||
2041 | bool Ramses::suspend() | ||
2042 | { | ||
2043 | //qDebug("Ramses::suspend()"); | ||
2044 | if ( !isQWS() ) // only qwsserver is allowed to suspend | ||
2045 | return false; | ||
2046 | |||
2047 | bool res = false; | 2027 | bool res = false; |
2048 | int fd; | 2028 | int fd; |
2049 | 2029 | ||
2050 | if ((fd = ::open("/proc/sys/pm/suspend", O_WRONLY)) >= 0) { | 2030 | if (((fd = ::open("/dev/apm_bios", O_RDWR)) >= 0) || |
2051 | res = ( ::write ( fd, "1", 1 ) != -1 ); | 2031 | ((fd = ::open("/dev/misc/apm_bios",O_RDWR)) >= 0)) { |
2032 | |||
2033 | int sources = ::ioctl(fd, APM_IOCGEVTSRC, 0); // get current event sources | ||
2034 | |||
2035 | if (sources >= 0) { | ||
2036 | if (soft) | ||
2037 | sources &= ~APM_EVT_POWER_BUTTON; | ||
2038 | else | ||
2039 | sources |= APM_EVT_POWER_BUTTON; | ||
2040 | |||
2041 | if (::ioctl(fd, APM_IOCSEVTSRC, sources) >= 0) // set new event sources | ||
2042 | res = true; | ||
2043 | else | ||
2044 | perror("APM_IOCGEVTSRC"); | ||
2045 | } | ||
2046 | else | ||
2047 | perror("APM_IOCGEVTSRC"); | ||
2048 | |||
2052 | ::close(fd); | 2049 | ::close(fd); |
2053 | } | 2050 | } |
2054 | return res; | 2051 | else |
2052 | perror("/dev/apm_bios or /dev/misc/apm_bios"); | ||
2053 | |||
2054 | return res; | ||
2055 | #else | ||
2056 | return true; | ||
2057 | #endif | ||
2058 | } | ||
2059 | |||
2060 | bool Ramses::suspend ( ) | ||
2061 | { | ||
2062 | qDebug("Ramses::suspend"); | ||
2063 | return false; | ||
2055 | } | 2064 | } |
2056 | 2065 | ||
2057 | /** | 2066 | /** |
2058 | * This sets the display on or off | 2067 | * This sets the display on or off |
2059 | */ | 2068 | */ |
2060 | bool Ramses::setDisplayStatus(bool on) | 2069 | bool Ramses::setDisplayStatus(bool on) |
2061 | { | 2070 | { |
2062 | //qDebug("Ramses::setDisplayStatus(%d)", on); | 2071 | qDebug("Ramses::setDisplayStatus(%d)", on); |
2072 | #if 0 | ||
2063 | bool res = false; | 2073 | bool res = false; |
2064 | int fd; | 2074 | int fd; |
2065 | 2075 | ||
2066 | if ((fd = ::open ("/dev/fb/1", O_RDWR)) >= 0) { | 2076 | if ((fd = ::open ("/dev/fb/0", O_RDWR)) >= 0) { |
2067 | res = (::ioctl(fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN) == 0); | 2077 | res = (::ioctl(fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN) == 0); |
2068 | ::close(fd); | 2078 | ::close(fd); |
2069 | } | 2079 | } |
2070 | return res; | 2080 | return res; |
2081 | #else | ||
2082 | return true; | ||
2083 | #endif | ||
2071 | } | 2084 | } |
2072 | 2085 | ||
2073 | 2086 | ||
2074 | /* | 2087 | /* |
2075 | * We get something between 0..255 into us | 2088 | * We get something between 0..255 into us |
2076 | */ | 2089 | */ |
2077 | bool Ramses::setDisplayBrightness(int bright) | 2090 | bool Ramses::setDisplayBrightness(int bright) |
2078 | { | 2091 | { |
2079 | //qDebug("Ramses::setDisplayBrightness(%d)", bright); | 2092 | qDebug("Ramses::setDisplayBrightness(%d)", bright); |
2080 | bool res = false; | 2093 | bool res = false; |
2081 | int fd; | 2094 | int fd; |
2082 | 2095 | ||
2083 | // pwm1 brighness: 20 steps 500..0 (dunkel->hell) | 2096 | // pwm1 brighness: 20 steps 500..0 (dunkel->hell) |
2084 | 2097 | ||
2085 | if (bright > 255 ) | 2098 | if (bright > 255 ) |
2086 | bright = 255; | 2099 | bright = 255; |
2087 | if (bright < 0) | 2100 | if (bright < 0) |
2088 | bright = 0; | 2101 | bright = 0; |
2089 | 2102 | ||
2090 | // Turn backlight completely off | 2103 | // Turn backlight completely off |
2091 | if ((fd = ::open("/proc/sys/board/lcd_backlight", O_WRONLY)) >= 0) { | 2104 | if ((fd = ::open("/proc/sys/board/lcd_backlight", O_WRONLY)) >= 0) { |
2092 | char writeCommand[10]; | 2105 | char writeCommand[10]; |
2093 | const int count = sprintf(writeCommand, "%d\n", bright ? 1 : 0); | 2106 | const int count = sprintf(writeCommand, "%d\n", bright ? 1 : 0); |
2094 | res = (::write(fd, writeCommand, count) != -1); | 2107 | res = (::write(fd, writeCommand, count) != -1); |
2095 | ::close(fd); | 2108 | ::close(fd); |
2096 | } | 2109 | } |
2097 | 2110 | ||
2098 | // scale backlight brightness to hardware | 2111 | // scale backlight brightness to hardware |
2099 | if ((fd = ::open("/proc/sys/board/lcd_brightness", O_WRONLY)) >= 0) { | 2112 | bright = 500-(bright * 500 / 255); |
2100 | //qDebug(" %d -> pwm1", bright); | 2113 | if ((fd = ::open("/proc/sys/board/pwm1", O_WRONLY)) >= 0) { |
2114 | qDebug(" %d -> pwm1", bright); | ||
2101 | char writeCommand[100]; | 2115 | char writeCommand[100]; |
2102 | const int count = sprintf(writeCommand, "%d\n", bright); | 2116 | const int count = sprintf(writeCommand, "%d\n", bright); |
2103 | res = (::write(fd, writeCommand, count) != -1); | 2117 | res = (::write(fd, writeCommand, count) != -1); |
2104 | ::close(fd); | 2118 | ::close(fd); |
2105 | } | 2119 | } |
2106 | return res; | 2120 | return res; |
2107 | } | 2121 | } |
2108 | 2122 | ||
2109 | 2123 | ||
2110 | int Ramses::displayBrightnessResolution() const | 2124 | int Ramses::displayBrightnessResolution() const |
2111 | { | 2125 | { |
2112 | return 256; | 2126 | return 32; |
2113 | } | 2127 | } |
2114 | 2128 | ||
2115 | bool Ramses::setDisplayContrast(int contr) | 2129 | bool Ramses::setDisplayContrast(int contr) |
2116 | { | 2130 | { |
2117 | //qDebug("Ramses::setDisplayContrast(%d)", contr); | 2131 | qDebug("Ramses::setDisplayContrast(%d)", contr); |
2118 | bool res = false; | 2132 | bool res = false; |
2119 | int fd; | 2133 | int fd; |
2120 | 2134 | ||
2121 | // pwm0 contrast: 20 steps 79..90 (dunkel->hell) | 2135 | // pwm0 contrast: 20 steps 79..90 (dunkel->hell) |
2122 | 2136 | ||
2123 | if (contr > 255 ) | 2137 | if (contr > 255 ) |
2124 | contr = 255; | 2138 | contr = 255; |
2125 | if (contr < 0) | 2139 | if (contr < 0) |
2126 | contr = 0; | 2140 | contr = 0; |
2141 | contr = 90 - (contr * 20 / 255); | ||
2127 | 2142 | ||
2128 | if ((fd = ::open("/proc/sys/board/lcd_contrast", O_WRONLY)) >= 0) { | 2143 | if ((fd = ::open("/proc/sys/board/pwm0", O_WRONLY)) >= 0) { |
2129 | //qDebug(" %d -> pwm0", contr); | 2144 | qDebug(" %d -> pwm0", contr); |
2130 | char writeCommand[100]; | 2145 | char writeCommand[100]; |
2131 | const int count = sprintf(writeCommand, "%d\n", contr); | 2146 | const int count = sprintf(writeCommand, "%d\n", contr); |
2132 | res = (::write(fd, writeCommand, count) != -1); | 2147 | res = (::write(fd, writeCommand, count) != -1); |
2133 | res = true; | 2148 | res = true; |
2134 | ::close(fd); | 2149 | ::close(fd); |
2135 | } | 2150 | } |
2136 | return res; | 2151 | return res; |
2137 | } | 2152 | } |
2138 | 2153 | ||
2139 | 2154 | ||
2140 | int Ramses::displayContrastResolution() const | 2155 | int Ramses::displayContrastResolution() const |
2141 | { | 2156 | { |
2142 | return 256; | 2157 | return 20; |
2143 | } | 2158 | } |
diff --git a/libopie/ofiledialog.cc b/libopie/ofiledialog.cc index 9e725c2..5511b24 100644 --- a/libopie/ofiledialog.cc +++ b/libopie/ofiledialog.cc | |||
@@ -1,156 +1,215 @@ | |||
1 | /* | 1 | /* |
2 | =. This file is part of the OPIE Project | 2 | =. This file is part of the OPIE Project |
3 | .=l. Copyright (c) 2002 <> | 3 | .=l. Copyright (c) 2002,2003 <zecke@handhelds.org> |
4 | .>+-= | 4 | .>+-= |
5 | _;:, .> :=|. This library is free software; you can | 5 | _;:, .> :=|. This library is free software; you can |
6 | .> <`_, > . <= redistribute it and/or modify it under | 6 | .> <`_, > . <= redistribute it and/or modify it under |
7 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 7 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
8 | .="- .-=="i, .._ License as published by the Free Software | 8 | .="- .-=="i, .._ License as published by the Free Software |
9 | - . .-<_> .<> Foundation; either version 2 of the License, | 9 | - . .-<_> .<> Foundation; either version 2 of the License, |
10 | ._= =} : or (at your option) any later version. | 10 | ._= =} : or (at your option) any later version. |
11 | .%`+i> _;_. | 11 | .%`+i> _;_. |
12 | .i_,=:_. -<s. This library is distributed in the hope that | 12 | .i_,=:_. -<s. This library is distributed in the hope that |
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
14 | : .. .:, . . . without even the implied warranty of | 14 | : .. .:, . . . without even the implied warranty of |
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
17 | ..}^=.= = ; Library General Public License for more | 17 | ..}^=.= = ; Library General Public License for more |
18 | ++= -. .` .: details. | 18 | ++= -. .` .: details. |
19 | : = ...= . :.=- | 19 | : = ...= . :.=- |
20 | -. .:....=;==+<; You should have received a copy of the GNU | 20 | -. .:....=;==+<; You should have received a copy of the GNU |
21 | -_. . . )=. = Library General Public License along with | 21 | -_. . . )=. = Library General Public License along with |
22 | -- :-=` this library; see the file COPYING.LIB. | 22 | -- :-=` this library; see the file COPYING.LIB. |
23 | If not, write to the Free Software Foundation, | 23 | If not, write to the Free Software Foundation, |
24 | Inc., 59 Temple Place - Suite 330, | 24 | Inc., 59 Temple Place - Suite 330, |
25 | Boston, MA 02111-1307, USA. | 25 | Boston, MA 02111-1307, USA. |
26 | 26 | ||
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include <qpe/applnk.h> | 29 | #include <qpe/applnk.h> |
30 | #include <qpe/config.h> | ||
31 | #include <qpe/qpeapplication.h> | ||
32 | |||
33 | #include <qfileinfo.h> | ||
30 | #include <qstring.h> | 34 | #include <qstring.h> |
31 | #include <qapplication.h> | 35 | #include <qapplication.h> |
32 | #include <qlayout.h> | 36 | #include <qlayout.h> |
33 | 37 | ||
38 | |||
34 | #include "ofiledialog.h" | 39 | #include "ofiledialog.h" |
35 | 40 | ||
41 | |||
42 | namespace { | ||
43 | /* | ||
44 | * helper functions to load the start dir | ||
45 | * and to save it | ||
46 | * helper to extract the dir out of a file name | ||
47 | */ | ||
48 | /** | ||
49 | * This method will use Config( argv[0] ); | ||
50 | * @param key The group key used | ||
51 | */ | ||
52 | QString lastUsedDir( const QString& key ) { | ||
53 | if ( qApp->argc() < 1 ) | ||
54 | return QString::null; | ||
55 | |||
56 | Config cfg( QFileInfo(qApp->argv()[0]).fileName() ); // appname | ||
57 | cfg.setGroup( key ); | ||
58 | return cfg.readEntry("LastDir", QPEApplication::documentDir() ); | ||
59 | } | ||
60 | |||
61 | void saveLastDir( const QString& key, const QString& file ) { | ||
62 | if ( qApp->argc() < 1 ) | ||
63 | return; | ||
64 | |||
65 | Config cfg( QFileInfo(qApp->argv()[0]).fileName() ); | ||
66 | cfg.setGroup( key ); | ||
67 | QFileInfo inf( file ); | ||
68 | cfg.writeEntry("LastDir", inf.dirPath( true ) ); | ||
69 | } | ||
70 | }; | ||
71 | |||
36 | /** | 72 | /** |
37 | * This constructs a modal dialog | 73 | * This constructs a modal dialog |
38 | * | 74 | * |
39 | * @param caption The caption of the dialog | 75 | * @param caption The caption of the dialog |
40 | * @param wid The parent widget | 76 | * @param wid The parent widget |
41 | * @param mode The mode of the OFileSelector @see OFileSelector | 77 | * @param mode The mode of the OFileSelector @see OFileSelector |
42 | * @param selector The selector of the OFileSelector | 78 | * @param selector The selector of the OFileSelector |
43 | * @param dirName the dir or resource to start from | 79 | * @param dirName the dir or resource to start from |
44 | * @param fileName a proposed or existing filename | 80 | * @param fileName a proposed or existing filename |
45 | * @param mimetypes The mimeTypes | 81 | * @param mimetypes The mimeTypes |
46 | */ | 82 | */ |
47 | OFileDialog::OFileDialog(const QString &caption, | 83 | OFileDialog::OFileDialog(const QString &caption, |
48 | QWidget *wid, int mode, int selector, | 84 | QWidget *wid, int mode, int selector, |
49 | const QString &dirName, | 85 | const QString &dirName, |
50 | const QString &fileName, | 86 | const QString &fileName, |
51 | const QMap<QString,QStringList>& mimetypes ) | 87 | const QMap<QString,QStringList>& mimetypes ) |
52 | : QDialog( wid, "OFileDialog", true ) | 88 | : QDialog( wid, "OFileDialog", true ) |
53 | { | 89 | { |
54 | // QVBoxLayout *lay = new QVBoxLayout(this); | 90 | // QVBoxLayout *lay = new QVBoxLayout(this); |
55 | //showMaximized(); | 91 | //showMaximized(); |
56 | QVBoxLayout *lay = new QVBoxLayout(this ); | 92 | QVBoxLayout *lay = new QVBoxLayout(this ); |
57 | file = new OFileSelector(this , mode, selector, | 93 | file = new OFileSelector(this , mode, selector, |
58 | dirName, fileName, | 94 | dirName, fileName, |
59 | mimetypes ); | 95 | mimetypes ); |
60 | lay->addWidget( file ); | 96 | lay->addWidget( file ); |
61 | 97 | ||
62 | //lay->addWidget( file ); | 98 | //lay->addWidget( file ); |
63 | //showFullScreen(); | 99 | //showFullScreen(); |
64 | setCaption( caption.isEmpty() ? tr("FileDialog") : caption ); | 100 | setCaption( caption.isEmpty() ? tr("FileDialog") : caption ); |
65 | connect(file, SIGNAL(fileSelected(const QString&) ), | 101 | connect(file, SIGNAL(fileSelected(const QString&) ), |
66 | this, SLOT(slotFileSelected(const QString&) ) ); | 102 | this, SLOT(slotFileSelected(const QString&) ) ); |
103 | connect(file, SIGNAL(ok() ), | ||
104 | this, SLOT(slotSelectorOk()) ) ; | ||
67 | 105 | ||
106 | connect(file, SIGNAL(dirSelected(const QString&) ), this, SLOT(slotDirSelected(const QString&) ) ); | ||
107 | |||
108 | #if 0 | ||
68 | connect(file, SIGNAL(dirSelected(const QString &) ), | 109 | connect(file, SIGNAL(dirSelected(const QString &) ), |
69 | this, SLOT(slotDirSelected(const QString &) ) ); | 110 | this, SLOT(slotDirSelected(const QString &) ) ); |
70 | 111 | #endif | |
71 | |||
72 | file->setYesCancelVisible( false ); // relayout | ||
73 | } | 112 | } |
74 | /** | 113 | /** |
75 | * @returns the mimetype of the selected | 114 | * @returns the mimetype of the selected |
76 | * currently it return QString::null | 115 | * currently it return QString::null |
77 | */ | 116 | */ |
78 | QString OFileDialog::mimetype()const | 117 | QString OFileDialog::mimetype()const |
79 | { | 118 | { |
80 | return QString::null; | 119 | return QString::null; |
81 | } | 120 | } |
82 | 121 | ||
83 | /** | 122 | /** |
84 | * @return the fileName | 123 | * @return the fileName |
85 | */ | 124 | */ |
86 | QString OFileDialog::fileName()const | 125 | QString OFileDialog::fileName()const |
87 | { | 126 | { |
88 | return file->selectedName(); | 127 | return file->selectedName(); |
89 | } | 128 | } |
90 | 129 | ||
91 | /** | 130 | /** |
92 | * return a DocLnk to the current file | 131 | * return a DocLnk to the current file |
93 | */ | 132 | */ |
94 | DocLnk OFileDialog::selectedDocument()const | 133 | DocLnk OFileDialog::selectedDocument()const |
95 | { | 134 | { |
96 | return file->selectedDocument(); | 135 | return file->selectedDocument(); |
97 | } | 136 | } |
98 | 137 | ||
99 | /** | 138 | /** |
100 | * This opens up a filedialog in Open mode | 139 | * This opens up a filedialog in Open mode |
101 | * | 140 | * |
102 | * @param selector the Selector Mode | 141 | * @param selector the Selector Mode |
103 | * @param startDir Where to start from | 142 | * @param startDir Where to start from |
104 | * @param file A proposed filename | 143 | * @param file A proposed filename |
105 | * @param mimes A list of MimeTypes | 144 | * @param mimes A list of MimeTypes |
106 | * @param wid the parent | 145 | * @param wid the parent |
107 | * @param caption of the dialog if QString::null tr("Open") will be used | 146 | * @param caption of the dialog if QString::null tr("Open") will be used |
108 | * @return the fileName or QString::null | 147 | * @return the fileName or QString::null |
109 | */ | 148 | */ |
110 | QString OFileDialog::getOpenFileName(int selector, | 149 | QString OFileDialog::getOpenFileName(int selector, |
111 | const QString &startDir, | 150 | const QString &_startDir, |
112 | const QString &file, | 151 | const QString &file, |
113 | const MimeTypes &mimes, | 152 | const MimeTypes &mimes, |
114 | QWidget *wid, | 153 | QWidget *wid, |
115 | const QString &caption ) | 154 | const QString &caption ) |
116 | { | 155 | { |
117 | QString ret; | 156 | QString ret; |
157 | QString startDir = _startDir; | ||
158 | if (startDir.isEmpty() ) | ||
159 | startDir = lastUsedDir( "FileDialog-OPEN" ); | ||
160 | |||
161 | |||
118 | OFileDialog dlg( caption.isEmpty() ? tr("Open") : caption, | 162 | OFileDialog dlg( caption.isEmpty() ? tr("Open") : caption, |
119 | wid, OFileSelector::OPEN, selector, startDir, file, mimes); | 163 | wid, OFileSelector::Open, selector, startDir, file, mimes); |
120 | dlg.showMaximized(); | 164 | dlg.showMaximized(); |
121 | if( dlg.exec() ) | 165 | if( dlg.exec() ) { |
122 | ret = dlg.fileName(); | 166 | ret = dlg.fileName(); |
167 | saveLastDir( "FileDialog-OPEN", ret ); | ||
168 | } | ||
123 | 169 | ||
124 | return ret; | 170 | return ret; |
125 | } | 171 | } |
126 | 172 | ||
127 | /** | 173 | /** |
128 | * This opens up a file dialog in save mode | 174 | * This opens up a file dialog in save mode |
129 | * @see getOpenFileName | 175 | * @see getOpenFileName |
130 | */ | 176 | */ |
131 | QString OFileDialog::getSaveFileName(int selector, | 177 | QString OFileDialog::getSaveFileName(int selector, |
132 | const QString &startDir, | 178 | const QString &_startDir, |
133 | const QString &file, | 179 | const QString &file, |
134 | const MimeTypes &mimes, | 180 | const MimeTypes &mimes, |
135 | QWidget *wid, | 181 | QWidget *wid, |
136 | const QString &caption ) | 182 | const QString &caption ) |
137 | { | 183 | { |
138 | QString ret; | 184 | QString ret; |
185 | QString startDir = _startDir; | ||
186 | if (startDir.isEmpty() ) | ||
187 | startDir = lastUsedDir( "FileDialog-SAVE" ); | ||
188 | |||
139 | OFileDialog dlg( caption.isEmpty() ? tr("Save") : caption, | 189 | OFileDialog dlg( caption.isEmpty() ? tr("Save") : caption, |
140 | wid, OFileSelector::SAVE, selector, startDir, file, mimes); | 190 | wid, OFileSelector::Save, selector, startDir, file, mimes); |
141 | dlg.showMaximized(); | 191 | dlg.showMaximized(); |
142 | if( dlg.exec() ) | 192 | if( dlg.exec() ) { |
143 | ret = dlg.fileName(); | 193 | ret = dlg.fileName(); |
194 | saveLastDir( "FileDialog-SAVE", ret ); | ||
195 | } | ||
144 | 196 | ||
145 | return ret; | 197 | return ret; |
146 | } | 198 | } |
147 | 199 | ||
148 | void OFileDialog::slotFileSelected(const QString & ) | 200 | void OFileDialog::slotFileSelected(const QString & ) |
149 | { | 201 | { |
150 | accept(); | 202 | accept(); |
151 | } | 203 | } |
152 | void OFileDialog::slotDirSelected(const QString & ) | 204 | |
205 | void OFileDialog::slotSelectorOk( ) | ||
206 | { | ||
207 | accept(); | ||
208 | } | ||
209 | |||
210 | void OFileDialog::slotDirSelected(const QString &dir ) | ||
153 | { | 211 | { |
212 | setCaption( dir ); | ||
154 | // if mode | 213 | // if mode |
155 | //accept(); | 214 | //accept(); |
156 | } | 215 | } |
diff --git a/libopie/ofiledialog.h b/libopie/ofiledialog.h index 309086b..91e0586 100644 --- a/libopie/ofiledialog.h +++ b/libopie/ofiledialog.h | |||
@@ -1,100 +1,101 @@ | |||
1 | /* | 1 | /* |
2 | =. This file is part of the OPIE Project | 2 | =. This file is part of the OPIE Project |
3 | .=l. Copyright (c) 2002 zecke <zecke@handhelds.org> | 3 | .=l. Copyright (c) 2002 zecke <zecke@handhelds.org> |
4 | .>+-= | 4 | .>+-= |
5 | _;:, .> :=|. This library is free software; you can | 5 | _;:, .> :=|. This library is free software; you can |
6 | .> <`_, > . <= redistribute it and/or modify it under | 6 | .> <`_, > . <= redistribute it and/or modify it under |
7 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 7 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
8 | .="- .-=="i, .._ License as published by the Free Software | 8 | .="- .-=="i, .._ License as published by the Free Software |
9 | - . .-<_> .<> Foundation; either version 2 of the License, | 9 | - . .-<_> .<> Foundation; either version 2 of the License, |
10 | ._= =} : or (at your option) any later version. | 10 | ._= =} : or (at your option) any later version. |
11 | .%`+i> _;_. | 11 | .%`+i> _;_. |
12 | .i_,=:_. -<s. This library is distributed in the hope that | 12 | .i_,=:_. -<s. This library is distributed in the hope that |
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
14 | : .. .:, . . . without even the implied warranty of | 14 | : .. .:, . . . without even the implied warranty of |
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
17 | ..}^=.= = ; Library General Public License for more | 17 | ..}^=.= = ; Library General Public License for more |
18 | ++= -. .` .: details. | 18 | ++= -. .` .: details. |
19 | : = ...= . :.=- | 19 | : = ...= . :.=- |
20 | -. .:....=;==+<; You should have received a copy of the GNU | 20 | -. .:....=;==+<; You should have received a copy of the GNU |
21 | -_. . . )=. = Library General Public License along with | 21 | -_. . . )=. = Library General Public License along with |
22 | -- :-=` this library; see the file COPYING.LIB. | 22 | -- :-=` this library; see the file COPYING.LIB. |
23 | If not, write to the Free Software Foundation, | 23 | If not, write to the Free Software Foundation, |
24 | Inc., 59 Temple Place - Suite 330, | 24 | Inc., 59 Temple Place - Suite 330, |
25 | Boston, MA 02111-1307, USA. | 25 | Boston, MA 02111-1307, USA. |
26 | 26 | ||
27 | */ | 27 | */ |
28 | 28 | ||
29 | 29 | ||
30 | #ifndef OpieFileDialog_h | 30 | #ifndef OpieFileDialog_h |
31 | #define OpieFileDialog_h | 31 | #define OpieFileDialog_h |
32 | 32 | ||
33 | #include <qdialog.h> | 33 | #include <qdialog.h> |
34 | 34 | ||
35 | #include <opie/ofileselector.h> | 35 | #include <opie/ofileselector.h> |
36 | 36 | ||
37 | /** | 37 | /** |
38 | * This class places a OFileSelector inside a QDialog. | 38 | * This class places a OFileSelector inside a QDialog. |
39 | * It provides static method for letting a user chose | 39 | * It provides static method for letting a user chose |
40 | * a file for either opening or saving. | 40 | * a file for either opening or saving. |
41 | * Most of the time the c'tor will not be used instead using | 41 | * Most of the time the c'tor will not be used instead using |
42 | * the static member functions is prefered. | 42 | * the static member functions is prefered. |
43 | * | 43 | * |
44 | * <pre> | 44 | * <pre> |
45 | * QMap<QString, QStringList> mimeTypes; | 45 | * QMap<QString, QStringList> mimeTypes; |
46 | * QStringList types; | 46 | * QStringList types; |
47 | * types << "text/* "; | 47 | * types << "text[slash]* "; |
48 | * mimeTypes.insert( tr("Text"), types ); | 48 | * mimeTypes.insert( tr("Text"), types ); |
49 | * mimeTypes.insert( tr("All"), " * / * " ); // remove the spaces in the 2nd comment | 49 | * mimeTypes.insert( tr("All"), " * / * " ); // remove the spaces in the 2nd comment |
50 | * QString fileName= OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL, | 50 | * QString fileName= OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL, |
51 | * "foo","bar", mimeTypes); | 51 | * "foo","bar", mimeTypes); |
52 | * </pre> | 52 | * </pre> |
53 | * | 53 | * |
54 | * @short A small QDialog swalloing a FileSelector | 54 | * @short A small QDialog swalloing a FileSelector |
55 | * @see QDialog | 55 | * @see QDialog |
56 | * @see OFileSelector | 56 | * @see OFileSelector |
57 | * @version 0.1-unfinished | 57 | * @version 0.1-unfinished |
58 | * @author Holger Freyther ( zecke@handhelds.org ) | 58 | * @author Holger Freyther ( zecke@handhelds.org ) |
59 | */ | 59 | */ |
60 | class OFileDialog : public QDialog { | 60 | class OFileDialog : public QDialog { |
61 | Q_OBJECT | 61 | Q_OBJECT |
62 | public: | 62 | public: |
63 | OFileDialog(const QString &caption, | 63 | OFileDialog(const QString &caption, |
64 | QWidget *, int mode, int selector, | 64 | QWidget *, int mode, int selector, |
65 | const QString &dirName, | 65 | const QString &dirName, |
66 | const QString &fileName = QString::null, | 66 | const QString &fileName = QString::null, |
67 | const MimeTypes &mimetypes = MimeTypes() ); | 67 | const MimeTypes &mimetypes = MimeTypes() ); |
68 | QString mimetype() const; | 68 | QString mimetype() const; |
69 | QString fileName() const; | 69 | QString fileName() const; |
70 | DocLnk selectedDocument()const; | 70 | DocLnk selectedDocument()const; |
71 | 71 | ||
72 | // static methods | 72 | // static methods |
73 | static QString getOpenFileName(int selector, | 73 | static QString getOpenFileName(int selector, |
74 | const QString& startDir = QString::null, | 74 | const QString& startDir = QString::null, |
75 | const QString &fileName = QString::null, | 75 | const QString &fileName = QString::null, |
76 | const MimeTypes& mime = MimeTypes(), | 76 | const MimeTypes& mime = MimeTypes(), |
77 | QWidget *wid = 0, | 77 | QWidget *wid = 0, |
78 | const QString &caption = QString::null ); | 78 | const QString &caption = QString::null ); |
79 | 79 | ||
80 | static QString getSaveFileName(int selector, | 80 | static QString getSaveFileName(int selector, |
81 | const QString& startDir = QString::null, | 81 | const QString& startDir = QString::null, |
82 | const QString& fileName = QString::null, | 82 | const QString& fileName = QString::null, |
83 | const MimeTypes& mimefilter = MimeTypes(), | 83 | const MimeTypes& mimefilter = MimeTypes(), |
84 | QWidget *wid = 0, | 84 | QWidget *wid = 0, |
85 | const QString &caption = QString::null ); | 85 | const QString &caption = QString::null ); |
86 | 86 | ||
87 | //let's OFileSelector catch up first | 87 | //let's OFileSelector catch up first |
88 | //static QString getExistingDirectory(const QString& startDir = QString::null, | 88 | //static QString getExistingDirectory(const QString& startDir = QString::null, |
89 | // QWidget *parent = 0, | 89 | // QWidget *parent = 0, |
90 | // const QString& caption = QString::null ); | 90 | // const QString& caption = QString::null ); |
91 | private: | 91 | private: |
92 | class OFileDialogPrivate; | 92 | class OFileDialogPrivate; |
93 | OFileDialogPrivate *d; | 93 | OFileDialogPrivate *d; |
94 | OFileSelector *file; | 94 | OFileSelector *file; |
95 | 95 | ||
96 | private slots: | 96 | private slots: |
97 | void slotFileSelected( const QString & ); | 97 | void slotFileSelected( const QString & ); |
98 | void slotDirSelected(const QString & ); | 98 | void slotDirSelected(const QString & ); |
99 | void slotSelectorOk(); | ||
99 | }; | 100 | }; |
100 | #endif | 101 | #endif |
diff --git a/libopie/ofileselector.cc b/libopie/ofileselector.cc deleted file mode 100644 index 6748bec..0000000 --- a/libopie/ofileselector.cc +++ b/dev/null | |||
@@ -1,1310 +0,0 @@ | |||
1 | |||
2 | |||
3 | #include <qwmatrix.h> | ||
4 | #include <qcheckbox.h> | ||
5 | #include <qcombobox.h> | ||
6 | #include <qheader.h> | ||
7 | #include <qlabel.h> | ||
8 | #include <qabstractlayout.h> | ||
9 | #include <qlayout.h> | ||
10 | #include <qlineedit.h> | ||
11 | #include <qlistview.h> | ||
12 | #include <qmessagebox.h> | ||
13 | #include <qpainter.h> | ||
14 | #include <qpushbutton.h> | ||
15 | #include <qwidgetstack.h> | ||
16 | #include <qpopupmenu.h> | ||
17 | #include <qdir.h> | ||
18 | #include <qfile.h> | ||
19 | #include <qfileinfo.h> | ||
20 | #include <qtimer.h> | ||
21 | |||
22 | #include <qpe/qpeapplication.h> | ||
23 | #include <qpe/applnk.h> | ||
24 | #include <qpe/fileselector.h> | ||
25 | #include <qpe/global.h> | ||
26 | #include <qpe/mimetype.h> | ||
27 | #include <qpe/resource.h> | ||
28 | #include <qpe/storage.h> | ||
29 | |||
30 | #include <unistd.h> | ||
31 | #include <stdlib.h> | ||
32 | #include <sys/stat.h> | ||
33 | |||
34 | #include "ofileselector.h" | ||
35 | |||
36 | |||
37 | QMap<QString,QPixmap> *OFileSelector::m_pixmaps = 0; | ||
38 | |||
39 | namespace { | ||
40 | int indexByString( const QComboBox *box, const QString &str ){ | ||
41 | int index= 0; | ||
42 | for(int i= 0; i < box->count(); i++ ){ | ||
43 | if( str == box->text(i ) ){ | ||
44 | index= i; | ||
45 | break; | ||
46 | } | ||
47 | } | ||
48 | return index; | ||
49 | } | ||
50 | class OFileSelectorItem : public QListViewItem { | ||
51 | public: | ||
52 | OFileSelectorItem(QListView *view, const QPixmap &pixmap, const QString &path, | ||
53 | const QString &date, const QString &size, const QString &mDir, | ||
54 | bool isLocked=false, bool isDir=false ): QListViewItem(view) { | ||
55 | setPixmap(0, pixmap ); | ||
56 | setText(1, path ); | ||
57 | setText(2, size ); | ||
58 | setText(3, date ); | ||
59 | //setText(4, mDir ); | ||
60 | m_dir = mDir; | ||
61 | dir = isDir; | ||
62 | mLocked = isLocked; | ||
63 | } | ||
64 | bool isLocked() const{ | ||
65 | return mLocked; | ||
66 | } | ||
67 | QString directory()const{ | ||
68 | return m_dir; | ||
69 | } | ||
70 | bool isDir()const{ | ||
71 | return dir; | ||
72 | } | ||
73 | QString path()const{ | ||
74 | return text(1 ); | ||
75 | } | ||
76 | QString key(int id, bool )const { | ||
77 | QString ke; | ||
78 | if( id == 0 || id == 1 ){ // name | ||
79 | if( dir ){ | ||
80 | ke.append("0" ); | ||
81 | ke.append( text(1) ); | ||
82 | }else{ | ||
83 | ke.append("1" ); | ||
84 | ke.append( text(1) ); | ||
85 | } | ||
86 | }else if( id == 2 ){ // size | ||
87 | return text(2); | ||
88 | }else if( id == 3 ){ // date | ||
89 | return text(3); | ||
90 | } | ||
91 | return ke; | ||
92 | }; | ||
93 | private: | ||
94 | bool mLocked:1; | ||
95 | bool dir:1; | ||
96 | QString m_dir; | ||
97 | }; | ||
98 | }; | ||
99 | |||
100 | |||
101 | OFileSelector::OFileSelector( QWidget *wid, int mode, int selector, | ||
102 | const QString &dirName, | ||
103 | const QString &fileName, | ||
104 | const QMap<QString,QStringList>& mimeTypes) | ||
105 | : QWidget( wid, "OFileSelector") | ||
106 | { | ||
107 | m_mimetypes = mimeTypes; | ||
108 | if (mode == SAVE ) | ||
109 | m_name = fileName; | ||
110 | initVars(); | ||
111 | m_mode = mode; | ||
112 | m_selector = selector; | ||
113 | m_currentDir = dirName; | ||
114 | init(); | ||
115 | //QTimer::singleShot(6*1000, this, SLOT( slotTest() ) ); | ||
116 | } | ||
117 | |||
118 | OFileSelector::OFileSelector(const QString &mimeFilter, QWidget *parent, | ||
119 | const char *name, bool newVisible, | ||
120 | bool closeVisible ) | ||
121 | : QWidget( parent, name ) | ||
122 | { | ||
123 | if (!mimeFilter.isEmpty() ) { | ||
124 | QStringList list = QStringList::split(";", mimeFilter ); | ||
125 | m_mimetypes.insert(mimeFilter, list ); | ||
126 | } | ||
127 | initVars(); | ||
128 | m_currentDir = QPEApplication::documentDir(); | ||
129 | m_mode = FILESELECTOR; | ||
130 | m_selector = NORMAL; | ||
131 | m_shClose = closeVisible; | ||
132 | m_shNew = newVisible; | ||
133 | m_shLne = false; | ||
134 | m_shPerm = false; | ||
135 | m_shYesNo = false; | ||
136 | init(); | ||
137 | |||
138 | } | ||
139 | |||
140 | OFileSelector::~OFileSelector() | ||
141 | { | ||
142 | |||
143 | |||
144 | } | ||
145 | |||
146 | void OFileSelector::setNewVisible( bool visible ) | ||
147 | { | ||
148 | m_shNew = visible; | ||
149 | if( m_selector == NORMAL ){ | ||
150 | delete m_select; | ||
151 | // we need to initialize but keep the selected mimetype | ||
152 | QString mime = currentMimeType(); | ||
153 | m_select = new FileSelector( mime , | ||
154 | m_stack, "fileselector", | ||
155 | m_shNew, m_shClose); | ||
156 | connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ), | ||
157 | this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) ); | ||
158 | connect(m_select, SIGNAL(closeMe() ), | ||
159 | this, SIGNAL(closeMe() ) ); | ||
160 | //connect to close me and other signals as well | ||
161 | m_stack->addWidget( m_select, NORMAL ); | ||
162 | }else{ | ||
163 | m_new->show(); | ||
164 | } | ||
165 | } | ||
166 | void OFileSelector::setCloseVisible( bool visible ) | ||
167 | { | ||
168 | m_shClose = visible; | ||
169 | if( m_selector == NORMAL ){ | ||
170 | setNewVisible( m_shNew ); // yeah baby | ||
171 | }else{ | ||
172 | m_close->show(); | ||
173 | } | ||
174 | } | ||
175 | void OFileSelector::reread() | ||
176 | { | ||
177 | if( m_selector == NORMAL ){ | ||
178 | setNewVisible( m_shNew ); // make it a initializeSelector | ||
179 | }else if ( m_selector == EXTENDED || m_selector == EXTENDED_ALL ){ | ||
180 | reparse(); | ||
181 | //}else{ | ||
182 | //; | ||
183 | } | ||
184 | } | ||
185 | |||
186 | const DocLnk *OFileSelector::selected() | ||
187 | { | ||
188 | DocLnk *lnk = new DocLnk(selectedDocument() ); | ||
189 | return lnk; | ||
190 | } | ||
191 | |||
192 | void OFileSelector::setYesCancelVisible( bool show ) | ||
193 | { | ||
194 | initializeYes(); // FIXME if YesCancel is not shown we will initialize it to hide it :( | ||
195 | m_shYesNo = show; | ||
196 | if( m_shYesNo ) | ||
197 | m_boxOk->show(); | ||
198 | else | ||
199 | m_boxOk->hide(); | ||
200 | |||
201 | } | ||
202 | void OFileSelector::setToolbarVisible( bool show ) | ||
203 | { | ||
204 | m_shTool = show; | ||
205 | initializeListView(); // FIXME see above waste of memory | ||
206 | if(!m_shTool ){ | ||
207 | m_location->hide(); | ||
208 | m_up->hide(); | ||
209 | m_homeButton->hide(); | ||
210 | m_docButton->hide(); | ||
211 | }else{ | ||
212 | m_location->show(); | ||
213 | m_up->show(); | ||
214 | m_homeButton->show(); | ||
215 | m_docButton->show(); | ||
216 | } | ||
217 | } | ||
218 | void OFileSelector::setPermissionBarVisible( bool show ) | ||
219 | { | ||
220 | m_shPerm = show; | ||
221 | initializePerm(); | ||
222 | if( m_shPerm ) | ||
223 | m_checkPerm->show(); | ||
224 | else | ||
225 | m_checkPerm->hide(); | ||
226 | } | ||
227 | void OFileSelector::setLineEditVisible( bool show ) | ||
228 | { | ||
229 | if( show ){ | ||
230 | initializeName(); | ||
231 | m_boxName->show(); | ||
232 | }else{ | ||
233 | if( m_shLne && m_boxName != 0 ){ // check if we showed before this is the way to go | ||
234 | m_boxName->hide(); | ||
235 | } | ||
236 | } | ||
237 | m_shLne = show; | ||
238 | } | ||
239 | |||
240 | void OFileSelector::setChooserVisible( bool show ) | ||
241 | { | ||
242 | m_shChooser = show; | ||
243 | initializeChooser(); | ||
244 | if( m_shChooser ){ | ||
245 | m_boxView->hide(); | ||
246 | }else{ | ||
247 | m_boxView->show(); | ||
248 | } | ||
249 | } | ||
250 | |||
251 | QCheckBox* OFileSelector::permissionCheckbox() | ||
252 | { | ||
253 | if( m_selector == NORMAL ) | ||
254 | return 0l; | ||
255 | else | ||
256 | return m_checkPerm; | ||
257 | } | ||
258 | bool OFileSelector::setPermission()const | ||
259 | { | ||
260 | return m_checkPerm == 0 ? false : m_checkPerm->isChecked(); | ||
261 | } | ||
262 | void OFileSelector::setPermissionChecked( bool check ) | ||
263 | { | ||
264 | if( m_checkPerm ) | ||
265 | m_checkPerm->setChecked( check ); | ||
266 | } | ||
267 | |||
268 | void OFileSelector::setMode(int mode) // FIXME do direct raising | ||
269 | { | ||
270 | m_mode = mode; | ||
271 | if( m_selector == NORMAL ) | ||
272 | return; | ||
273 | } | ||
274 | void OFileSelector::setShowDirs(bool ) | ||
275 | { | ||
276 | m_dir = true; | ||
277 | reparse(); | ||
278 | } | ||
279 | void OFileSelector::setCaseSensetive(bool caSe ) | ||
280 | { | ||
281 | m_case = caSe; | ||
282 | reparse(); | ||
283 | } | ||
284 | void OFileSelector::setShowFiles(bool show ) | ||
285 | { | ||
286 | m_files = show; | ||
287 | reparse(); | ||
288 | } | ||
289 | /// | ||
290 | bool OFileSelector::cd(const QString &path ) | ||
291 | { | ||
292 | m_currentDir = path; | ||
293 | reparse(); | ||
294 | return true; | ||
295 | } | ||
296 | void OFileSelector::setSelector(int mode ) | ||
297 | { | ||
298 | QString text; | ||
299 | switch( mode ){ | ||
300 | case NORMAL: | ||
301 | text = tr("Documents"); | ||
302 | break; | ||
303 | case EXTENDED: | ||
304 | text = tr("Files"); | ||
305 | break; | ||
306 | case EXTENDED_ALL: | ||
307 | text = tr("All Files"); | ||
308 | break; | ||
309 | } | ||
310 | slotViewCheck( text ); | ||
311 | } | ||
312 | |||
313 | void OFileSelector::setPopupMenu(QPopupMenu *popup ) | ||
314 | { | ||
315 | m_custom = popup; | ||
316 | m_showPopup = true; | ||
317 | } | ||
318 | |||
319 | //void OFileSelector::updateL | ||
320 | |||
321 | QString OFileSelector::selectedName() const | ||
322 | { | ||
323 | QString name; | ||
324 | if( m_selector == NORMAL ){ | ||
325 | DocLnk lnk = m_select->selectedDocument(); | ||
326 | name = lnk.file(); | ||
327 | }else if( m_selector == EXTENDED || m_selector == EXTENDED_ALL ){ | ||
328 | if ( m_shLne ) { | ||
329 | name = m_currentDir + "/" +m_edit->text(); | ||
330 | }else{ | ||
331 | QListViewItem *item = m_View->currentItem(); | ||
332 | if( item != 0 ) | ||
333 | name = m_currentDir + "/" + item->text( 1 ); | ||
334 | } | ||
335 | }else { // installed view | ||
336 | ; | ||
337 | } | ||
338 | return name; | ||
339 | } | ||
340 | QStringList OFileSelector::selectedNames()const | ||
341 | { | ||
342 | QStringList list; | ||
343 | if( m_selector == NORMAL ){ | ||
344 | list << selectedName(); | ||
345 | }else if ( m_selector == EXTENDED || m_selector == EXTENDED_ALL ) { | ||
346 | list << selectedName(); // FIXME implement multiple Selections | ||
347 | } | ||
348 | return list; | ||
349 | } | ||
350 | /** If mode is set to the Dir selection this will return the selected path. | ||
351 | * | ||
352 | * | ||
353 | */ | ||
354 | QString OFileSelector::selectedPath()const | ||
355 | { | ||
356 | QString path; | ||
357 | if( m_selector == NORMAL ){ | ||
358 | path = QPEApplication::documentDir(); | ||
359 | }else if( m_selector == EXTENDED || m_selector == EXTENDED_ALL ){ | ||
360 | ; | ||
361 | } | ||
362 | return path; | ||
363 | } | ||
364 | QStringList OFileSelector::selectedPaths() const | ||
365 | { | ||
366 | QStringList list; | ||
367 | list << selectedPath(); | ||
368 | return list; | ||
369 | } | ||
370 | QString OFileSelector::directory()const | ||
371 | { | ||
372 | if( m_selector == NORMAL ) | ||
373 | return QPEApplication::documentDir(); | ||
374 | |||
375 | return QDir(m_currentDir).absPath(); | ||
376 | } | ||
377 | |||
378 | int OFileSelector::fileCount() const | ||
379 | { | ||
380 | int count; | ||
381 | switch( m_selector ){ | ||
382 | case NORMAL: | ||
383 | count = m_select->fileCount(); | ||
384 | break; | ||
385 | //case CUSTOM: | ||
386 | case EXTENDED: | ||
387 | case EXTENDED_ALL: | ||
388 | default: | ||
389 | count = m_View->childCount(); | ||
390 | break; | ||
391 | } | ||
392 | return count; | ||
393 | } | ||
394 | DocLnk OFileSelector::selectedDocument() const | ||
395 | { | ||
396 | DocLnk lnk; | ||
397 | switch( m_selector ){ | ||
398 | case NORMAL:{ | ||
399 | lnk = m_select->selectedDocument(); | ||
400 | break; | ||
401 | } | ||
402 | case EXTENDED: | ||
403 | case EXTENDED_ALL: | ||
404 | default: | ||
405 | lnk = DocLnk( selectedName() ); // new DocLnk | ||
406 | break; | ||
407 | } | ||
408 | return lnk; | ||
409 | } | ||
410 | QValueList<DocLnk> OFileSelector::selectedDocuments() const | ||
411 | { | ||
412 | QValueList<DocLnk> docs; | ||
413 | docs.append( selectedDocument() ); | ||
414 | return docs; | ||
415 | } | ||
416 | |||
417 | |||
418 | // slots internal | ||
419 | |||
420 | void OFileSelector::slotOk() | ||
421 | { | ||
422 | emit ok(); | ||
423 | } | ||
424 | void OFileSelector::slotCancel() | ||
425 | { | ||
426 | emit cancel(); | ||
427 | } | ||
428 | void OFileSelector::slotViewCheck(const QString &sel) | ||
429 | { | ||
430 | if( sel == tr("Documents" ) ){ | ||
431 | if( m_select == 0 ){ | ||
432 | // autMime? fix cause now we use All and not the current | ||
433 | // yes currentMime fixes that for us | ||
434 | QString mime = currentMimeType(); | ||
435 | m_select = new FileSelector(mime, | ||
436 | m_stack, "fileselector", | ||
437 | m_shNew, m_shClose); | ||
438 | connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ), | ||
439 | this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) ); | ||
440 | connect(m_select, SIGNAL(closeMe() ), | ||
441 | this, SIGNAL(closeMe() ) ); | ||
442 | //connect to close me and other signals as well | ||
443 | |||
444 | m_stack->addWidget( m_select, NORMAL ); | ||
445 | } | ||
446 | m_stack->raiseWidget( NORMAL ); | ||
447 | m_selector = NORMAL; | ||
448 | }else if( sel == tr("Files") ){ | ||
449 | m_selector = EXTENDED; | ||
450 | initializeListView(); | ||
451 | reparse(); | ||
452 | m_stack->raiseWidget( EXTENDED ); | ||
453 | }else if( sel == tr("All Files") ){ | ||
454 | m_selector = EXTENDED_ALL; | ||
455 | initializeListView(); | ||
456 | reparse(); | ||
457 | m_stack->raiseWidget( EXTENDED ); // same widget other QFileFilter | ||
458 | } | ||
459 | } | ||
460 | // not yet finished..... | ||
461 | QString OFileSelector::currentMimeType() const{ | ||
462 | QString mime; | ||
463 | QString currentText; | ||
464 | if (m_shChooser ) | ||
465 | currentText = m_mimeCheck->currentText(); | ||
466 | |||
467 | if (tr("All") == currentText ) return QString::null; | ||
468 | else if (currentText.isEmpty() ) { | ||
469 | ; | ||
470 | }else { | ||
471 | QMap<QString, QStringList>::ConstIterator it; | ||
472 | it = m_mimetypes.find( currentText ); | ||
473 | if ( it == m_mimetypes.end() ) { | ||
474 | mime = it.data().join(";"); | ||
475 | }else{ | ||
476 | mime = currentText; | ||
477 | } | ||
478 | } | ||
479 | return mime; | ||
480 | } | ||
481 | void OFileSelector::slotMimeCheck(const QString &mime) | ||
482 | { | ||
483 | if( m_selector == NORMAL ){ | ||
484 | //if( m_autoMime ){ | ||
485 | QString newMimeType; | ||
486 | if (mime != tr("All") ) { | ||
487 | QMap<QString, QStringList>::Iterator it; | ||
488 | it = m_mimetypes.find(mime); | ||
489 | if ( it != m_mimetypes.end() ) { | ||
490 | newMimeType = it.data().join(";"); | ||
491 | }else{ | ||
492 | newMimeType = mime; | ||
493 | } | ||
494 | } | ||
495 | delete m_select; | ||
496 | m_select = new FileSelector( newMimeType, | ||
497 | m_stack, "fileselector", | ||
498 | m_shNew, m_shClose); | ||
499 | |||
500 | connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ), | ||
501 | this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) ); | ||
502 | connect(m_select, SIGNAL(closeMe() ), | ||
503 | this, SIGNAL(closeMe() ) ); | ||
504 | //connect to close me and other signals as well | ||
505 | m_stack->addWidget( m_select, NORMAL ); | ||
506 | m_stack->raiseWidget( NORMAL ); | ||
507 | updateMimes(); | ||
508 | updateMimeCheck(); | ||
509 | m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, mime) ); | ||
510 | //} | ||
511 | }else{ // others | ||
512 | qWarning("Mime %s", mime.latin1() ); | ||
513 | if(m_shChooser ){ | ||
514 | qWarning("Current Text %s", m_mimeCheck->currentText().latin1() ); | ||
515 | //m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, mime) ); | ||
516 | } | ||
517 | reparse(); | ||
518 | } | ||
519 | |||
520 | } | ||
521 | /* | ||
522 | * Ok if a non dir gets inserted into this combobox | ||
523 | * we need to change it | ||
524 | * QFileInfo and dirPath will give us the right Dir | ||
525 | */ | ||
526 | void OFileSelector::slotLocationActivated(const QString &file) | ||
527 | { | ||
528 | qWarning("slotLocationActivated"); | ||
529 | QString name = file.left( file.find("<-", 0, TRUE ) ); | ||
530 | QFileInfo info( name ); | ||
531 | if ( info.isFile() ) | ||
532 | cd(info.dirPath( TRUE ) ); //absolute | ||
533 | else | ||
534 | cd(name ); | ||
535 | reparse(); | ||
536 | } | ||
537 | void OFileSelector::slotInsertLocationPath(const QString ¤tPath, int count) | ||
538 | { | ||
539 | QStringList pathList; | ||
540 | bool underDog = FALSE; | ||
541 | for(int i=0;i<count;i++) { | ||
542 | pathList << m_location->text(i); | ||
543 | if( m_location->text(i) == currentPath) | ||
544 | underDog = TRUE; | ||
545 | } | ||
546 | if( !underDog) { | ||
547 | m_location->clear(); | ||
548 | if( currentPath.left(2)=="//") | ||
549 | pathList.append( currentPath.right(currentPath.length()-1) ); | ||
550 | else | ||
551 | pathList.append( currentPath ); | ||
552 | m_location->insertStringList( pathList,-1); | ||
553 | } | ||
554 | } | ||
555 | /* | ||
556 | * Do not crash anymore | ||
557 | * don't try to change dir to a file | ||
558 | */ | ||
559 | void OFileSelector::locationComboChanged() | ||
560 | { | ||
561 | QFileInfo info( m_location->lineEdit()->text() ); | ||
562 | qWarning("info %s %s", info.dirPath(true).latin1(), m_location->lineEdit()->text().latin1() ); | ||
563 | if (info.isFile() ) | ||
564 | cd(info.dirPath(TRUE) ); //absolute path | ||
565 | else | ||
566 | cd( m_location->lineEdit()->text() ); | ||
567 | |||
568 | reparse(); | ||
569 | } | ||
570 | void OFileSelector::init() | ||
571 | { | ||
572 | m_lay = new QVBoxLayout( this ); | ||
573 | m_lay->setSpacing(0 ); | ||
574 | |||
575 | m_stack = new QWidgetStack( this ); | ||
576 | if( m_selector == NORMAL ){ | ||
577 | QString mime; | ||
578 | if (!m_autoMime) { | ||
579 | if (!m_mimetypes.isEmpty() ) { | ||
580 | QMap<QString, QStringList>::Iterator it; | ||
581 | it = m_mimetypes.begin(); // cause we're in the init | ||
582 | mime = it.data().join(";"); | ||
583 | } | ||
584 | } | ||
585 | m_select = new FileSelector(mime, | ||
586 | m_stack, "fileselector", | ||
587 | m_shNew, m_shClose); | ||
588 | |||
589 | connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ), | ||
590 | this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) ); | ||
591 | connect(m_select, SIGNAL(closeMe() ), | ||
592 | this, SIGNAL( closeMe() ) ); | ||
593 | //connect to close me and other signals as well | ||
594 | |||
595 | m_stack->addWidget( m_select, NORMAL ); | ||
596 | m_stack->raiseWidget( NORMAL ); | ||
597 | }else{ // we're in init so it will be EXTENDED or EXTENDED_ALL | ||
598 | // and initializeListview will take care of those | ||
599 | // toolbar get's generade in initializeListView | ||
600 | initializeListView( ); // will raise the widget as well | ||
601 | m_stack->raiseWidget( EXTENDED ); | ||
602 | } | ||
603 | m_lay->addWidget( m_stack, 100 ); // add to the layout 10 = stretch | ||
604 | |||
605 | if( m_shLne ) // the LineEdit with the current FileName | ||
606 | initializeName(); | ||
607 | |||
608 | if( m_shPerm ) // the Permission QCheckBox | ||
609 | initializePerm(); | ||
610 | |||
611 | if( m_shChooser ) // the Chooser for the view and Mimetypes | ||
612 | initializeChooser(); | ||
613 | |||
614 | if( m_shYesNo ) // the Yes No button row | ||
615 | initializeYes( ); | ||
616 | |||
617 | if (m_selector != NORMAL ) | ||
618 | reparse(); | ||
619 | } | ||
620 | void OFileSelector::updateMimes() | ||
621 | { | ||
622 | if( m_autoMime ){ | ||
623 | m_mimetypes.clear(); | ||
624 | m_mimetypes.insert( tr("All"), QString::null ); | ||
625 | if( m_selector == NORMAL ){ | ||
626 | DocLnkSet set; | ||
627 | Global::findDocuments(&set, QString::null ); | ||
628 | QListIterator<DocLnk> dit( set.children() ); | ||
629 | for( ; dit.current(); ++dit ){ | ||
630 | if( !m_mimetypes.contains( (*dit)->type() ) ) | ||
631 | m_mimetypes.insert( (*dit)->type(), (*dit)->type() ); | ||
632 | } | ||
633 | }// else done in reparse | ||
634 | } | ||
635 | } | ||
636 | void OFileSelector::initVars() | ||
637 | { | ||
638 | if( m_mimetypes.isEmpty() ) | ||
639 | m_autoMime = true; | ||
640 | else | ||
641 | m_autoMime = false; | ||
642 | m_shClose = false; | ||
643 | m_shNew = false; | ||
644 | m_shTool = true; | ||
645 | m_shPerm = false; | ||
646 | m_shLne = true; | ||
647 | m_shChooser = true; | ||
648 | m_shYesNo = true; | ||
649 | m_case = false; | ||
650 | m_dir = true; | ||
651 | m_files = true; | ||
652 | m_showPopup = false; | ||
653 | if(m_pixmaps == 0 ) // init the pixmaps | ||
654 | initPics(); | ||
655 | |||
656 | // pointers | ||
657 | m_location = 0; | ||
658 | m_mimeCheck = 0; | ||
659 | m_viewCheck = 0; | ||
660 | m_homeButton = 0; | ||
661 | m_docButton = 0; | ||
662 | m_hideButton = 0; | ||
663 | m_ok = 0; | ||
664 | m_cancel = 0; | ||
665 | m_reread = 0; | ||
666 | m_up = 0; | ||
667 | m_View = 0; | ||
668 | m_checkPerm = 0; | ||
669 | m_pseudo = 0; | ||
670 | m_pseudoLayout = 0; | ||
671 | m_select = 0; | ||
672 | m_stack = 0; | ||
673 | m_lay = 0; | ||
674 | m_Oselector = 0; | ||
675 | m_boxToolbar = 0; | ||
676 | m_boxOk = 0; | ||
677 | m_boxName = 0; | ||
678 | m_boxView = 0; | ||
679 | m_custom = 0; | ||
680 | m_edit = 0; | ||
681 | m_fnLabel = 0; | ||
682 | m_new = 0; | ||
683 | m_close = 0; | ||
684 | } | ||
685 | void OFileSelector::addFile(const QString &/*mime*/, QFileInfo *info, bool symlink) | ||
686 | { | ||
687 | if(!m_files) | ||
688 | return; | ||
689 | // if( !compliesMime(info->absFilePath(), mime ) ) | ||
690 | // return; | ||
691 | MimeType type( info->absFilePath() ); | ||
692 | if (!compliesMime( type.id() ) ) | ||
693 | return; | ||
694 | |||
695 | QPixmap pix = type.pixmap(); | ||
696 | QString dir; | ||
697 | QString name; | ||
698 | bool locked; | ||
699 | if( pix.isNull() ) { | ||
700 | //TODO make this scaled pixmap global, so we dont have to keep doing this | ||
701 | QWMatrix matrix; | ||
702 | QPixmap pixer(Resource::loadPixmap( "UnknownDocument" )); | ||
703 | matrix.scale( .4, .4); | ||
704 | pix = pixer.xForm(matrix); | ||
705 | // pix = Resource::loadPixmap( "UnknownDocument-14"); | ||
706 | } | ||
707 | dir = info->dirPath( true ); | ||
708 | if( symlink ) | ||
709 | name = info->fileName() + " -> " +info->dirPath() + "/" + info->readLink(); | ||
710 | else { | ||
711 | name = info->fileName(); | ||
712 | if( ( m_mode == OPEN && !info->isReadable() )|| | ||
713 | ( m_mode == SAVE && !info->isWritable() ) ){ | ||
714 | |||
715 | locked = true; pix = Resource::loadPixmap("locked"); | ||
716 | } | ||
717 | } | ||
718 | new OFileSelectorItem( m_View, pix, name, | ||
719 | info->lastModified().toString(), | ||
720 | QString::number( info->size() ), | ||
721 | dir, locked ); | ||
722 | } | ||
723 | void OFileSelector::addDir(const QString &/*mime*/, QFileInfo *info, bool symlink ) | ||
724 | { | ||
725 | if(!m_dir) | ||
726 | return; | ||
727 | if( m_selector == EXTENDED_ALL || m_selector == EXTENDED ){ | ||
728 | bool locked = false; | ||
729 | QString name; | ||
730 | QPixmap pix; | ||
731 | if( ( m_mode == OPEN && !info->isReadable() ) || ( m_mode == SAVE && !info->isWritable() ) ){ | ||
732 | locked = true; | ||
733 | if( symlink ) | ||
734 | pix = (*m_pixmaps)["symlinkedlocked"]; | ||
735 | else | ||
736 | pix = Resource::loadPixmap("lockedfolder"); | ||
737 | }else { // readable | ||
738 | pix = symlink ? (*m_pixmaps)["dirsymlink"] : Resource::loadPixmap("folder") ; | ||
739 | } | ||
740 | name = symlink ? info->fileName() + "->" + info->dirPath(true) + "/" +info->readLink() : info->fileName() ; | ||
741 | new OFileSelectorItem( m_View, pix, name, | ||
742 | info->lastModified().toString(), | ||
743 | QString::number( info->size() ), | ||
744 | info->dirPath( true ), locked, | ||
745 | true ); | ||
746 | |||
747 | }// else CUSTOM View | ||
748 | } | ||
749 | void OFileSelector::delItems() | ||
750 | { | ||
751 | |||
752 | } | ||
753 | void OFileSelector::initializeName() | ||
754 | { | ||
755 | /** Name Layout Line | ||
756 | * This is the Layout line arranged in | ||
757 | * horizontal way each components | ||
758 | * are next to each other | ||
759 | * but we will only do this if | ||
760 | * we didn't initialize a while ago. | ||
761 | */ | ||
762 | if( m_boxName == 0 ){ | ||
763 | m_boxName = new QHBox( this ); // remove this this? or use a QHBox | ||
764 | m_fnLabel = new QLabel( m_boxName ); | ||
765 | m_fnLabel->setText( tr("Name:") ); | ||
766 | m_edit = new QLineEdit( m_boxName ); | ||
767 | m_edit->setText( m_name ); | ||
768 | //m_boxName->addWidget( m_fnLabel ); | ||
769 | m_boxName->setMargin( 5 ); | ||
770 | m_boxName->setSpacing( 8 ); | ||
771 | //m_boxName->setStretchFactor(m_edit, 100 ); // 100 is stretch factor | ||
772 | |||
773 | m_lay->addWidget( m_boxName, 0 ); // add it to the topLevel layout | ||
774 | }// else we already initialized | ||
775 | // maybe show the components? | ||
776 | // | ||
777 | } | ||
778 | void OFileSelector::initializeYes() | ||
779 | { | ||
780 | /** The Save Cancel bar | ||
781 | * | ||
782 | */ | ||
783 | if( m_boxOk == 0 ){ | ||
784 | m_boxOk = new QHBox( this ); | ||
785 | m_ok = new QPushButton( tr("&Save"),m_boxOk , "save" ); | ||
786 | m_cancel = new QPushButton( tr("C&ancel"), m_boxOk, "cancel" ); | ||
787 | |||
788 | //m_boxOk->addWidget( m_ok ); | ||
789 | //m_boxOk->addWidget( m_cancel ); | ||
790 | m_boxOk->setMargin( 5 ); | ||
791 | m_boxOk->setSpacing( 10 ); | ||
792 | m_lay->addWidget( m_boxOk, 0 ); | ||
793 | |||
794 | connect( m_ok, SIGNAL( clicked() ), | ||
795 | this, SLOT(slotOk() ) ); | ||
796 | connect( m_cancel, SIGNAL( clicked() ), | ||
797 | this, SLOT( slotCancel() ) ); | ||
798 | } | ||
799 | } | ||
800 | /* | ||
801 | * OK m_mimeCheck is a QComboBox we now want to fill | ||
802 | * out that combobox | ||
803 | * if automime we need to update the mimetypes | ||
804 | */ | ||
805 | void OFileSelector::updateMimeCheck() { | ||
806 | m_mimeCheck->clear(); | ||
807 | if (m_autoMime ) { | ||
808 | //m_mimeCheck->insertItem( tr("All") ); | ||
809 | updateMimes(); | ||
810 | } | ||
811 | |||
812 | QMap<QString, QStringList>::Iterator it; | ||
813 | for (it = m_mimetypes.begin(); it != m_mimetypes.end(); ++it ) { | ||
814 | m_mimeCheck->insertItem( it.key() ); | ||
815 | } | ||
816 | } | ||
817 | |||
818 | void OFileSelector::initializeChooser() | ||
819 | { | ||
820 | if( m_boxView == 0 ){ | ||
821 | m_boxView = new QHBox( this ); | ||
822 | m_viewCheck = new QComboBox( m_boxView, "view check"); | ||
823 | m_mimeCheck = new QComboBox( m_boxView, "mime check"); | ||
824 | m_boxView->setSpacing( 8 ); | ||
825 | m_lay->addWidget(m_boxView, 0 ); | ||
826 | |||
827 | m_viewCheck->insertItem( tr("Documents") ); | ||
828 | m_viewCheck->insertItem( tr("Files") ); | ||
829 | m_viewCheck->insertItem( tr("All Files") ); | ||
830 | updateMimeCheck(); | ||
831 | |||
832 | connect( m_viewCheck, SIGNAL( activated(const QString & ) ), | ||
833 | this, SLOT( slotViewCheck(const QString & ) ) ); | ||
834 | connect( m_mimeCheck, SIGNAL( activated(const QString & ) ), | ||
835 | this, SLOT( slotMimeCheck( const QString & ) ) ); | ||
836 | } | ||
837 | } | ||
838 | void OFileSelector::initializeListView() | ||
839 | { | ||
840 | qWarning("initializeListView"); | ||
841 | if( m_pseudo == 0 ){ | ||
842 | qWarning("init"); | ||
843 | m_pseudo = new QWidget( m_stack, "Pseudo Widget"); | ||
844 | m_pseudoLayout = new QVBoxLayout( m_pseudo ); | ||
845 | // toolbar | ||
846 | m_boxToolbar = new QHBox( m_pseudo ); | ||
847 | m_boxToolbar->setSpacing(0 ); // next to each other please | ||
848 | |||
849 | // toolbar members | ||
850 | { | ||
851 | // location QComboBox | ||
852 | m_location = new QComboBox( m_boxToolbar ); | ||
853 | m_location->setEditable( TRUE ); | ||
854 | m_location->setDuplicatesEnabled( FALSE ); | ||
855 | connect( m_location, SIGNAL(activated(const QString &) ), | ||
856 | this, SLOT( slotLocationActivated(const QString &) ) ); | ||
857 | connect( m_location->lineEdit(), SIGNAL(returnPressed() ), | ||
858 | this, SLOT(locationComboChanged() ) ); | ||
859 | // UP Button | ||
860 | m_up = new QPushButton(Resource::loadIconSet("up"),"", | ||
861 | m_boxToolbar,"cdUpButton"); | ||
862 | m_up->setFixedSize( QSize( 20, 20 ) ); | ||
863 | connect(m_up ,SIGNAL(clicked()),this,SLOT(cdUP() ) ); | ||
864 | m_up->setFlat(TRUE); | ||
865 | |||
866 | // Home Button | ||
867 | m_homeButton = new QPushButton(Resource::loadIconSet("home") , | ||
868 | "", m_boxToolbar); | ||
869 | m_homeButton->setFixedSize( QSize( 20, 20 ) ); | ||
870 | connect(m_homeButton,SIGNAL(clicked()),this,SLOT(slotHome() ) ); | ||
871 | m_homeButton->setFlat(TRUE); | ||
872 | // Documents Button | ||
873 | m_docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"", | ||
874 | m_boxToolbar,"docsButton"); | ||
875 | m_docButton->setFixedSize( QSize( 20, 20 ) ); | ||
876 | connect(m_homeButton,SIGNAL(clicked()),this,SLOT(slotDoc() ) ); | ||
877 | m_docButton->setFlat(TRUE); | ||
878 | |||
879 | // Close button | ||
880 | m_close = new QPushButton( Resource::loadIconSet( "close"), "", | ||
881 | m_boxToolbar ); | ||
882 | connect( m_close, SIGNAL(clicked() ), this, SIGNAL(closeMe() ) ); | ||
883 | m_close->setFixedSize( 20, 20 ); | ||
884 | |||
885 | m_boxToolbar->setFixedHeight( 20 ); | ||
886 | m_pseudoLayout->addWidget(m_boxToolbar ); | ||
887 | |||
888 | // let;s fill the Location ComboBox | ||
889 | StorageInfo storage; | ||
890 | const QList<FileSystem> &fs = storage.fileSystems(); | ||
891 | QListIterator<FileSystem> it ( fs ); | ||
892 | for( ; it.current(); ++it ){ | ||
893 | const QString disk = (*it)->name(); | ||
894 | const QString path = (*it)->path(); | ||
895 | m_location->insertItem(path+ "<-"+disk ); | ||
896 | } | ||
897 | int count = m_location->count(); | ||
898 | m_location->insertItem( m_currentDir ); | ||
899 | m_location->setCurrentItem( count ); | ||
900 | // due to the New and Close button we can not simply hide m_boxToolBar to not show it | ||
901 | if( !m_shTool ){ | ||
902 | m_location->hide( ); | ||
903 | m_up->hide( ); | ||
904 | m_homeButton->hide( ); | ||
905 | m_docButton->hide( ); | ||
906 | } | ||
907 | if(!m_shClose ) | ||
908 | m_close->hide(); | ||
909 | //if(!m_shNew) | ||
910 | //m_close->hide(); | ||
911 | |||
912 | } // off toolbar | ||
913 | // the Main ListView | ||
914 | // make a QWidgetStack first so Views can share the Toolbar | ||
915 | m_View = new QListView( m_pseudo, "Extended view"); | ||
916 | QPEApplication::setStylusOperation( m_View->viewport(), | ||
917 | QPEApplication::RightOnHold); | ||
918 | m_View->addColumn(" " ); | ||
919 | m_View->addColumn(tr("Name"), 135 ); | ||
920 | m_View->addColumn(tr("Size"), -1 ); | ||
921 | m_View->addColumn(tr("Date"), 60 ); | ||
922 | m_View->addColumn(tr("Mime Type"), -1 ); | ||
923 | QHeader *header = m_View->header(); | ||
924 | header->hide(); | ||
925 | m_View->setSorting( 1 ); | ||
926 | m_View->setAllColumnsShowFocus( TRUE ); | ||
927 | |||
928 | connect(m_View, SIGNAL(selectionChanged() ), | ||
929 | this, SLOT(slotSelectionChanged() ) ); | ||
930 | |||
931 | connect(m_View, SIGNAL(clicked(QListViewItem *) ), | ||
932 | // connect(m_View, SIGNAL(currentChanged(QListViewItem *) ), | ||
933 | this, SLOT(slotCurrentChanged(QListViewItem * ) ) ); | ||
934 | |||
935 | connect(m_View, SIGNAL(mouseButtonClicked(int, QListViewItem*, const QPoint &, int) ), | ||
936 | this, SLOT(slotClicked( int, QListViewItem *, const QPoint &, int) ) ); | ||
937 | |||
938 | connect(m_View, SIGNAL(mouseButtonPressed(int, QListViewItem *, const QPoint &, int )), | ||
939 | this, SLOT(slotRightButton(int, QListViewItem *, const QPoint &, int ) ) ); | ||
940 | |||
941 | m_pseudoLayout->addWidget( m_View, 288 ); | ||
942 | m_stack->addWidget( m_pseudo, EXTENDED ); | ||
943 | } | ||
944 | } | ||
945 | void OFileSelector::initializePerm() | ||
946 | { | ||
947 | if( m_checkPerm == 0 ){ | ||
948 | m_checkPerm = new QCheckBox(tr("Ser Permission"), this, "perm"); | ||
949 | m_checkPerm->setChecked( false ); | ||
950 | m_lay->addWidget( m_checkPerm ); | ||
951 | |||
952 | } | ||
953 | } | ||
954 | void OFileSelector::initPics() | ||
955 | { | ||
956 | m_pixmaps = new QMap<QString,QPixmap>; | ||
957 | QPixmap pm = Resource::loadPixmap( "folder" ); | ||
958 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); | ||
959 | QPainter painter( &pm ); | ||
960 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); | ||
961 | pm.setMask( pm.createHeuristicMask( FALSE ) ); | ||
962 | m_pixmaps->insert("dirsymlink", pm ); | ||
963 | |||
964 | QPixmap pm2 = Resource::loadPixmap( "lockedfolder" ); | ||
965 | QPainter pen(&pm2 ); | ||
966 | pen.drawPixmap(pm2.width()-lnk.width(), pm2.height()-lnk.height(), lnk ); | ||
967 | pm2.setMask( pm2.createHeuristicMask( FALSE ) ); | ||
968 | m_pixmaps->insert("symlinkedlocked", pm2 ); | ||
969 | } | ||
970 | // if a mime complies with the m_mimeCheck->currentItem | ||
971 | bool OFileSelector::compliesMime( const QString &path, const QString &mime ) | ||
972 | { | ||
973 | if( mime == "All" ) | ||
974 | return true; | ||
975 | MimeType type( path ); | ||
976 | if( type.id() == mime ) | ||
977 | return true; | ||
978 | return false; | ||
979 | } | ||
980 | /* check if the mimetype in mime | ||
981 | * complies with the one which is current | ||
982 | */ | ||
983 | /* | ||
984 | * We've the mimetype of the file | ||
985 | * We need to get the stringlist of the current mimetype | ||
986 | * | ||
987 | * mime = image/jpeg | ||
988 | * QStringList = 'image/*' | ||
989 | * or QStringList = image/jpeg;image/png;application/x-ogg | ||
990 | * or QStringList = application/x-ogg;image/*; | ||
991 | * with all these mime filters it should get acceptes | ||
992 | * to do so we need to look if mime is contained inside | ||
993 | * the stringlist | ||
994 | * if it's contained return true | ||
995 | * if not ( I'm no RegExp expert at all ) we'll look if a '/*' | ||
996 | * is contained in the mimefilter and then we will | ||
997 | * look if both are equal until the '/' | ||
998 | */ | ||
999 | bool OFileSelector::compliesMime( const QString& mime ) { | ||
1000 | qWarning("mimetype is %s", mime.latin1() ); | ||
1001 | QString currentText; | ||
1002 | if (m_shChooser ) | ||
1003 | currentText = m_mimeCheck->currentText(); | ||
1004 | |||
1005 | qWarning("current text is %s", currentText.latin1() ); | ||
1006 | QMap<QString, QStringList>::Iterator it; | ||
1007 | QStringList list; | ||
1008 | if ( currentText == tr("All") ) return true; | ||
1009 | else if ( currentText.isEmpty() && !m_mimetypes.isEmpty() ) { | ||
1010 | it = m_mimetypes.begin(); | ||
1011 | list = it.data(); | ||
1012 | }else if ( currentText.isEmpty() ) return true; | ||
1013 | else{ | ||
1014 | it = m_mimetypes.find(currentText ); | ||
1015 | if ( it == m_mimetypes.end() ) qWarning("not there"), list << currentText; | ||
1016 | else qWarning("found"), list = it.data(); | ||
1017 | } | ||
1018 | // dump it now | ||
1019 | //for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { | ||
1020 | // qWarning( "%s", (*it).latin1() ); | ||
1021 | //} | ||
1022 | |||
1023 | |||
1024 | if ( list.contains(mime) ) return true; | ||
1025 | qWarning("list doesn't contain it "); | ||
1026 | QStringList::Iterator it2; | ||
1027 | int pos; | ||
1028 | for ( it2 = list.begin(); it2 != list.end(); ++it2 ) { | ||
1029 | pos = (*it2).findRev("/*"); | ||
1030 | if ( pos >= 0 ) { | ||
1031 | if ( mime.contains( (*it2).left(pos) ) ) return true; | ||
1032 | } | ||
1033 | } | ||
1034 | return false; | ||
1035 | } | ||
1036 | void OFileSelector::slotFileSelected( const QString &string ) | ||
1037 | { | ||
1038 | if( m_shLne ) | ||
1039 | m_edit->setText( string ); | ||
1040 | emit fileSelected( string ); | ||
1041 | } | ||
1042 | void OFileSelector::slotFileBridgeSelected( const DocLnk &lnk ) | ||
1043 | { | ||
1044 | slotFileSelected( lnk.name() ); | ||
1045 | emit fileSelected( lnk ); | ||
1046 | } | ||
1047 | void OFileSelector::slotSelectionChanged() | ||
1048 | { | ||
1049 | |||
1050 | } | ||
1051 | void OFileSelector::slotCurrentChanged(QListViewItem* item ) | ||
1052 | { | ||
1053 | if( item == 0 ) | ||
1054 | return; | ||
1055 | if( m_selector == EXTENDED || m_selector == EXTENDED_ALL ) { | ||
1056 | OFileSelectorItem *sel = (OFileSelectorItem*) item; // start to use the C++ casts ;) | ||
1057 | qWarning("current changed"); | ||
1058 | if(!sel->isDir() ){ | ||
1059 | if( m_shLne ) | ||
1060 | m_edit->setText( sel->text(1) ); | ||
1061 | |||
1062 | if (m_mode == FILESELECTOR ) { | ||
1063 | QStringList str = QStringList::split("->", sel->text(1) ); | ||
1064 | QString path =sel->directory() + "/" + str[0].stripWhiteSpace(); | ||
1065 | emit fileSelected(path ); | ||
1066 | DocLnk lnk( path ); | ||
1067 | emit fileSelected(lnk ); | ||
1068 | } | ||
1069 | } | ||
1070 | } | ||
1071 | } | ||
1072 | void OFileSelector::slotClicked( int button, QListViewItem *item, const QPoint &, int) | ||
1073 | { | ||
1074 | if ( item == 0 ) | ||
1075 | return; | ||
1076 | |||
1077 | if( button != Qt::LeftButton ) | ||
1078 | return; | ||
1079 | |||
1080 | switch( m_selector ){ | ||
1081 | default: | ||
1082 | break; | ||
1083 | case EXTENDED: // fall through | ||
1084 | case EXTENDED_ALL:{ | ||
1085 | OFileSelectorItem *sel = (OFileSelectorItem*)item; | ||
1086 | if(!sel->isLocked() ){ | ||
1087 | QStringList str = QStringList::split("->", sel->text(1) ); | ||
1088 | if( sel->isDir() ){ | ||
1089 | cd( sel->directory() + "/" + str[0].stripWhiteSpace() ); | ||
1090 | // if MODE Dir m_shLne set the Text | ||
1091 | }else{ | ||
1092 | if( m_shLne ) | ||
1093 | m_edit->setText( str[0].stripWhiteSpace() ); | ||
1094 | qWarning("selected here in slot clicked"); | ||
1095 | emit fileSelected( sel->directory() + "/" + str[0].stripWhiteSpace() ); | ||
1096 | DocLnk lnk( sel->directory() + "/" + str[0].stripWhiteSpace() ); | ||
1097 | qWarning("file selected"); | ||
1098 | emit fileSelected( lnk ); | ||
1099 | } | ||
1100 | } | ||
1101 | break; | ||
1102 | } | ||
1103 | } | ||
1104 | } | ||
1105 | void OFileSelector::slotRightButton(int button, QListViewItem *item, const QPoint &, int ) | ||
1106 | { | ||
1107 | if( item == 0 ) | ||
1108 | return; | ||
1109 | |||
1110 | if( button != Qt::RightButton ) | ||
1111 | return; | ||
1112 | slotContextMenu( item ); | ||
1113 | } | ||
1114 | void OFileSelector::slotContextMenu( QListViewItem * /*item*/) | ||
1115 | { | ||
1116 | |||
1117 | } | ||
1118 | void OFileSelector::slotChangedDir() | ||
1119 | { | ||
1120 | OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem(); | ||
1121 | if(sel->isDir() ){ | ||
1122 | QStringList str = QStringList::split("->", sel->text(1) ); | ||
1123 | cd( sel->directory() + "/" + str[0].stripWhiteSpace() ); | ||
1124 | } | ||
1125 | } | ||
1126 | void OFileSelector::slotOpen() | ||
1127 | { | ||
1128 | OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem(); | ||
1129 | if(!sel->isDir() ){ | ||
1130 | QStringList str = QStringList::split("->", sel->text(1) ); | ||
1131 | slotFileSelected( sel->directory() +"/" +str[0].stripWhiteSpace() ); | ||
1132 | qWarning("slot open"); | ||
1133 | // DocLnk lnk( sel->directory() + "/" + str[0].stripWhiteSpace() ); | ||
1134 | //emit fileSelected( lnk ); | ||
1135 | } | ||
1136 | } | ||
1137 | void OFileSelector::slotRescan() | ||
1138 | { | ||
1139 | |||
1140 | } | ||
1141 | void OFileSelector::slotRename() | ||
1142 | { | ||
1143 | reparse(); | ||
1144 | } | ||
1145 | void OFileSelector::slotDelete() | ||
1146 | { | ||
1147 | OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem(); | ||
1148 | QStringList list = QStringList::split("->", sel->text(1) ); | ||
1149 | if( sel->isDir() ){ | ||
1150 | QString str = QString::fromLatin1("rm -rf ") + sel->directory() +"/" + list[0]; //better safe than sorry | ||
1151 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+list[0], | ||
1152 | tr("Yes"),tr("No"),0,1,1) ) { | ||
1153 | case 0: | ||
1154 | ::system(str.utf8().data() ); | ||
1155 | break; | ||
1156 | } | ||
1157 | } else { | ||
1158 | QFile::remove( list[0] ); | ||
1159 | } | ||
1160 | m_View->takeItem( sel ); | ||
1161 | delete sel; | ||
1162 | } | ||
1163 | void OFileSelector::cdUP() | ||
1164 | { | ||
1165 | QDir dir( m_currentDir ); | ||
1166 | dir.cdUp(); | ||
1167 | if(dir.exists() ){ | ||
1168 | m_currentDir = dir.absPath(); | ||
1169 | reparse(); | ||
1170 | int count = m_location->count(); | ||
1171 | slotInsertLocationPath( m_currentDir, count); | ||
1172 | m_location->setCurrentItem( indexByString( m_location, m_currentDir)); | ||
1173 | //this wont work in all instances | ||
1174 | // FIXME | ||
1175 | } | ||
1176 | } | ||
1177 | void OFileSelector::slotHome() | ||
1178 | { | ||
1179 | cd(QDir::homeDirPath() ); | ||
1180 | } | ||
1181 | void OFileSelector::slotDoc() | ||
1182 | { | ||
1183 | cd(QPEApplication::documentDir() ); | ||
1184 | } | ||
1185 | void OFileSelector::slotNavigate( ) | ||
1186 | { | ||
1187 | |||
1188 | } | ||
1189 | // fill the View with life | ||
1190 | void OFileSelector::reparse() | ||
1191 | { | ||
1192 | if( m_selector == NORMAL ) | ||
1193 | return; | ||
1194 | if( m_selector == EXTENDED || m_selector == EXTENDED_ALL ) | ||
1195 | m_View->clear(); | ||
1196 | else // custom view | ||
1197 | ; // currentView()->clear(); | ||
1198 | if( m_shChooser) | ||
1199 | qWarning("reparse %s", m_mimeCheck->currentText().latin1() ); | ||
1200 | |||
1201 | QString currentMimeType; | ||
1202 | // let's update the mimetype | ||
1203 | if( m_autoMime ){ | ||
1204 | m_mimetypes.clear(); | ||
1205 | // ok we can change mimetype so we need to be able to give a selection | ||
1206 | if( m_shChooser ) { | ||
1207 | currentMimeType = m_mimeCheck->currentText(); | ||
1208 | m_mimeCheck->clear(); | ||
1209 | |||
1210 | // let's find possible mimetypes | ||
1211 | QDir dir( m_currentDir ); | ||
1212 | if( dir.exists() ){ | ||
1213 | dir.setFilter( QDir::Files | QDir::Readable ); | ||
1214 | dir.setSorting( QDir::Size ); | ||
1215 | const QFileInfoList *list = dir.entryInfoList(); | ||
1216 | QFileInfoListIterator it( *list ); | ||
1217 | QFileInfo *fi; | ||
1218 | while( (fi=it.current() ) ) { | ||
1219 | if( fi->extension() == QString::fromLatin1("desktop") ){ | ||
1220 | ++it; | ||
1221 | continue; | ||
1222 | } | ||
1223 | MimeType type( fi->absFilePath() ); | ||
1224 | if( !m_mimetypes.contains( type.id() ) ){ | ||
1225 | //qWarning("Type %s", type.id().latin1() ); | ||
1226 | m_mimetypes.insert( type.id(), type.id() ); | ||
1227 | } | ||
1228 | |||
1229 | ++it; | ||
1230 | } | ||
1231 | // add them to the chooser | ||
1232 | updateMimeCheck(); | ||
1233 | m_mimeCheck->setCurrentItem( indexByString( m_mimeCheck, currentMimeType ) ); | ||
1234 | currentMimeType = m_mimeCheck->currentText(); | ||
1235 | } | ||
1236 | } | ||
1237 | }else { // no autoMime | ||
1238 | // let the mimetype be set from out side the m_mimeCheck FEATURE | ||
1239 | |||
1240 | if( m_shChooser ){ | ||
1241 | currentMimeType = m_mimeCheck->currentText(); | ||
1242 | // updateMimeCheck(); | ||
1243 | } | ||
1244 | } | ||
1245 | // now we got our mimetypes we can add the files | ||
1246 | |||
1247 | QDir dir( m_currentDir ); | ||
1248 | |||
1249 | if( dir.exists() ){ | ||
1250 | int sort; | ||
1251 | if ( m_case ) | ||
1252 | sort = (QDir::IgnoreCase | QDir::Name | QDir::DirsFirst | QDir::Reversed); | ||
1253 | else | ||
1254 | sort = (QDir::Name | QDir::DirsFirst | QDir::Reversed); | ||
1255 | dir.setSorting( sort ); | ||
1256 | |||
1257 | int filter; | ||
1258 | if( m_selector == EXTENDED_ALL /*|| m_selector ==CUSTOM_ALL */ ){ | ||
1259 | filter = QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All; | ||
1260 | }else | ||
1261 | filter = QDir::Files | QDir::Dirs | QDir::All; | ||
1262 | dir.setFilter( filter ); | ||
1263 | |||
1264 | // now go through all files | ||
1265 | const QFileInfoList *list = dir.entryInfoList(); | ||
1266 | QFileInfoListIterator it( *list ); | ||
1267 | QFileInfo *fi; | ||
1268 | while( (fi=it.current() ) ){ | ||
1269 | //qWarning("True and only" ); | ||
1270 | if( fi->fileName() == QString::fromLatin1("..") || fi->fileName() == QString::fromLatin1(".") ){ | ||
1271 | //qWarning(".. or ." ); | ||
1272 | ++it; | ||
1273 | continue; | ||
1274 | } | ||
1275 | if( fi->isSymLink() ){ | ||
1276 | QString file = fi->dirPath( true ) + "/" + fi->readLink(); | ||
1277 | for( int i = 0; i<=4; i++) { // 5 tries to prevent dos | ||
1278 | QFileInfo info( file ); | ||
1279 | if( !info.exists() ){ | ||
1280 | addSymlink( currentMimeType, fi, TRUE ); | ||
1281 | break; | ||
1282 | }else if( info.isDir() ){ | ||
1283 | addDir( currentMimeType, fi, TRUE ); | ||
1284 | break; | ||
1285 | }else if( info.isFile() ){ | ||
1286 | addFile( currentMimeType, fi, TRUE ); | ||
1287 | break; | ||
1288 | }else if( info.isSymLink() ){ | ||
1289 | file = info.dirPath(true ) + "/" + info.readLink() ; | ||
1290 | break; | ||
1291 | }else if( i == 4){ | ||
1292 | addSymlink( currentMimeType, fi ); | ||
1293 | } | ||
1294 | } // off for loop | ||
1295 | }else if( fi->isDir() ){ | ||
1296 | addDir( currentMimeType, fi ); | ||
1297 | }else if( fi->isFile() ){ | ||
1298 | addFile( currentMimeType, fi ); | ||
1299 | } | ||
1300 | //qWarning( "%s", fi->fileName().latin1() ); | ||
1301 | ++it; | ||
1302 | } // of while loop | ||
1303 | } // if ( dir.exists() ) | ||
1304 | m_View->sort(); | ||
1305 | if( m_shTool ){ | ||
1306 | m_location->insertItem( m_currentDir ); | ||
1307 | |||
1308 | } | ||
1309 | // reenable painting and updates | ||
1310 | } | ||
diff --git a/libopie/ofileselector.cpp b/libopie/ofileselector.cpp new file mode 100644 index 0000000..577e916 --- a/dev/null +++ b/libopie/ofileselector.cpp | |||
@@ -0,0 +1,856 @@ | |||
1 | #include <qcombobox.h> | ||
2 | #include <qdir.h> | ||
3 | #include <qhbox.h> | ||
4 | #include <qheader.h> | ||
5 | #include <qlabel.h> | ||
6 | #include <qlayout.h> | ||
7 | #include <qlineedit.h> | ||
8 | #include <qlistview.h> | ||
9 | #include <qpopupmenu.h> | ||
10 | #include <qwidgetstack.h> | ||
11 | #include <qregexp.h> | ||
12 | #include <qobjectlist.h> | ||
13 | |||
14 | /* hacky but we need to get FileSelector::filter */ | ||
15 | #define private public | ||
16 | #include <qpe/fileselector.h> | ||
17 | #undef private | ||
18 | |||
19 | #include <qpe/qpeapplication.h> | ||
20 | #include <qpe/mimetype.h> | ||
21 | #include <qpe/resource.h> | ||
22 | #include <qpe/storage.h> | ||
23 | |||
24 | #include "ofileselector_p.h" | ||
25 | #include "ofileselector.h" | ||
26 | |||
27 | |||
28 | |||
29 | OFileViewInterface::OFileViewInterface( OFileSelector* selector ) | ||
30 | : m_selector( selector ) { | ||
31 | } | ||
32 | OFileViewInterface::~OFileViewInterface() { | ||
33 | } | ||
34 | QString OFileViewInterface::name()const{ | ||
35 | return m_name; | ||
36 | } | ||
37 | void OFileViewInterface::setName( const QString& name ) { | ||
38 | m_name = name; | ||
39 | } | ||
40 | OFileSelector* OFileViewInterface::selector()const { | ||
41 | return m_selector; | ||
42 | } | ||
43 | DocLnk OFileViewInterface::selectedDocument()const { | ||
44 | return DocLnk( selectedName() ); | ||
45 | } | ||
46 | bool OFileViewInterface::showNew()const { | ||
47 | return selector()->showNew(); | ||
48 | } | ||
49 | bool OFileViewInterface::showClose()const { | ||
50 | return selector()->showClose(); | ||
51 | } | ||
52 | MimeTypes OFileViewInterface::mimeTypes()const { | ||
53 | return selector()->mimeTypes(); | ||
54 | } | ||
55 | QStringList OFileViewInterface::currentMimeType()const { | ||
56 | return selector()->currentMimeType(); | ||
57 | } | ||
58 | void OFileViewInterface::activate( const QString& ) { | ||
59 | // not implemented here | ||
60 | } | ||
61 | void OFileViewInterface::ok() { | ||
62 | emit selector()->ok(); | ||
63 | } | ||
64 | void OFileViewInterface::cancel() { | ||
65 | emit selector()->cancel(); | ||
66 | } | ||
67 | void OFileViewInterface::closeMe() { | ||
68 | emit selector()->closeMe(); | ||
69 | } | ||
70 | void OFileViewInterface::fileSelected( const QString& str) { | ||
71 | emit selector()->fileSelected( str); | ||
72 | } | ||
73 | void OFileViewInterface::fileSelected( const DocLnk& lnk) { | ||
74 | emit selector()->fileSelected( lnk ); | ||
75 | } | ||
76 | void OFileViewInterface::setCurrentFileName( const QString& str ) { | ||
77 | selector()->m_lneEdit->setText( str ); | ||
78 | } | ||
79 | QString OFileViewInterface::currentFileName()const{ | ||
80 | return selector()->m_lneEdit->text(); | ||
81 | } | ||
82 | QString OFileViewInterface::startDirectory()const{ | ||
83 | return selector()->m_startDir; | ||
84 | } | ||
85 | |||
86 | |||
87 | ODocumentFileView::ODocumentFileView( OFileSelector* selector ) | ||
88 | : OFileViewInterface( selector ) { | ||
89 | m_selector = 0; | ||
90 | setName( QObject::tr("Documents") ); | ||
91 | } | ||
92 | ODocumentFileView::~ODocumentFileView() { | ||
93 | |||
94 | } | ||
95 | QString ODocumentFileView::selectedName()const { | ||
96 | if (!m_selector) | ||
97 | return QString::null; | ||
98 | |||
99 | return m_selector->selectedDocument().file(); | ||
100 | } | ||
101 | QString ODocumentFileView::selectedPath()const { | ||
102 | return QPEApplication::documentDir(); | ||
103 | } | ||
104 | QString ODocumentFileView::directory()const { | ||
105 | return selectedPath(); | ||
106 | } | ||
107 | void ODocumentFileView::reread() { | ||
108 | if (!m_selector) | ||
109 | return; | ||
110 | |||
111 | m_selector->setNewVisible( showNew() ); | ||
112 | m_selector->setCloseVisible( showClose() ); | ||
113 | m_selector->filter = currentMimeType().join(";"); | ||
114 | m_selector->reread(); | ||
115 | } | ||
116 | int ODocumentFileView::fileCount()const { | ||
117 | if (!m_selector) | ||
118 | return -1; | ||
119 | |||
120 | return m_selector->fileCount(); | ||
121 | } | ||
122 | DocLnk ODocumentFileView::selectedDocument()const { | ||
123 | if (!m_selector) | ||
124 | return DocLnk(); | ||
125 | |||
126 | return m_selector->selectedDocument(); | ||
127 | } | ||
128 | QWidget* ODocumentFileView::widget( QWidget* parent ) { | ||
129 | if (!m_selector ) { | ||
130 | m_selector = new FileSelector(currentMimeType().join(";"), parent, "fileselector", showNew(), showClose() ); | ||
131 | QObject::connect(m_selector, SIGNAL(fileSelected( const DocLnk& ) ), | ||
132 | selector(), SLOT(slotDocLnkBridge(const DocLnk&) ) ); | ||
133 | QObject::connect(m_selector, SIGNAL(closeMe() ), | ||
134 | selector(), SIGNAL(closeMe() ) ); | ||
135 | QObject::connect(m_selector, SIGNAL(newSelected(const DocLnk& ) ), | ||
136 | selector(), SIGNAL(newSelected(const DocLnk& ) ) ); | ||
137 | } | ||
138 | |||
139 | return m_selector; | ||
140 | } | ||
141 | |||
142 | /* | ||
143 | * This is the file system view used | ||
144 | * we use a QListView + QListViewItems for it | ||
145 | */ | ||
146 | |||
147 | OFileSelectorItem::OFileSelectorItem( QListView* view, const QPixmap& pixmap, | ||
148 | const QString& path, const QString& date, | ||
149 | const QString& size, const QString& dir, | ||
150 | bool isLocked, bool isDir ) | ||
151 | : QListViewItem( view ) | ||
152 | { | ||
153 | setPixmap(0, pixmap ); | ||
154 | setText(1, path ); | ||
155 | setText(2, size ); | ||
156 | setText(3, date ); | ||
157 | m_isDir = isDir; | ||
158 | m_dir = dir; | ||
159 | m_locked = isLocked; | ||
160 | } | ||
161 | OFileSelectorItem::~OFileSelectorItem() { | ||
162 | |||
163 | } | ||
164 | bool OFileSelectorItem::isLocked()const { | ||
165 | return m_locked; | ||
166 | } | ||
167 | QString OFileSelectorItem::directory()const { | ||
168 | return m_dir; | ||
169 | } | ||
170 | bool OFileSelectorItem::isDir()const { | ||
171 | return m_isDir; | ||
172 | } | ||
173 | QString OFileSelectorItem::path()const { | ||
174 | return text( 1 ); | ||
175 | } | ||
176 | QString OFileSelectorItem::key( int id, bool )const { | ||
177 | QString ke; | ||
178 | if( id == 0 || id == 1 ){ // name | ||
179 | if( m_isDir ){ | ||
180 | ke.append("0" ); | ||
181 | ke.append( text(1) ); | ||
182 | }else{ | ||
183 | ke.append("1" ); | ||
184 | ke.append( text(1) ); | ||
185 | } | ||
186 | return ke; | ||
187 | }else | ||
188 | return text( id ); | ||
189 | |||
190 | } | ||
191 | |||
192 | OFileViewFileListView::OFileViewFileListView( QWidget* parent, const QString& startDir, | ||
193 | OFileSelector* sel) | ||
194 | : QWidget( parent ), m_sel( sel ) { | ||
195 | m_all = false; | ||
196 | QVBoxLayout* lay = new QVBoxLayout( this ); | ||
197 | m_currentDir = startDir; | ||
198 | |||
199 | /* | ||
200 | * now we add a special bar | ||
201 | * One Button For Up | ||
202 | * Home | ||
203 | * Doc | ||
204 | * And a dropdown menu with FileSystems | ||
205 | * FUTURE: one to change dir with lineedit | ||
206 | * Bookmarks | ||
207 | * Create Dir | ||
208 | */ | ||
209 | QHBox* box = new QHBox(this ); | ||
210 | box->setBackgroundMode( PaletteButton ); | ||
211 | box->setSpacing( 0 ); | ||
212 | |||
213 | QToolButton *btn = new QToolButton( box ); | ||
214 | btn->setIconSet( Resource::loadIconSet("up") ); | ||
215 | connect(btn, SIGNAL(clicked() ), | ||
216 | this, SLOT( cdUP() ) ); | ||
217 | |||
218 | btn = new QToolButton( box ); | ||
219 | btn->setIconSet( Resource::loadIconSet("home") ); | ||
220 | connect(btn, SIGNAL(clicked() ), | ||
221 | this, SLOT( cdHome() ) ); | ||
222 | |||
223 | btn = new QToolButton( box ); | ||
224 | btn->setIconSet( Resource::loadIconSet("DocsIcon") ); | ||
225 | connect(btn, SIGNAL(clicked() ), | ||
226 | this, SLOT(cdDoc() ) ); | ||
227 | |||
228 | m_btnNew = new QToolButton( box ); | ||
229 | m_btnNew->setIconSet( Resource::loadIconSet("new") ); | ||
230 | connect(m_btnNew, SIGNAL(clicked() ), | ||
231 | this, SLOT(slotNew() ) ); | ||
232 | |||
233 | |||
234 | m_btnClose = new QToolButton( box ); | ||
235 | m_btnClose->setIconSet( Resource::loadIconSet("close") ); | ||
236 | connect(m_btnClose, SIGNAL(clicked() ), | ||
237 | selector(), SIGNAL(closeMe() ) ); | ||
238 | |||
239 | btn = new QToolButton( box ); | ||
240 | btn->setIconSet( Resource::loadIconSet("cardmon/pcmcia") ); | ||
241 | |||
242 | /* let's fill device parts */ | ||
243 | QPopupMenu* pop = new QPopupMenu(this); | ||
244 | connect(pop, SIGNAL( activated(int) ), | ||
245 | this, SLOT(slotFSActivated(int) ) ); | ||
246 | |||
247 | StorageInfo storage; | ||
248 | const QList<FileSystem> &fs = storage.fileSystems(); | ||
249 | QListIterator<FileSystem> it(fs); | ||
250 | for ( ; it.current(); ++it ) { | ||
251 | const QString disk = (*it)->name(); | ||
252 | const QString path = (*it)->path(); | ||
253 | m_dev.insert( disk, path ); | ||
254 | pop->insertItem( disk ); | ||
255 | } | ||
256 | m_fsPop = pop; | ||
257 | |||
258 | |||
259 | btn->setPopup( pop ); | ||
260 | |||
261 | lay->addWidget( box ); | ||
262 | |||
263 | m_view = new QListView( this ); | ||
264 | |||
265 | m_view->installEventFilter(this); | ||
266 | |||
267 | QPEApplication::setStylusOperation( m_view->viewport(), | ||
268 | QPEApplication::RightOnHold); | ||
269 | m_view->addColumn(" " ); | ||
270 | m_view->addColumn(tr("Name"), 135 ); | ||
271 | m_view->addColumn(tr("Size"), -1 ); | ||
272 | m_view->addColumn(tr("Date"), 60 ); | ||
273 | m_view->addColumn(tr("Mime Type"), -1 ); | ||
274 | |||
275 | |||
276 | m_view->setSorting( 1 ); | ||
277 | m_view->setAllColumnsShowFocus( TRUE ); | ||
278 | |||
279 | lay->addWidget( m_view, 1000 ); | ||
280 | connectSlots(); | ||
281 | } | ||
282 | OFileViewFileListView::~OFileViewFileListView() { | ||
283 | } | ||
284 | void OFileViewFileListView::slotNew() { | ||
285 | DocLnk lnk; | ||
286 | emit selector()->newSelected( lnk ); | ||
287 | } | ||
288 | OFileSelectorItem* OFileViewFileListView::currentItem()const{ | ||
289 | QListViewItem* item = m_view->currentItem(); | ||
290 | if (!item ) | ||
291 | return 0l; | ||
292 | |||
293 | return static_cast<OFileSelectorItem*>(item); | ||
294 | } | ||
295 | void OFileViewFileListView::reread( bool all ) { | ||
296 | m_view->clear(); | ||
297 | |||
298 | if (selector()->showClose() ) | ||
299 | m_btnClose->show(); | ||
300 | else | ||
301 | m_btnClose->hide(); | ||
302 | |||
303 | if (selector()->showNew() ) | ||
304 | m_btnNew->show(); | ||
305 | else | ||
306 | m_btnNew->hide(); | ||
307 | |||
308 | m_mimes = selector()->currentMimeType(); | ||
309 | m_all = all; | ||
310 | |||
311 | QDir dir( m_currentDir ); | ||
312 | if (!dir.exists() ) | ||
313 | return; | ||
314 | |||
315 | dir.setSorting( QDir::Name | QDir::DirsFirst | QDir::Reversed ); | ||
316 | int filter; | ||
317 | if (m_all ) | ||
318 | filter = QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All; | ||
319 | else | ||
320 | filter = QDir::Files | QDir::Dirs | QDir::All; | ||
321 | dir.setFilter( filter ); | ||
322 | |||
323 | // now go through all files | ||
324 | const QFileInfoList *list = dir.entryInfoList(); | ||
325 | if (!list) { | ||
326 | cdUP(); | ||
327 | return; | ||
328 | } | ||
329 | QFileInfoListIterator it( *list ); | ||
330 | QFileInfo *fi; | ||
331 | while( (fi=it.current() ) ){ | ||
332 | if( fi->fileName() == QString::fromLatin1("..") || fi->fileName() == QString::fromLatin1(".") ){ | ||
333 | ++it; | ||
334 | continue; | ||
335 | } | ||
336 | |||
337 | /* | ||
338 | * It is a symlink we try to resolve it now but don't let us attack by DOS | ||
339 | * | ||
340 | */ | ||
341 | if( fi->isSymLink() ){ | ||
342 | QString file = fi->dirPath( true ) + "/" + fi->readLink(); | ||
343 | for( int i = 0; i<=4; i++) { // 5 tries to prevent dos | ||
344 | QFileInfo info( file ); | ||
345 | if( !info.exists() ){ | ||
346 | addSymlink( fi, TRUE ); | ||
347 | break; | ||
348 | }else if( info.isDir() ){ | ||
349 | addDir( fi, TRUE ); | ||
350 | break; | ||
351 | }else if( info.isFile() ){ | ||
352 | addFile( fi, TRUE ); | ||
353 | break; | ||
354 | }else if( info.isSymLink() ){ | ||
355 | file = info.dirPath(true ) + "/" + info.readLink() ; | ||
356 | break; | ||
357 | }else if( i == 4){ // couldn't resolve symlink add it as symlink | ||
358 | addSymlink( fi ); | ||
359 | } | ||
360 | } // off for loop for symlink resolving | ||
361 | }else if( fi->isDir() ) | ||
362 | addDir( fi ); | ||
363 | else if( fi->isFile() ) | ||
364 | addFile( fi ); | ||
365 | |||
366 | ++it; | ||
367 | } // of while loop | ||
368 | m_view->sort(); | ||
369 | |||
370 | } | ||
371 | int OFileViewFileListView::fileCount()const{ | ||
372 | return m_view->childCount(); | ||
373 | } | ||
374 | QString OFileViewFileListView::currentDir()const{ | ||
375 | return m_currentDir; | ||
376 | } | ||
377 | OFileSelector* OFileViewFileListView::selector() { | ||
378 | return m_sel; | ||
379 | } | ||
380 | |||
381 | bool OFileViewFileListView::eventFilter (QObject *o, QEvent *e) { | ||
382 | if ( e->type() == QEvent::KeyPress ) { | ||
383 | QKeyEvent *k = (QKeyEvent *)e; | ||
384 | if ( (k->key()==Key_Enter) || (k->key()==Key_Return)) { | ||
385 | slotClicked( Qt::LeftButton,m_view->currentItem(),QPoint(0,0),0); | ||
386 | return true; | ||
387 | } | ||
388 | } | ||
389 | return false; | ||
390 | } | ||
391 | |||
392 | |||
393 | void OFileViewFileListView::connectSlots() { | ||
394 | connect(m_view, SIGNAL(clicked(QListViewItem*) ), | ||
395 | this, SLOT(slotCurrentChanged(QListViewItem*) ) ); | ||
396 | connect(m_view, SIGNAL(mouseButtonClicked(int, QListViewItem*, const QPoint&, int ) ), | ||
397 | this, SLOT(slotClicked(int, QListViewItem*, const QPoint&, int ) ) ); | ||
398 | } | ||
399 | void OFileViewFileListView::slotCurrentChanged( QListViewItem* item) { | ||
400 | if (!item) | ||
401 | return; | ||
402 | #if 0 | ||
403 | |||
404 | OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item); | ||
405 | |||
406 | if (!sel->isDir() ) { | ||
407 | selector()->m_lneEdit->setText( sel->text(1) ); | ||
408 | // if in fileselector mode we will emit selected | ||
409 | if ( selector()->mode() == OFileSelector::FileSelector ) { | ||
410 | qWarning("slot Current Changed"); | ||
411 | QStringList str = QStringList::split("->", sel->text(1) ); | ||
412 | QString path = sel->directory() + "/" + str[0].stripWhiteSpace(); | ||
413 | emit selector()->fileSelected( path ); | ||
414 | DocLnk lnk( path ); | ||
415 | emit selector()->fileSelected( lnk ); | ||
416 | } | ||
417 | } | ||
418 | #endif | ||
419 | } | ||
420 | void OFileViewFileListView::slotClicked(int button , QListViewItem* item, const QPoint&, int ) { | ||
421 | if (!item || ( button != Qt::LeftButton) ) | ||
422 | return; | ||
423 | |||
424 | OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item); | ||
425 | if (!sel->isLocked() ) { | ||
426 | QStringList str = QStringList::split("->", sel->text(1) ); | ||
427 | if (sel->isDir() ) { | ||
428 | m_currentDir = sel->directory() + "/" + str[0].stripWhiteSpace(); | ||
429 | emit selector()->dirSelected( m_currentDir ); | ||
430 | reread( m_all ); | ||
431 | }else { // file | ||
432 | qWarning("slot Clicked"); | ||
433 | selector()->m_lneEdit->setText( str[0].stripWhiteSpace() ); | ||
434 | QString path = sel->directory() + "/" + str[0].stripWhiteSpace(); | ||
435 | emit selector()->fileSelected( path ); | ||
436 | DocLnk lnk( path ); | ||
437 | emit selector()->fileSelected( lnk ); | ||
438 | } | ||
439 | } // not locked | ||
440 | } | ||
441 | void OFileViewFileListView::addFile( QFileInfo* info, bool symlink ) { | ||
442 | MimeType type( info->absFilePath() ); | ||
443 | if (!compliesMime( type.id() ) ) | ||
444 | return; | ||
445 | |||
446 | QPixmap pix = type.pixmap(); | ||
447 | QString dir, name; bool locked; | ||
448 | if ( pix.isNull() ) { | ||
449 | QWMatrix matrix; | ||
450 | QPixmap pixer(Resource::loadPixmap("UnknownDocument") ); | ||
451 | matrix.scale( .4, .4 ); | ||
452 | pix = pixer.xForm( matrix ); | ||
453 | } | ||
454 | dir = info->dirPath( true ); | ||
455 | locked = false; | ||
456 | if ( symlink ) | ||
457 | name = info->fileName() + " -> " + info->dirPath() + "/" + info->readLink(); | ||
458 | else{ | ||
459 | name = info->fileName(); | ||
460 | if ( ( (selector()->mode() == OFileSelector::Open)&& !info->isReadable() ) || | ||
461 | ( (selector()->mode() == OFileSelector::Save)&& !info->isWritable() ) ) { | ||
462 | locked = true; pix = Resource::loadPixmap("locked"); | ||
463 | } | ||
464 | } | ||
465 | (void)new OFileSelectorItem( m_view, pix, name, | ||
466 | info->lastModified().toString(), QString::number( info->size() ), | ||
467 | dir, locked ); | ||
468 | } | ||
469 | void OFileViewFileListView::addDir( QFileInfo* info, bool symlink ) { | ||
470 | bool locked = false; QString name; QPixmap pix; | ||
471 | |||
472 | if ( ( ( selector()->mode() == OFileSelector::Open ) && !info->isReadable() ) || | ||
473 | ( ( selector()->mode() == OFileSelector::Save ) && !info->isWritable() ) ) { | ||
474 | locked = true; | ||
475 | if ( symlink ) | ||
476 | pix = Resource::loadPixmap( "opie/symlink" ); | ||
477 | else | ||
478 | pix = Resource::loadPixmap( "lockedfolder" ); | ||
479 | }else | ||
480 | pix = symlink ? Resource::loadPixmap( "opie/symlink") : Resource::loadPixmap("folder"); | ||
481 | |||
482 | name = symlink ? info->fileName() + " -> " + info->dirPath(true) + "/" + info->readLink() : | ||
483 | info->fileName(); | ||
484 | |||
485 | (void)new OFileSelectorItem( m_view, pix, name, | ||
486 | info->lastModified().toString(), | ||
487 | QString::number( info->size() ), | ||
488 | info->dirPath( true ), locked, true ); | ||
489 | |||
490 | |||
491 | } | ||
492 | void OFileViewFileListView::addSymlink( QFileInfo* , bool ) { | ||
493 | |||
494 | } | ||
495 | void OFileViewFileListView::cdUP() { | ||
496 | QDir dir( m_currentDir ); | ||
497 | dir.cdUp(); | ||
498 | |||
499 | if (!dir.exists() ) | ||
500 | m_currentDir = "/"; | ||
501 | else | ||
502 | m_currentDir = dir.absPath(); | ||
503 | |||
504 | emit selector()->dirSelected( m_currentDir ); | ||
505 | reread( m_all ); | ||
506 | } | ||
507 | void OFileViewFileListView::cdHome() { | ||
508 | m_currentDir = QDir::homeDirPath(); | ||
509 | emit selector()->dirSelected( m_currentDir ); | ||
510 | reread( m_all ); | ||
511 | } | ||
512 | void OFileViewFileListView::cdDoc() { | ||
513 | m_currentDir = QPEApplication::documentDir(); | ||
514 | emit selector()->dirSelected( m_currentDir ); | ||
515 | reread( m_all ); | ||
516 | } | ||
517 | void OFileViewFileListView::changeDir( const QString& dir ) { | ||
518 | m_currentDir = dir; | ||
519 | emit selector()->dirSelected( m_currentDir ); | ||
520 | reread( m_all ); | ||
521 | } | ||
522 | void OFileViewFileListView::slotFSActivated( int id ) { | ||
523 | changeDir ( m_dev[m_fsPop->text(id)] ); | ||
524 | } | ||
525 | |||
526 | /* check if the mimetype in mime | ||
527 | * complies with the one which is current | ||
528 | */ | ||
529 | /* | ||
530 | * We've the mimetype of the file | ||
531 | * We need to get the stringlist of the current mimetype | ||
532 | * | ||
533 | * mime = image@slashjpeg | ||
534 | * QStringList = 'image@slash*' | ||
535 | * or QStringList = image/jpeg;image/png;application/x-ogg | ||
536 | * or QStringList = application/x-ogg;image@slash*; | ||
537 | * with all these mime filters it should get acceptes | ||
538 | * to do so we need to look if mime is contained inside | ||
539 | * the stringlist | ||
540 | * if it's contained return true | ||
541 | * if not ( I'm no RegExp expert at all ) we'll look if a '@slash*' | ||
542 | * is contained in the mimefilter and then we will | ||
543 | * look if both are equal until the '/' | ||
544 | */ | ||
545 | bool OFileViewFileListView::compliesMime( const QString& str) { | ||
546 | if (str.isEmpty() || m_mimes.isEmpty() || str.stripWhiteSpace().isEmpty() ) | ||
547 | return true; | ||
548 | |||
549 | for (QStringList::Iterator it = m_mimes.begin(); it != m_mimes.end(); ++it ) { | ||
550 | QRegExp reg( (*it) ); | ||
551 | reg.setWildcard( true ); | ||
552 | if ( str.find( reg ) != -1 ) | ||
553 | return true; | ||
554 | |||
555 | } | ||
556 | return false; | ||
557 | } | ||
558 | /* | ||
559 | * The listView giving access to the file system! | ||
560 | */ | ||
561 | class OFileViewFileSystem : public OFileViewInterface { | ||
562 | public: | ||
563 | OFileViewFileSystem( OFileSelector* ); | ||
564 | ~OFileViewFileSystem(); | ||
565 | |||
566 | QString selectedName() const; | ||
567 | QString selectedPath() const; | ||
568 | |||
569 | QString directory()const; | ||
570 | void reread(); | ||
571 | int fileCount()const; | ||
572 | |||
573 | QWidget* widget( QWidget* parent ); | ||
574 | void activate( const QString& ); | ||
575 | private: | ||
576 | OFileViewFileListView* m_view; | ||
577 | bool m_all : 1; | ||
578 | }; | ||
579 | OFileViewFileSystem::OFileViewFileSystem( OFileSelector* sel) | ||
580 | : OFileViewInterface( sel ) { | ||
581 | m_view = 0; | ||
582 | m_all = false; | ||
583 | } | ||
584 | OFileViewFileSystem::~OFileViewFileSystem() { | ||
585 | } | ||
586 | QString OFileViewFileSystem::selectedName()const{ | ||
587 | if (!m_view ) | ||
588 | return QString::null; | ||
589 | |||
590 | QString cFN=currentFileName(); | ||
591 | if (cFN.startsWith("/")) return cFN; | ||
592 | return m_view->currentDir() + "/" + cFN; | ||
593 | } | ||
594 | QString OFileViewFileSystem::selectedPath()const{ | ||
595 | return QString::null; | ||
596 | } | ||
597 | QString OFileViewFileSystem::directory()const{ | ||
598 | if (!m_view) | ||
599 | return QString::null; | ||
600 | |||
601 | OFileSelectorItem* item = m_view->currentItem(); | ||
602 | if (!item ) | ||
603 | return QString::null; | ||
604 | |||
605 | return QDir(item->directory() ).absPath(); | ||
606 | } | ||
607 | void OFileViewFileSystem::reread() { | ||
608 | if (!m_view) | ||
609 | return; | ||
610 | |||
611 | m_view->reread( m_all ); | ||
612 | } | ||
613 | int OFileViewFileSystem::fileCount()const{ | ||
614 | if (!m_view ) | ||
615 | return -1; | ||
616 | return m_view->fileCount(); | ||
617 | } | ||
618 | QWidget* OFileViewFileSystem::widget( QWidget* parent ) { | ||
619 | if (!m_view ) { | ||
620 | m_view = new OFileViewFileListView( parent, startDirectory(), selector() ); | ||
621 | } | ||
622 | return m_view; | ||
623 | } | ||
624 | void OFileViewFileSystem::activate( const QString& str) { | ||
625 | m_all = (str != QObject::tr("Files") ); | ||
626 | |||
627 | |||
628 | } | ||
629 | |||
630 | /* Selector */ | ||
631 | OFileSelector::OFileSelector( QWidget* parent, int mode, int sel, | ||
632 | const QString& dirName, const QString& fileName, | ||
633 | const MimeTypes& mimetypes, | ||
634 | bool showNew, bool showClose) | ||
635 | : QWidget( parent, "OFileSelector" ) | ||
636 | { | ||
637 | m_current = 0; | ||
638 | m_shNew = showNew; | ||
639 | m_shClose = showClose; | ||
640 | m_mimeType = mimetypes; | ||
641 | m_startDir = dirName; | ||
642 | |||
643 | m_mode = mode; | ||
644 | m_selector = sel; | ||
645 | |||
646 | initUI(); | ||
647 | m_lneEdit->setText( fileName ); | ||
648 | initMime(); | ||
649 | initViews(); | ||
650 | |||
651 | QString str; | ||
652 | switch ( m_selector ) { | ||
653 | default: | ||
654 | case Normal: | ||
655 | str = QObject::tr("Documents"); | ||
656 | m_cmbView->setCurrentItem( 0 ); | ||
657 | break; | ||
658 | case Extended: | ||
659 | str = QObject::tr("Files"); | ||
660 | m_cmbView->setCurrentItem( 1 ); | ||
661 | break; | ||
662 | case ExtendedAll: | ||
663 | str = QObject::tr("All Files"); | ||
664 | m_cmbView->setCurrentItem( 2 ); | ||
665 | break; | ||
666 | } | ||
667 | slotViewChange( str ); | ||
668 | |||
669 | } | ||
670 | OFileSelector::OFileSelector( const QString& mimeFilter, QWidget* parent, const char* name, | ||
671 | bool showNew, bool showClose ) | ||
672 | : QWidget( parent, name ) | ||
673 | { | ||
674 | m_current = 0; | ||
675 | m_shNew = showNew; | ||
676 | m_shClose = showClose; | ||
677 | m_startDir = QPEApplication::documentDir(); | ||
678 | |||
679 | if (!mimeFilter.isEmpty() ) | ||
680 | m_mimeType.insert(mimeFilter, QStringList::split(";", mimeFilter ) ); | ||
681 | |||
682 | m_mode = OFileSelector::FileSelector; | ||
683 | m_selector = OFileSelector::Normal; | ||
684 | |||
685 | initUI(); | ||
686 | initMime(); | ||
687 | initViews(); | ||
688 | m_cmbView->setCurrentItem( 0 ); | ||
689 | slotViewChange( QObject::tr("Documents") ); | ||
690 | } | ||
691 | /* | ||
692 | * INIT UI will set up the basic GUI | ||
693 | * Layout: Simple VBoxLayout | ||
694 | * On top a WidgetStack containing the Views... | ||
695 | * - List View | ||
696 | * - Document View | ||
697 | * Below we will have a Label + LineEdit | ||
698 | * Below we will have two ComoBoxes one for choosing the view one for | ||
699 | * choosing the mimetype | ||
700 | */ | ||
701 | void OFileSelector::initUI() { | ||
702 | QVBoxLayout* lay = new QVBoxLayout( this ); | ||
703 | |||
704 | m_stack = new QWidgetStack( this ); | ||
705 | lay->addWidget( m_stack, 1000 ); | ||
706 | |||
707 | m_nameBox = new QHBox( this ); | ||
708 | (void)new QLabel( tr("Name:"), m_nameBox ); | ||
709 | m_lneEdit = new QLineEdit( m_nameBox ); | ||
710 | m_lneEdit ->installEventFilter(this); | ||
711 | lay->addWidget( m_nameBox ); | ||
712 | |||
713 | m_cmbBox = new QHBox( this ); | ||
714 | m_cmbView = new QComboBox( m_cmbBox ); | ||
715 | m_cmbMime = new QComboBox( m_cmbBox ); | ||
716 | lay->addWidget( m_cmbBox ); | ||
717 | } | ||
718 | |||
719 | /* | ||
720 | * This will make sure that the return key in the name edit causes dialogs to close | ||
721 | */ | ||
722 | |||
723 | bool OFileSelector::eventFilter (QObject *o, QEvent *e) { | ||
724 | if ( e->type() == QEvent::KeyPress ) { | ||
725 | QKeyEvent *k = (QKeyEvent *)e; | ||
726 | if ( (k->key()==Key_Enter) || (k->key()==Key_Return)) { | ||
727 | emit ok(); | ||
728 | return true; | ||
729 | } | ||
730 | } | ||
731 | return false; | ||
732 | } | ||
733 | |||
734 | /* | ||
735 | * This will insert the MimeTypes into the Combo Box | ||
736 | * And also connect the changed signal | ||
737 | * | ||
738 | * AutoMimeTyping is disabled for now. It used to reparse a dir and then set available mimetypes | ||
739 | */ | ||
740 | void OFileSelector::initMime() { | ||
741 | MimeTypes::Iterator it; | ||
742 | for ( it = m_mimeType.begin(); it != m_mimeType.end(); ++it ) { | ||
743 | m_cmbMime->insertItem( it.key() ); | ||
744 | } | ||
745 | m_cmbMime->setCurrentItem( 0 ); | ||
746 | |||
747 | connect( m_cmbMime, SIGNAL(activated(int) ), | ||
748 | this, SLOT(slotMimeTypeChanged() ) ); | ||
749 | |||
750 | } | ||
751 | void OFileSelector::initViews() { | ||
752 | m_cmbView->insertItem( QObject::tr("Documents") ); | ||
753 | m_cmbView->insertItem( QObject::tr("Files") ); | ||
754 | m_cmbView->insertItem( QObject::tr("All Files") ); | ||
755 | connect(m_cmbView, SIGNAL(activated( const QString& ) ), | ||
756 | this, SLOT(slotViewChange( const QString& ) ) ); | ||
757 | |||
758 | |||
759 | m_views.insert( QObject::tr("Documents"), new ODocumentFileView(this) ); | ||
760 | |||
761 | /* see above why add both */ | ||
762 | OFileViewInterface* in = new OFileViewFileSystem( this ); | ||
763 | m_views.insert( QObject::tr("Files"), in ); | ||
764 | m_views.insert( QObject::tr("All Files"), in ); | ||
765 | } | ||
766 | OFileSelector::~OFileSelector() { | ||
767 | |||
768 | } | ||
769 | const DocLnk* OFileSelector::selected() { | ||
770 | DocLnk* lnk = new DocLnk( currentView()->selectedDocument() ); | ||
771 | return lnk; | ||
772 | } | ||
773 | QString OFileSelector::selectedName()const{ | ||
774 | return currentView()->selectedName(); | ||
775 | } | ||
776 | QString OFileSelector::selectedPath()const { | ||
777 | return currentView()->selectedPath(); | ||
778 | } | ||
779 | QString OFileSelector::directory()const { | ||
780 | return currentView()->directory(); | ||
781 | } | ||
782 | DocLnk OFileSelector::selectedDocument()const { | ||
783 | return currentView()->selectedDocument(); | ||
784 | } | ||
785 | int OFileSelector::fileCount()const { | ||
786 | return currentView()->fileCount(); | ||
787 | } | ||
788 | void OFileSelector::reread() { | ||
789 | return currentView()->reread(); | ||
790 | } | ||
791 | OFileViewInterface* OFileSelector::currentView()const{ | ||
792 | return m_current; | ||
793 | } | ||
794 | bool OFileSelector::showNew()const { | ||
795 | return m_shNew; | ||
796 | } | ||
797 | bool OFileSelector::showClose()const { | ||
798 | return m_shClose; | ||
799 | } | ||
800 | MimeTypes OFileSelector::mimeTypes()const { | ||
801 | return m_mimeType; | ||
802 | } | ||
803 | int OFileSelector::mode()const{ | ||
804 | return m_mode; | ||
805 | } | ||
806 | int OFileSelector::selector()const{ | ||
807 | return m_selector; | ||
808 | } | ||
809 | QStringList OFileSelector::currentMimeType()const { | ||
810 | return m_mimeType[m_cmbMime->currentText()]; | ||
811 | } | ||
812 | void OFileSelector::slotMimeTypeChanged() { | ||
813 | reread(); | ||
814 | } | ||
815 | void OFileSelector::slotDocLnkBridge( const DocLnk& lnk) { | ||
816 | m_lneEdit->setText( lnk.name() ); | ||
817 | emit fileSelected( lnk ); | ||
818 | emit fileSelected( lnk.name() ); | ||
819 | } | ||
820 | void OFileSelector::slotFileBridge( const QString& str) { | ||
821 | DocLnk lnk( str ); | ||
822 | emit fileSelected( lnk ); | ||
823 | } | ||
824 | void OFileSelector::slotViewChange( const QString& view ) { | ||
825 | OFileViewInterface* interface = m_views[view]; | ||
826 | if (!interface) | ||
827 | return; | ||
828 | |||
829 | interface->activate( view ); | ||
830 | if (m_current) | ||
831 | m_stack->removeWidget( m_current->widget( m_stack ) ); | ||
832 | |||
833 | static int id = 1; | ||
834 | |||
835 | m_stack->addWidget( interface->widget(m_stack), id ); | ||
836 | m_stack->raiseWidget( id ); | ||
837 | |||
838 | interface->reread(); | ||
839 | m_current = interface; | ||
840 | |||
841 | id++; | ||
842 | } | ||
843 | void OFileSelector::setNewVisible( bool b ) { | ||
844 | m_shNew = b; | ||
845 | currentView()->reread(); | ||
846 | } | ||
847 | void OFileSelector::setCloseVisible( bool b ) { | ||
848 | m_shClose = b; | ||
849 | currentView()->reread(); | ||
850 | } | ||
851 | void OFileSelector::setNameVisible( bool b ) { | ||
852 | if ( b ) | ||
853 | m_nameBox->show(); | ||
854 | else | ||
855 | m_nameBox->hide(); | ||
856 | } | ||
diff --git a/libopie/ofileselector.h b/libopie/ofileselector.h index d06aa0a..bdb3e56 100644 --- a/libopie/ofileselector.h +++ b/libopie/ofileselector.h | |||
@@ -1,314 +1,150 @@ | |||
1 | /* | 1 | /* |
2 | This is based on code and ideas of | 2 | This is based on code and ideas of |
3 | L. J. Potter ljp@llornkcor.com | 3 | L. J. Potter ljp@llornkcor.com |
4 | Thanks a lot | 4 | Thanks a lot |
5 | 5 | ||
6 | 6 | ||
7 | =. This file is part of the OPIE Project | 7 | =. This file is part of the OPIE Project |
8 | .=l. Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> | 8 | .=l. Copyright (c) 2002,2003 Holger Freyther <zecke@handhelds.org> |
9 | .>+-= | 9 | .>+-= |
10 | _;:, .> :=|. This library is free software; you can | 10 | _;:, .> :=|. This library is free software; you can |
11 | .> <`_, > . <= redistribute it and/or modify it under | 11 | .> <`_, > . <= redistribute it and/or modify it under |
12 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 12 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
13 | .="- .-=="i, .._ License as published by the Free Software | 13 | .="- .-=="i, .._ License as published by the Free Software |
14 | - . .-<_> .<> Foundation; either version 2 of the License, | 14 | - . .-<_> .<> Foundation; either version 2 of the License, |
15 | ._= =} : or (at your option) any later version. | 15 | ._= =} : or (at your option) any later version. |
16 | .%`+i> _;_. | 16 | .%`+i> _;_. |
17 | .i_,=:_. -<s. This library is distributed in the hope that | 17 | .i_,=:_. -<s. This library is distributed in the hope that |
18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
19 | : .. .:, . . . without even the implied warranty of | 19 | : .. .:, . . . without even the implied warranty of |
20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
22 | ..}^=.= = ; Library General Public License for more | 22 | ..}^=.= = ; Library General Public License for more |
23 | ++= -. .` .: details. | 23 | ++= -. .` .: details. |
24 | : = ...= . :.=- | 24 | : = ...= . :.=- |
25 | -. .:....=;==+<; You should have received a copy of the GNU | 25 | -. .:....=;==+<; You should have received a copy of the GNU |
26 | -_. . . )=. = Library General Public License along with | 26 | -_. . . )=. = Library General Public License along with |
27 | -- :-=` this library; see the file COPYING.LIB. | 27 | -- :-=` this library; see the file COPYING.LIB. |
28 | If not, write to the Free Software Foundation, | 28 | If not, write to the Free Software Foundation, |
29 | Inc., 59 Temple Place - Suite 330, | 29 | Inc., 59 Temple Place - Suite 330, |
30 | Boston, MA 02111-1307, USA. | 30 | Boston, MA 02111-1307, USA. |
31 | 31 | ||
32 | */ | 32 | */ |
33 | 33 | ||
34 | #ifndef opiefileselector_h | ||
35 | #define opiefileselector_h | ||
36 | 34 | ||
35 | #ifndef OPIE_OFILESELECTOR_FOO_H | ||
36 | #define OPIE_OFILESELECTOR_FOO_H | ||
37 | |||
38 | #include <qlist.h> | ||
37 | #include <qwidget.h> | 39 | #include <qwidget.h> |
38 | #include <qstring.h> | ||
39 | #include <qpixmap.h> | ||
40 | #include <qstringlist.h> | ||
41 | #include <qmap.h> | 40 | #include <qmap.h> |
42 | #include <qvaluelist.h> | 41 | #include <qvaluelist.h> |
42 | #include <qstringlist.h> | ||
43 | 43 | ||
44 | #include <qpe/applnk.h> | 44 | #include <qpe/applnk.h> |
45 | #include <qlistview.h> | ||
46 | 45 | ||
46 | typedef QMap<QString, QStringList> MimeTypes; | ||
47 | 47 | ||
48 | class DocLnk; | 48 | class OFileViewInterface; |
49 | class QCheckBox; | 49 | class OFileViewFileListView; |
50 | class QComboBox; | ||
51 | class QPushButton; | ||
52 | class FileSelector; | ||
53 | class QGridLayout; | ||
54 | class QLineEdit; | 50 | class QLineEdit; |
55 | class QLabel; | 51 | class QComboBox; |
56 | class QWidgetStack; | 52 | class QWidgetStack; |
57 | class QHBoxLayout; | ||
58 | class QVBoxLayout; | ||
59 | class QPopupMenu; | ||
60 | class QFileInfo; | ||
61 | class QHBox; | 53 | class QHBox; |
62 | // | ||
63 | |||
64 | typedef QMap< QString, QStringList> MimeTypes; | ||
65 | |||
66 | /** | ||
67 | * This is OPIEs FileDialog Widget. You can use it | ||
68 | * as a dropin replacement of the fileselector and | ||
69 | * or use any of the new features. | ||
70 | * This is also a complete FileSave and FileLoad widget | ||
71 | * If you look for a Dialog check OFileDialog | ||
72 | * | ||
73 | * NOTE THAT the API will change to be more extendable! | ||
74 | */ | ||
75 | class OFileSelector : public QWidget { | 54 | class OFileSelector : public QWidget { |
76 | Q_OBJECT | 55 | Q_OBJECT |
77 | public: | 56 | friend class OFileViewInterface; |
78 | /** | 57 | friend class OFileViewFileListView; |
79 | * The mode of the file selector | 58 | public: |
80 | * Either open, save, fileselector or dir browsing mode | 59 | enum Mode { Open=1, Save=2, FileSelector=4, OPEN=1, SAVE=2, FILESELECTOR=4 }; |
81 | * | 60 | // enum OldMode { OPEN=1, SAVE=2, FILESELECTOR = 4 }; |
82 | */ | 61 | enum Selector { Normal = 0, Extended=1, ExtendedAll =2, Default=3, NORMAL=0,EXTENDED=1, EXTENDED_ALL =2, DEFAULT=3 }; |
83 | enum Mode {OPEN=1, SAVE=2, FILESELECTOR=4, DIR=8 }; | 62 | // enum OldSelector { NORMAL = 0, EXTENDED =1, EXTENDED_ALL = 2}; |
84 | 63 | ||
85 | /** | 64 | OFileSelector(QWidget* parent, int mode, int selector, |
86 | * Selector. Either NORMAL for the one shipped with | 65 | const QString& dirName, |
87 | * libqpe or EXTENDED. for the EXTENDED | 66 | const QString& fileName, |
88 | * EXTENDED_ALL also shows 'hidden' files | 67 | const MimeTypes& mimetypes = MimeTypes(), |
89 | */ | 68 | bool newVisible = FALSE, bool closeVisible = FALSE ); |
90 | enum Selector{NORMAL=0, EXTENDED = 1, EXTENDED_ALL =2 }; | 69 | |
91 | 70 | OFileSelector(const QString& mimeFilter, QWidget* parent, | |
92 | /** | 71 | const char* name = 0, bool newVisible = TRUE, bool closeVisible = FALSE ); |
93 | * This is reserved for futrue views | 72 | ~OFileSelector(); |
94 | */ | 73 | |
95 | enum View { DIRS = 1, FILES = 2, TREE = 4, ICON = 8 }; | 74 | const DocLnk* selected(); |
96 | 75 | ||
97 | /** | 76 | QString selectedName()const; |
98 | * A c'tor which should be used for advanced mode | 77 | QString selectedPath()const; |
99 | * @param wid the parent | 78 | QString directory()const; |
100 | * @param mode the Mode of the Selector | 79 | |
101 | * @param selector the current View of the Selector | 80 | DocLnk selectedDocument()const; |
102 | * @param dirName in which dir to start | 81 | |
103 | * @param fileName a proposed filename | 82 | int fileCount()const; |
104 | * @param mimetypes A list of mimetypes \ | 83 | void reread(); |
105 | * QString is for a identifier name like "Text files" | 84 | |
106 | * the coresponding QStringList is used for the mimetypes | 85 | int mode()const; |
107 | * if empty it'll fill the list of mimetypes depending | 86 | int selector()const; |
108 | * on the content of the current directory | 87 | |
109 | */ | 88 | |
110 | 89 | void setNewVisible( bool b ); | |
111 | OFileSelector(QWidget *wid, int mode, int selector, | 90 | void setCloseVisible( bool b ); |
112 | const QString &dirName, | 91 | void setNameVisible( bool b ); |
113 | const QString &fileName = QString::null, | 92 | |
114 | const MimeTypes &mimetypes = MimeTypes() ); | 93 | signals: |
115 | 94 | void dirSelected( const QString& ); | |
116 | 95 | void fileSelected( const DocLnk& ); | |
117 | /** | 96 | void fileSelected( const QString& ); |
118 | * This is a QPE compatible c'tor | 97 | void newSelected( const DocLnk& ); |
119 | */ | 98 | void closeMe(); |
120 | OFileSelector(const QString &mimeFilter, QWidget *parent, | 99 | void ok(); |
121 | const char *name, bool newVisible = TRUE, | 100 | void cancel(); |
122 | bool closeVisible = FALSE ); | 101 | |
123 | 102 | /* used by the ViewInterface */ | |
124 | ~OFileSelector(); | 103 | private: |
125 | 104 | bool showNew()const; | |
126 | // currently only for the FILESELECTOR Mode | 105 | bool showClose()const; |
127 | /** | 106 | MimeTypes mimeTypes()const; |
128 | */ | 107 | QStringList currentMimeType()const; |
129 | void setNewVisible( bool /*b*/ ); | 108 | |
130 | void setCloseVisible(bool /*b*/ ); | 109 | private: |
131 | 110 | /* inits the Widgets */ | |
132 | // end file selector mode | 111 | void initUI(); |
133 | // deprecated | 112 | /* inits the MimeType ComboBox content + connects signals and slots */ |
134 | void reread(); | 113 | void initMime(); |
135 | // make sure not to leak please | 114 | /* init the Views :) */ |
136 | const DocLnk *selected(); | 115 | void initViews(); |
137 | // end deprecated | 116 | |
138 | 117 | private: | |
139 | bool isToolbarVisible() const { return m_shTool; }; | 118 | QLineEdit* m_lneEdit; // the LineEdit for the Name |
140 | bool isPermissionBarVisible() const { return m_shPerm; }; | 119 | QComboBox *m_cmbView, *m_cmbMime; // two ComboBoxes to select the View and MimeType |
141 | bool isLineEditVisible()const { return m_shLne; }; | 120 | QWidgetStack* m_stack; // our widget stack which will contain the views |
142 | bool isChooserVisible( )const { return m_shChooser; }; | 121 | OFileViewInterface* currentView()const; // returns the currentView |
143 | bool isYesCancelVisible()const { return m_shYesNo; }; | 122 | OFileViewInterface* m_current; // here is the view saved |
144 | void setYesCancelVisible( bool show ); | 123 | bool m_shNew : 1; // should we show New? |
145 | void setToolbarVisible( bool show ); | 124 | bool m_shClose : 1; // should we show Close? |
146 | void setPermissionBarVisible( bool show ); | 125 | MimeTypes m_mimeType; // list of mimetypes |
147 | void setLineEditVisible(bool show) ; | 126 | |
148 | void setChooserVisible( bool chooser ); | 127 | QMap<QString, OFileViewInterface*> m_views; // QString translated view name + ViewInterface Ptr |
149 | 128 | QHBox* m_nameBox; // the LineEdit + Label is hold here | |
150 | QCheckBox* permissionCheckbox(); | 129 | QHBox* m_cmbBox; // this holds the two combo boxes |
151 | bool setPermission() const; | 130 | |
152 | void setPermissionChecked( bool check ); | 131 | QString m_startDir; |
153 | 132 | int m_mode; | |
154 | void setMode( int ); | 133 | int m_selector; |
155 | 134 | ||
156 | bool showDirs()const { return m_dir; } | 135 | struct Data; // used for future versions |
157 | void setShowDirs(bool ); | 136 | Data *d; |
158 | |||
159 | const QListView* listView() { return m_View; }; | ||
160 | |||
161 | bool isCaseSensetive()const { return m_case; } | ||
162 | void setCaseSensetive(bool caSe ); | ||
163 | |||
164 | bool showFiles()const { return m_files; }; | ||
165 | void setShowFiles(bool ); | ||
166 | bool cd(const QString &path ); | ||
167 | 137 | ||
138 | private slots: | ||
139 | void slotMimeTypeChanged(); | ||
168 | 140 | ||
169 | int mode()const { return m_mode; }; | 141 | /* will set the text of the lineedit and emit a fileChanged signal */ |
170 | int selector()const { return m_selector; }; | 142 | void slotDocLnkBridge( const DocLnk& ); |
171 | void setSelector( int ); | 143 | void slotFileBridge( const QString& ); |
172 | 144 | void slotViewChange( const QString& ); | |
173 | bool showPopup()const { return m_showPopup; }; | ||
174 | void setShowPopup( bool pop ) { m_showPopup = pop; }; | ||
175 | void setPopupMenu( QPopupMenu * ); | ||
176 | |||
177 | // void updateLay(); | ||
178 | |||
179 | void reparse(); // re reads the dir | ||
180 | |||
181 | QString selectedName( )const; | ||
182 | QStringList selectedNames()const; | ||
183 | |||
184 | QString selectedPath() const; | ||
185 | QStringList selectedPaths() const; | ||
186 | |||
187 | QString directory()const; | ||
188 | int fileCount() const; | ||
189 | |||
190 | /* the user needs to delete it */ | ||
191 | DocLnk selectedDocument()const; | ||
192 | /* the user needs to delete it */ | ||
193 | QValueList<DocLnk> selectedDocuments()const; | ||
194 | |||
195 | signals: | ||
196 | void fileSelected( const DocLnk & ); | ||
197 | void fileSelected( const QString & ); | ||
198 | void dirSelected(const QString &dir ); | ||
199 | void closeMe(); | ||
200 | void ok(); | ||
201 | void cancel(); | ||
202 | void contextMenu(); | ||
203 | |||
204 | private slots: | ||
205 | void slotTest() { qWarning("slotTest" ); setLineEditVisible(false ); }; | ||
206 | void slotOk(); | ||
207 | void slotCancel(); | ||
208 | void slotViewCheck(const QString & ); | ||
209 | void slotMimeCheck(const QString & ); | ||
210 | void slotLocationActivated(const QString & ); | ||
211 | void slotInsertLocationPath(const QString &, int); | ||
212 | void locationComboChanged(); | ||
213 | |||
214 | private: | ||
215 | void init(); | ||
216 | void updateMimes(); | ||
217 | |||
218 | protected: | ||
219 | |||
220 | private: | ||
221 | int m_mode, m_selector; | ||
222 | QComboBox *m_location, *m_mimeCheck, *m_viewCheck; | ||
223 | QPushButton *m_homeButton, *m_docButton, *m_hideButton, *m_ok, *m_cancel; | ||
224 | QPushButton *m_reread, *m_up, *m_new, *m_close; | ||
225 | QListView *m_View; | ||
226 | QCheckBox *m_checkPerm; | ||
227 | QWidget *m_pseudo; | ||
228 | QVBoxLayout *m_pseudoLayout; | ||
229 | |||
230 | QString m_currentDir; | ||
231 | QString m_name; | ||
232 | // QStringList m_mimetypes; | ||
233 | QMap<QString, QStringList> m_mimetypes; | ||
234 | |||
235 | FileSelector *m_select; | ||
236 | QWidgetStack *m_stack; | ||
237 | QVBoxLayout *m_lay; | ||
238 | QGridLayout *m_Oselector; | ||
239 | |||
240 | QHBox *m_boxToolbar; | ||
241 | QHBox *m_boxOk; // (no layout anymore) wait | ||
242 | QHBox *m_boxName; // (no Layout anymore) wait | ||
243 | QHBox *m_boxView; | ||
244 | |||
245 | QPopupMenu *m_custom; | ||
246 | |||
247 | QLineEdit *m_edit; | ||
248 | QLabel *m_fnLabel; | ||
249 | |||
250 | bool m_shClose : 1; | ||
251 | bool m_shNew : 1; | ||
252 | bool m_shTool : 1; | ||
253 | bool m_shPerm : 1; | ||
254 | bool m_shLne : 1; | ||
255 | bool m_shChooser : 1; | ||
256 | bool m_shYesNo : 1; | ||
257 | bool m_boCheckPerm : 1; | ||
258 | bool m_autoMime : 1; | ||
259 | bool m_case : 1; | ||
260 | bool m_dir : 1; | ||
261 | bool m_files : 1; | ||
262 | bool m_showPopup : 1; | ||
263 | |||
264 | void initVars(); | ||
265 | virtual void addFile(const QString &mime, QFileInfo *info, bool symlink = FALSE ); | ||
266 | virtual void addDir( const QString &mime, QFileInfo *info , bool symlink = FALSE ); | ||
267 | virtual void addSymlink(const QString &, QFileInfo *, bool = FALSE ){}; | ||
268 | void delItems(); | ||
269 | void initializeName(); | ||
270 | void initializeYes(); | ||
271 | void initializeChooser(); | ||
272 | void initializeListView(); | ||
273 | void initializePerm(); | ||
274 | void initPics(); | ||
275 | bool compliesMime(const QString &path, | ||
276 | const QString &mime); | ||
277 | bool compliesMime(const QString& mime ); | ||
278 | /** | ||
279 | * Updates the QComboBox with the current mimetypes | ||
280 | */ | ||
281 | void updateMimeCheck(); | ||
282 | 145 | ||
283 | /** | 146 | bool eventFilter (QObject *o, QEvent *e); |
284 | * Returns the current mimetype | ||
285 | */ | ||
286 | QString currentMimeType()const; | ||
287 | class OFileSelectorPrivate; | ||
288 | OFileSelectorPrivate *d; | ||
289 | static QMap<QString,QPixmap> *m_pixmaps; | ||
290 | 147 | ||
291 | private slots: | ||
292 | void slotFileSelected(const QString & ); // not really meant to be a slot | ||
293 | void slotFileBridgeSelected( const DocLnk & ); | ||
294 | virtual void slotSelectionChanged(); | ||
295 | virtual void slotCurrentChanged(QListViewItem* ); | ||
296 | virtual void slotClicked( int, QListViewItem *item, const QPoint &, int); | ||
297 | virtual void slotRightButton(int, QListViewItem *, const QPoint &, int ); | ||
298 | virtual void slotContextMenu( QListViewItem *item); | ||
299 | // listview above | ||
300 | // popup below | ||
301 | virtual void slotChangedDir(); | ||
302 | virtual void slotOpen(); | ||
303 | virtual void slotRescan(); | ||
304 | virtual void slotRename(); | ||
305 | virtual void slotDelete(); | ||
306 | virtual void cdUP(); | ||
307 | virtual void slotHome(); | ||
308 | virtual void slotDoc(); | ||
309 | virtual void slotNavigate( ); | ||
310 | }; | 148 | }; |
311 | 149 | ||
312 | |||
313 | #endif | 150 | #endif |
314 | |||
diff --git a/libopie/ofileselector_p.h b/libopie/ofileselector_p.h new file mode 100644 index 0000000..7fd0c50 --- a/dev/null +++ b/libopie/ofileselector_p.h | |||
@@ -0,0 +1,151 @@ | |||
1 | #ifndef OPIE_OFILE_SELECTOR_PRIVATE_H | ||
2 | #define OPIE_OFILE_SELECTOR_PRIVATE_H | ||
3 | |||
4 | #include <qmap.h> | ||
5 | #include <qstringlist.h> | ||
6 | #include <qwidget.h> | ||
7 | #include <qlistview.h> | ||
8 | |||
9 | #include <qpe/applnk.h> | ||
10 | #include <qpe/fileselector.h> | ||
11 | |||
12 | |||
13 | /* | ||
14 | * How to avoid having really two different objects | ||
15 | * for Extended and ExtendedAll | ||
16 | * The only difference is the Lister... | ||
17 | * a) static object? | ||
18 | * b) leave some object inside the OFileSelector which can be used? | ||
19 | * c) when switching views tell which view we want o have.. internally we can switch then | ||
20 | * | ||
21 | * I'll take c) -zecke | ||
22 | */ | ||
23 | |||
24 | |||
25 | /* the View Interface */ | ||
26 | class OFileSelector; | ||
27 | typedef QMap<QString, QStringList> MimeTypes; | ||
28 | class QFileInfo; | ||
29 | class QToolButton; | ||
30 | class OFileViewInterface { | ||
31 | public: | ||
32 | OFileViewInterface( OFileSelector* selector ); | ||
33 | virtual ~OFileViewInterface(); | ||
34 | virtual QString selectedName()const = 0; | ||
35 | virtual QString selectedPath()const = 0; | ||
36 | virtual QString directory()const = 0; | ||
37 | virtual void reread() = 0; | ||
38 | virtual int fileCount()const = 0; | ||
39 | virtual DocLnk selectedDocument()const; | ||
40 | virtual QWidget* widget( QWidget* parent) = 0; | ||
41 | virtual void activate( const QString& ); | ||
42 | QString name()const; | ||
43 | protected: | ||
44 | OFileSelector* selector()const; | ||
45 | void setName( const QString& ); | ||
46 | bool showNew()const; | ||
47 | bool showClose()const; | ||
48 | MimeTypes mimeTypes()const; | ||
49 | QStringList currentMimeType()const; | ||
50 | QString startDirectory()const; | ||
51 | protected: | ||
52 | void ok(); | ||
53 | void cancel(); | ||
54 | void closeMe(); | ||
55 | void fileSelected( const QString& ); | ||
56 | void fileSelected( const DocLnk& ); | ||
57 | void setCurrentFileName( const QString& ); | ||
58 | QString currentFileName()const; | ||
59 | |||
60 | private: | ||
61 | QString m_name; | ||
62 | OFileSelector* m_selector; | ||
63 | }; | ||
64 | |||
65 | |||
66 | /* THE Document View hosting a FileSelector*/ | ||
67 | class ODocumentFileView : public OFileViewInterface { | ||
68 | public: | ||
69 | ODocumentFileView( OFileSelector* selector ); | ||
70 | ~ODocumentFileView(); | ||
71 | |||
72 | QString selectedName() const; | ||
73 | QString selectedPath() const; | ||
74 | |||
75 | QString directory() const; | ||
76 | void reread(); | ||
77 | int fileCount()const; | ||
78 | DocLnk selectedDocument()const; | ||
79 | |||
80 | QWidget* widget( QWidget* parent ); | ||
81 | |||
82 | private: | ||
83 | mutable FileSelector* m_selector; | ||
84 | |||
85 | }; | ||
86 | |||
87 | class OFileSelectorItem : public QListViewItem { | ||
88 | public: | ||
89 | OFileSelectorItem( QListView* view, const QPixmap& pixmap, | ||
90 | const QString& path, const QString& date, | ||
91 | const QString& size, const QString& mDir, | ||
92 | bool isLocked = false, bool isDir = false ); | ||
93 | ~OFileSelectorItem(); | ||
94 | bool isLocked()const; | ||
95 | bool isDir()const; | ||
96 | QString directory()const; | ||
97 | QString path()const; | ||
98 | QString key(int id, bool )const; | ||
99 | |||
100 | private: | ||
101 | bool m_locked : 1; | ||
102 | bool m_isDir : 1; | ||
103 | QString m_dir; | ||
104 | }; | ||
105 | |||
106 | class OFileViewFileListView : public QWidget { | ||
107 | Q_OBJECT | ||
108 | public: | ||
109 | OFileViewFileListView( QWidget* parent, const QString& dir, OFileSelector* selector ); | ||
110 | ~OFileViewFileListView(); | ||
111 | |||
112 | OFileSelectorItem* currentItem()const; | ||
113 | void reread( bool all = false ); | ||
114 | int fileCount()const; | ||
115 | QString currentDir()const; | ||
116 | protected: | ||
117 | bool eventFilter (QObject *o, QEvent *e); | ||
118 | private slots: | ||
119 | void slotNew(); // will emit newSelected | ||
120 | void cdUP(); | ||
121 | void cdHome(); | ||
122 | void cdDoc(); | ||
123 | void changeDir( const QString& ); | ||
124 | void slotCurrentChanged( QListViewItem* ); | ||
125 | void slotClicked(int, QListViewItem*, const QPoint&, int ); | ||
126 | void slotFSActivated(int); | ||
127 | |||
128 | protected: | ||
129 | |||
130 | OFileSelector* selector(); | ||
131 | |||
132 | private: | ||
133 | QMap<QString, QString> m_dev; | ||
134 | bool m_all : 1; | ||
135 | OFileSelector* m_sel; | ||
136 | QPopupMenu* m_fsPop; | ||
137 | bool compliesMime( const QString& ); | ||
138 | QStringList m_mimes; // used in compy mime | ||
139 | QString m_currentDir; | ||
140 | QToolButton *m_btnNew, *m_btnClose; | ||
141 | void connectSlots(); | ||
142 | void addFile( QFileInfo* info, bool symlink = FALSE ); | ||
143 | void addDir ( QFileInfo* info, bool symlink = FALSE ); | ||
144 | void addSymlink( QFileInfo* info, bool = FALSE ); | ||
145 | |||
146 | |||
147 | private: | ||
148 | QListView* m_view; | ||
149 | }; | ||
150 | |||
151 | #endif | ||
diff --git a/libopie/orecurrancewidget.cpp b/libopie/orecurrancewidget.cpp index 471249d..be8ec30 100644 --- a/libopie/orecurrancewidget.cpp +++ b/libopie/orecurrancewidget.cpp | |||
@@ -1,612 +1,634 @@ | |||
1 | #include <qapplication.h> | 1 | #include <qapplication.h> |
2 | #include <qlabel.h> | 2 | #include <qlabel.h> |
3 | #include <qpopupmenu.h> | 3 | #include <qpopupmenu.h> |
4 | #include <qspinbox.h> | 4 | #include <qspinbox.h> |
5 | 5 | ||
6 | #include <qpe/timestring.h> | 6 | #include <qpe/timestring.h> |
7 | 7 | ||
8 | #include "orecurrancewidget.h" | 8 | #include "orecurrancewidget.h" |
9 | 9 | ||
10 | // Global Templates for use in setting up the repeat label... | 10 | // Global Templates for use in setting up the repeat label... |
11 | const QString strDayTemplate = QObject::tr("Every"); | 11 | // the problem is these strings get initialized before QPEApplication can install the translator -zecke |
12 | const QString strYearTemplate = QObject::tr("%1 %2 every "); | 12 | namespace { |
13 | const QString strMonthDateTemplate = QObject::tr("The %1 every "); | 13 | QString strDayTemplate; |
14 | const QString strMonthDayTemplate = QObject::tr("The %1 %1 of every"); | 14 | QString strYearTemplate; |
15 | const QString strWeekTemplate = QObject::tr("Every "); | 15 | QString strMonthDateTemplate; |
16 | const QString dayLabel[] = { QObject::tr("Monday"), | 16 | QString strMonthDayTemplate; |
17 | QObject::tr("Tuesday"), | 17 | QString strWeekTemplate; |
18 | QObject::tr("Wednesday"), | 18 | QString dayLabel[7]; |
19 | QObject::tr("Thursday"), | 19 | } |
20 | QObject::tr("Friday"), | ||
21 | QObject::tr("Saturday"), | ||
22 | QObject::tr("Sunday") }; | ||
23 | 20 | ||
21 | /* | ||
22 | * static linkage to not polute the symbol table... | ||
23 | * The problem is that const and static linkage are resolved prior to installing a translator | ||
24 | * leading to that the above strings are translted but to the original we delay the init of these strings... | ||
25 | * -zecke | ||
26 | */ | ||
27 | static void fillStrings() { | ||
28 | strDayTemplate = QObject::tr("Every"); | ||
29 | strYearTemplate = QObject::tr("%1 %2 every "); | ||
30 | strMonthDateTemplate = QObject::tr("The %1 every "); | ||
31 | strMonthDayTemplate = QObject::tr("The %1 %2 of every"); | ||
32 | strWeekTemplate = QObject::tr("Every "); | ||
33 | dayLabel[0] = QObject::tr("Monday"); | ||
34 | dayLabel[1] = QObject::tr("Tuesday"); | ||
35 | dayLabel[2] = QObject::tr("Wednesday"); | ||
36 | dayLabel[3] = QObject::tr("Thursday"); | ||
37 | dayLabel[4] = QObject::tr("Friday"); | ||
38 | dayLabel[5] = QObject::tr("Saturday"); | ||
39 | dayLabel[6] = QObject::tr("Sunday"); | ||
40 | } | ||
24 | 41 | ||
25 | static QString numberPlacing( int x );// return the proper word format for | 42 | static QString numberPlacing( int x );// return the proper word format for |
26 | // x (1st, 2nd, etc) | 43 | // x (1st, 2nd, etc) |
27 | static int week( const QDate &dt ); // what week in the month is dt? | 44 | static int week( const QDate &dt ); // what week in the month is dt? |
28 | 45 | ||
29 | /** | 46 | /** |
30 | * Constructs the Widget | 47 | * Constructs the Widget |
31 | * @param startOnMonday Does the week start on monday | 48 | * @param startOnMonday Does the week start on monday |
32 | * @param newStart The start date of the recurrence | 49 | * @param newStart The start date of the recurrence |
33 | * @param parent The parent widget | 50 | * @param parent The parent widget |
34 | * @param name the name of object | 51 | * @param name the name of object |
35 | * @param modal if the dialog should be modal | 52 | * @param modal if the dialog should be modal |
36 | * @param fl Additional window flags | 53 | * @param fl Additional window flags |
37 | */ | 54 | */ |
38 | ORecurranceWidget::ORecurranceWidget( bool startOnMonday, | 55 | ORecurranceWidget::ORecurranceWidget( bool startOnMonday, |
39 | const QDate& newStart, | 56 | const QDate& newStart, |
40 | QWidget* parent, | 57 | QWidget* parent, |
41 | const char* name, | 58 | const char* name, |
42 | bool modal, | 59 | bool modal, |
43 | WFlags fl ) | 60 | WFlags fl ) |
44 | : ORecurranceBase( parent, name, modal, fl ), | 61 | : ORecurranceBase( parent, name, modal, fl ), |
45 | start( newStart ), | 62 | start( newStart ), |
46 | currInterval( None ), | 63 | currInterval( None ), |
47 | startWeekOnMonday( startOnMonday ) | 64 | startWeekOnMonday( startOnMonday ) |
48 | { | 65 | { |
66 | if (strDayTemplate.isEmpty() ) | ||
67 | fillStrings(); | ||
68 | |||
49 | init(); | 69 | init(); |
50 | fraType->setButton( currInterval ); | 70 | fraType->setButton( currInterval ); |
51 | chkNoEnd->setChecked( TRUE ); | 71 | chkNoEnd->setChecked( TRUE ); |
52 | setupNone(); | 72 | setupNone(); |
53 | } | 73 | } |
54 | 74 | ||
55 | /** | 75 | /** |
56 | * Different constructor | 76 | * Different constructor |
57 | * @param startOnMonday Does the week start on monday? | 77 | * @param startOnMonday Does the week start on monday? |
58 | * @param rp Already set ORecur object | 78 | * @param rp Already set ORecur object |
59 | * @param startDate The start date | 79 | * @param startDate The start date |
60 | * @param parent The parent widget | 80 | * @param parent The parent widget |
61 | * @param name The name of the object | 81 | * @param name The name of the object |
62 | * @param modal | 82 | * @param modal |
63 | * @param fl The flags for window | 83 | * @param fl The flags for window |
64 | */ | 84 | */ |
65 | ORecurranceWidget::ORecurranceWidget( bool startOnMonday, | 85 | ORecurranceWidget::ORecurranceWidget( bool startOnMonday, |
66 | const ORecur& rp, const QDate& startDate, | 86 | const ORecur& rp, const QDate& startDate, |
67 | QWidget* parent, const char* name, | 87 | QWidget* parent, const char* name, |
68 | bool modal, WFlags fl) | 88 | bool modal, WFlags fl) |
69 | : ORecurranceBase( parent, name, modal, fl ), | 89 | : ORecurranceBase( parent, name, modal, fl ), |
70 | start( startDate ), | 90 | start( startDate ), |
71 | end( rp.endDate() ), | 91 | end( rp.endDate() ), |
72 | startWeekOnMonday( startOnMonday ) | 92 | startWeekOnMonday( startOnMonday ) |
73 | { | 93 | { |
94 | if (strDayTemplate.isEmpty() ) | ||
95 | fillStrings(); | ||
74 | // do some stuff with the repeat pattern | 96 | // do some stuff with the repeat pattern |
75 | init(); | 97 | init(); |
76 | setRecurrence( rp ); | 98 | setRecurrence( rp ); |
77 | } | 99 | } |
78 | 100 | ||
79 | ORecurranceWidget::~ORecurranceWidget() { | 101 | ORecurranceWidget::~ORecurranceWidget() { |
80 | } | 102 | } |
81 | 103 | ||
82 | /** | 104 | /** |
83 | * set the start date | 105 | * set the start date |
84 | * @param date the new start date | 106 | * @param date the new start date |
85 | */ | 107 | */ |
86 | void ORecurranceWidget::setStartDate( const QDate& date ) { | 108 | void ORecurranceWidget::setStartDate( const QDate& date ) { |
87 | qWarning("ORecurranceWidget::setStartDate"); | ||
88 | setRecurrence( recurrence(), date ); | 109 | setRecurrence( recurrence(), date ); |
89 | } | 110 | } |
90 | /** | 111 | /** |
91 | * set the recurrence | 112 | * set the recurrence |
92 | * @param rp The ORecur object with the new recurrence rules | 113 | * @param rp The ORecur object with the new recurrence rules |
93 | */ | 114 | */ |
94 | void ORecurranceWidget::setRecurrence( const ORecur& rp ) { | 115 | void ORecurranceWidget::setRecurrence( const ORecur& rp ) { |
95 | setRecurrence( rp, start ); | 116 | setRecurrence( rp, start ); |
96 | } | 117 | } |
97 | 118 | ||
98 | /** | 119 | /** |
99 | * overloaded method taking ORecur and a new start date | 120 | * overloaded method taking ORecur and a new start date |
100 | * @param rp Recurrence rule | 121 | * @param rp Recurrence rule |
101 | * @param date The new start date | 122 | * @param date The new start date |
102 | */ | 123 | */ |
103 | void ORecurranceWidget::setRecurrence( const ORecur& rp, const QDate& date ) { | 124 | void ORecurranceWidget::setRecurrence( const ORecur& rp, const QDate& date ) { |
104 | start = date; | 125 | start = date; |
105 | end = rp.endDate(); | 126 | end = rp.endDate(); |
106 | switch ( rp.type() ) { | 127 | switch ( rp.type() ) { |
107 | default: | 128 | default: |
108 | case ORecur::NoRepeat: | 129 | case ORecur::NoRepeat: |
109 | currInterval = None; | 130 | currInterval = None; |
110 | setupNone(); | 131 | setupNone(); |
111 | break; | 132 | break; |
112 | case ORecur::Daily: | 133 | case ORecur::Daily: |
113 | currInterval = Day; | 134 | currInterval = Day; |
114 | setupDaily(); | 135 | setupDaily(); |
115 | break; | 136 | break; |
116 | case ORecur::Weekly: | 137 | case ORecur::Weekly: |
117 | currInterval = Week; | 138 | currInterval = Week; |
118 | setupWeekly(); | 139 | setupWeekly(); |
119 | int day, buttons; | 140 | int day, buttons; |
120 | for ( day = 0x01, buttons = 0; buttons < 7; | 141 | for ( day = 0x01, buttons = 0; buttons < 7; |
121 | day = day << 1, buttons++ ) { | 142 | day = day << 1, buttons++ ) { |
122 | if ( rp.days() & day ) { | 143 | if ( rp.days() & day ) { |
123 | if ( startWeekOnMonday ) | 144 | if ( startWeekOnMonday ) |
124 | fraExtra->setButton( buttons ); | 145 | fraExtra->setButton( buttons ); |
125 | else { | 146 | else { |
126 | if ( buttons == 7 ) | 147 | if ( buttons == 7 ) |
127 | fraExtra->setButton( 0 ); | 148 | fraExtra->setButton( 0 ); |
128 | else | 149 | else |
129 | fraExtra->setButton( buttons + 1 ); | 150 | fraExtra->setButton( buttons + 1 ); |
130 | } | 151 | } |
131 | } | 152 | } |
132 | } | 153 | } |
133 | slotWeekLabel(); | 154 | slotWeekLabel(); |
134 | break; | 155 | break; |
135 | case ORecur::MonthlyDay: | 156 | case ORecur::MonthlyDay: |
136 | currInterval = Month; | 157 | currInterval = Month; |
137 | setupMonthly(); | 158 | setupMonthly(); |
138 | fraExtra->setButton( 0 ); | 159 | fraExtra->setButton( 0 ); |
139 | slotMonthLabel( 0 ); | 160 | slotMonthLabel( 0 ); |
140 | break; | 161 | break; |
141 | case ORecur::MonthlyDate: | 162 | case ORecur::MonthlyDate: |
142 | currInterval = Month; | 163 | currInterval = Month; |
143 | setupMonthly(); | 164 | setupMonthly(); |
144 | fraExtra->setButton( 1 ); | 165 | fraExtra->setButton( 1 ); |
145 | slotMonthLabel( 1 ); | 166 | slotMonthLabel( 1 ); |
146 | break; | 167 | break; |
147 | case ORecur::Yearly: | 168 | case ORecur::Yearly: |
148 | currInterval = Year; | 169 | currInterval = Year; |
149 | setupYearly(); | 170 | setupYearly(); |
150 | break; | 171 | break; |
151 | } | 172 | } |
152 | fraType->setButton( currInterval ); | 173 | fraType->setButton( currInterval ); |
153 | spinFreq->setValue( rp.frequency() ); | 174 | spinFreq->setValue( rp.frequency() ); |
154 | if ( !rp.hasEndDate() ) { | 175 | if ( !rp.hasEndDate() ) { |
155 | cmdEnd->setText( tr("No End Date") ); | 176 | cmdEnd->setText( tr("No End Date") ); |
156 | chkNoEnd->setChecked( TRUE ); | 177 | chkNoEnd->setChecked( TRUE ); |
157 | } else | 178 | } else |
158 | cmdEnd->setText( TimeString::shortDate( end ) ); | 179 | cmdEnd->setText( TimeString::shortDate( end ) ); |
159 | } | 180 | } |
160 | 181 | ||
161 | /** | 182 | /** |
162 | * the user selected recurrence rule. | 183 | * the user selected recurrence rule. |
163 | * @return The recurrence rule. | 184 | * @return The recurrence rule. |
164 | */ | 185 | */ |
165 | ORecur ORecurranceWidget::recurrence()const { | 186 | ORecur ORecurranceWidget::recurrence()const { |
166 | QListIterator<QToolButton> it( listRTypeButtons ); | 187 | QListIterator<QToolButton> it( listRTypeButtons ); |
167 | QListIterator<QToolButton> itExtra( listExtra ); | 188 | QListIterator<QToolButton> itExtra( listExtra ); |
168 | ORecur rpTmp; | 189 | ORecur rpTmp; |
169 | int i; | 190 | int i; |
170 | for ( i = 0; *it; ++it, i++ ) { | 191 | for ( i = 0; *it; ++it, i++ ) { |
171 | if ( (*it)->isOn() ) { | 192 | if ( (*it)->isOn() ) { |
172 | switch ( i ) { | 193 | switch ( i ) { |
173 | case None: | 194 | case None: |
174 | rpTmp.setType( ORecur::NoRepeat ); | 195 | rpTmp.setType( ORecur::NoRepeat ); |
175 | break; | 196 | break; |
176 | case Day: | 197 | case Day: |
177 | rpTmp.setType( ORecur::Daily ); | 198 | rpTmp.setType( ORecur::Daily ); |
178 | break; | 199 | break; |
179 | case Week:{ | 200 | case Week:{ |
180 | rpTmp.setType( ORecur::Weekly ); | 201 | rpTmp.setType( ORecur::Weekly ); |
181 | int day; | 202 | int day; |
182 | int day2 = 0; | 203 | int day2 = 0; |
183 | for ( day = 1; *itExtra; ++itExtra, day = day << 1 ) { | 204 | for ( day = 1; *itExtra; ++itExtra, day = day << 1 ) { |
184 | if ( (*itExtra)->isOn() ) { | 205 | if ( (*itExtra)->isOn() ) { |
185 | if ( startWeekOnMonday ) | 206 | if ( startWeekOnMonday ) |
186 | day2 |= day; | 207 | day2 |= day; |
187 | else { | 208 | else { |
188 | if ( day == 1 ) | 209 | if ( day == 1 ) |
189 | day2 |= Event::SUN; | 210 | day2 |= Event::SUN; |
190 | else | 211 | else |
191 | day2 |= day >> 1; | 212 | day2 |= day >> 1; |
192 | } | 213 | } |
193 | } | 214 | } |
194 | } | 215 | } |
195 | rpTmp.setDays( day2 ); | 216 | rpTmp.setDays( day2 ); |
196 | } | 217 | } |
197 | break; | 218 | break; |
198 | case Month: | 219 | case Month: |
199 | if ( cmdExtra1->isOn() ) | 220 | if ( cmdExtra1->isOn() ) |
200 | rpTmp.setType( ORecur::MonthlyDay ); | 221 | rpTmp.setType( ORecur::MonthlyDay ); |
201 | else if ( cmdExtra2->isOn() ) | 222 | else if ( cmdExtra2->isOn() ) |
202 | rpTmp.setType( ORecur::MonthlyDate ); | 223 | rpTmp.setType( ORecur::MonthlyDate ); |
203 | // figure out the montly day... | 224 | // figure out the montly day... |
204 | rpTmp.setPosition( week( start ) ); | 225 | rpTmp.setPosition( week( start ) ); |
205 | break; | 226 | break; |
206 | case Year: | 227 | case Year: |
207 | rpTmp.setType( ORecur::Yearly ); | 228 | rpTmp.setType( ORecur::Yearly ); |
208 | break; | 229 | break; |
209 | } | 230 | } |
210 | break; // no need to keep looking! | 231 | break; // no need to keep looking! |
211 | } | 232 | } |
212 | } | 233 | } |
213 | rpTmp.setFrequency(spinFreq->value() ); | 234 | rpTmp.setFrequency(spinFreq->value() ); |
214 | rpTmp.setHasEndDate( !chkNoEnd->isChecked() ); | 235 | rpTmp.setHasEndDate( !chkNoEnd->isChecked() ); |
215 | if ( rpTmp.hasEndDate() ) { | 236 | if ( rpTmp.hasEndDate() ) { |
216 | rpTmp.setEndDate( end ); | 237 | rpTmp.setEndDate( end ); |
217 | } | 238 | } |
218 | // timestamp it... | 239 | // timestamp it... |
219 | // rpTmp.setCreateTime( ); current DateTime is already set -zecke | 240 | // rpTmp.setCreateTime( ); current DateTime is already set -zecke |
220 | return rpTmp; | 241 | return rpTmp; |
221 | } | 242 | } |
222 | 243 | ||
223 | /** | 244 | /** |
224 | * Return the end date of the recurrence. This is only | 245 | * Return the end date of the recurrence. This is only |
225 | * valid if the recurrence rule does contain an enddate | 246 | * valid if the recurrence rule does contain an enddate |
226 | */ | 247 | */ |
227 | QDate ORecurranceWidget::endDate()const { | 248 | QDate ORecurranceWidget::endDate()const { |
228 | return end; | 249 | return end; |
229 | } | 250 | } |
230 | void ORecurranceWidget::slotSetRType(int rtype) { | 251 | void ORecurranceWidget::slotSetRType(int rtype) { |
231 | // now call the right function based on the type... | 252 | // now call the right function based on the type... |
232 | currInterval = static_cast<repeatButtons>(rtype); | 253 | currInterval = static_cast<repeatButtons>(rtype); |
233 | switch ( currInterval ) { | 254 | switch ( currInterval ) { |
234 | case None: | 255 | case None: |
235 | setupNone(); | 256 | setupNone(); |
236 | break; | 257 | break; |
237 | case Day: | 258 | case Day: |
238 | setupDaily(); | 259 | setupDaily(); |
239 | break; | 260 | break; |
240 | case Week: | 261 | case Week: |
241 | setupWeekly(); | 262 | setupWeekly(); |
242 | slotWeekLabel(); | 263 | slotWeekLabel(); |
243 | break; | 264 | break; |
244 | case Month: | 265 | case Month: |
245 | setupMonthly(); | 266 | setupMonthly(); |
246 | cmdExtra2->setOn( TRUE ); | 267 | cmdExtra2->setOn( TRUE ); |
247 | slotMonthLabel( 1 ); | 268 | slotMonthLabel( 1 ); |
248 | break; | 269 | break; |
249 | case Year: | 270 | case Year: |
250 | setupYearly(); | 271 | setupYearly(); |
251 | break; | 272 | break; |
252 | } | 273 | } |
253 | } | 274 | } |
254 | void ORecurranceWidget::endDateChanged(int y, int m, int d) { | 275 | void ORecurranceWidget::endDateChanged(int y, int m, int d) { |
255 | end.setYMD( y, m, d ); | 276 | end.setYMD( y, m, d ); |
256 | if ( end < start ) | 277 | if ( end < start ) |
257 | end = start; | 278 | end = start; |
258 | cmdEnd->setText( TimeString::shortDate( end ) ); | 279 | cmdEnd->setText( TimeString::shortDate( end ) ); |
259 | repeatPicker->setDate( end.year(), end.month(), end.day() ); | 280 | repeatPicker->setDate( end.year(), end.month(), end.day() ); |
260 | } | 281 | } |
261 | void ORecurranceWidget::slotNoEnd( bool unused) { | 282 | void ORecurranceWidget::slotNoEnd( bool unused) { |
262 | // if the item was toggled, then go ahead and set it to the maximum date | 283 | // if the item was toggled, then go ahead and set it to the maximum date |
263 | if ( unused ) { | 284 | if ( unused ) { |
264 | end.setYMD( 3000, 12, 31 ); | 285 | end.setYMD( 3000, 12, 31 ); |
265 | cmdEnd->setText( tr("No End Date") ); | 286 | cmdEnd->setText( tr("No End Date") ); |
266 | } else { | 287 | } else { |
267 | end = start; | 288 | end = start; |
268 | cmdEnd->setText( TimeString::shortDate(end) ); | 289 | cmdEnd->setText( TimeString::shortDate(end) ); |
269 | } | 290 | } |
270 | } | 291 | } |
271 | void ORecurranceWidget::setupRepeatLabel( const QString& s) { | 292 | void ORecurranceWidget::setupRepeatLabel( const QString& s) { |
272 | lblVar1->setText( s ); | 293 | lblVar1->setText( s ); |
273 | } | 294 | } |
274 | void ORecurranceWidget::setupRepeatLabel( int x) { | 295 | void ORecurranceWidget::setupRepeatLabel( int x) { |
275 | // change the spelling based on the value of x | 296 | // change the spelling based on the value of x |
276 | QString strVar2; | 297 | QString strVar2; |
277 | 298 | ||
278 | if ( x > 1 ) | 299 | if ( x > 1 ) |
279 | lblVar1->show(); | 300 | lblVar1->show(); |
280 | else | 301 | else |
281 | lblVar1->hide(); | 302 | lblVar1->hide(); |
282 | 303 | ||
283 | switch ( currInterval ) { | 304 | switch ( currInterval ) { |
284 | case None: | 305 | case None: |
285 | break; | 306 | break; |
286 | case Day: | 307 | case Day: |
287 | if ( x > 1 ) | 308 | if ( x > 1 ) |
288 | strVar2 = tr( "days" ); | 309 | strVar2 = tr( "days" ); |
289 | else | 310 | else |
290 | strVar2 = tr( "day" ); | 311 | strVar2 = tr( "day" ); |
291 | break; | 312 | break; |
292 | case Week: | 313 | case Week: |
293 | if ( x > 1 ) | 314 | if ( x > 1 ) |
294 | strVar2 = tr( "weeks" ); | 315 | strVar2 = tr( "weeks" ); |
295 | else | 316 | else |
296 | strVar2 = tr( "week" ); | 317 | strVar2 = tr( "week" ); |
297 | break; | 318 | break; |
298 | case Month: | 319 | case Month: |
299 | if ( x > 1 ) | 320 | if ( x > 1 ) |
300 | strVar2 = tr( "months" ); | 321 | strVar2 = tr( "months" ); |
301 | else | 322 | else |
302 | strVar2 = tr( "month" ); | 323 | strVar2 = tr( "month" ); |
303 | break; | 324 | break; |
304 | case Year: | 325 | case Year: |
305 | if ( x > 1 ) | 326 | if ( x > 1 ) |
306 | strVar2 = tr( "years" ); | 327 | strVar2 = tr( "years" ); |
307 | else | 328 | else |
308 | strVar2 = tr( "year" ); | 329 | strVar2 = tr( "year" ); |
309 | break; | 330 | break; |
310 | } | 331 | } |
311 | if ( !strVar2.isNull() ) | 332 | if ( !strVar2.isNull() ) |
312 | lblVar2->setText( strVar2 ); | 333 | lblVar2->setText( strVar2 ); |
313 | } | 334 | } |
314 | void ORecurranceWidget::slotWeekLabel() { | 335 | void ORecurranceWidget::slotWeekLabel() { |
315 | QString str; | 336 | QString str; |
316 | QListIterator<QToolButton> it( listExtra ); | 337 | QListIterator<QToolButton> it( listExtra ); |
317 | unsigned int i; | 338 | unsigned int i; |
318 | unsigned int keepMe; | 339 | unsigned int keepMe; |
319 | bool bNeedCarriage = FALSE; | 340 | bool bNeedCarriage = FALSE; |
320 | // don't do something we'll regret!!! | 341 | // don't do something we'll regret!!! |
321 | if ( currInterval != Week ) | 342 | if ( currInterval != Week ) |
322 | return; | 343 | return; |
323 | 344 | ||
324 | if ( startWeekOnMonday ) | 345 | if ( startWeekOnMonday ) |
325 | keepMe = start.dayOfWeek() - 1; | 346 | keepMe = start.dayOfWeek() - 1; |
326 | else | 347 | else |
327 | keepMe = start.dayOfWeek() % 7; | 348 | keepMe = start.dayOfWeek() % 7; |
328 | 349 | ||
329 | QStringList list; | 350 | QStringList list; |
330 | for ( i = 0; *it; ++it, i++ ) { | 351 | for ( i = 0; *it; ++it, i++ ) { |
331 | // a crazy check, if you are repeating weekly, the current day | 352 | // a crazy check, if you are repeating weekly, the current day |
332 | // must be selected!!! | 353 | // must be selected!!! |
333 | if ( i == keepMe && !( (*it)->isOn() ) ) | 354 | if ( i == keepMe && !( (*it)->isOn() ) ) |
334 | (*it)->setOn( TRUE ); | 355 | (*it)->setOn( TRUE ); |
335 | if ( (*it)->isOn() ) { | 356 | if ( (*it)->isOn() ) { |
336 | if ( startWeekOnMonday ) | 357 | if ( startWeekOnMonday ) |
337 | list.append( dayLabel[i] ); | 358 | list.append( dayLabel[i] ); |
338 | else { | 359 | else { |
339 | if ( i == 0 ) | 360 | if ( i == 0 ) |
340 | list.append( dayLabel[6] ); | 361 | list.append( dayLabel[6] ); |
341 | else | 362 | else |
342 | list.append( dayLabel[i - 1] ); | 363 | list.append( dayLabel[i - 1] ); |
343 | } | 364 | } |
344 | } | 365 | } |
345 | } | 366 | } |
346 | QStringList::Iterator itStr; | 367 | QStringList::Iterator itStr; |
347 | for ( i = 0, itStr = list.begin(); itStr != list.end(); ++itStr, i++ ) { | 368 | for ( i = 0, itStr = list.begin(); itStr != list.end(); ++itStr, i++ ) { |
348 | if ( i == 3 ) | 369 | if ( i == 3 ) |
349 | bNeedCarriage = TRUE; | 370 | bNeedCarriage = TRUE; |
350 | else | 371 | else |
351 | bNeedCarriage = FALSE; | 372 | bNeedCarriage = FALSE; |
352 | if ( str.isNull() ) | 373 | if ( str.isNull() ) |
353 | str = *itStr; | 374 | str = *itStr; |
354 | else if ( i == list.count() - 1 ) { | 375 | else if ( i == list.count() - 1 ) { |
355 | if ( i < 2 ) | 376 | if ( i < 2 ) |
356 | str += tr(" and ") + *itStr; | 377 | str += tr(" and ") + *itStr; |
357 | else { | 378 | else { |
358 | if ( bNeedCarriage ) | 379 | if ( bNeedCarriage ) |
359 | str += tr( ",\nand " ) + *itStr; | 380 | str += tr( ",\nand " ) + *itStr; |
360 | else | 381 | else |
361 | str += tr( ", and " ) + *itStr; | 382 | str += tr( ", and " ) + *itStr; |
362 | } | 383 | } |
363 | } else { | 384 | } else { |
364 | if ( bNeedCarriage ) | 385 | if ( bNeedCarriage ) |
365 | str += ",\n" + *itStr; | 386 | str += ",\n" + *itStr; |
366 | else | 387 | else |
367 | str += ", " + *itStr; | 388 | str += ", " + *itStr; |
368 | } | 389 | } |
369 | } | 390 | } |
370 | str = str.prepend( "on " ); | 391 | str = str.prepend( tr("on ") ); |
392 | |||
371 | lblWeekVar->setText( str ); | 393 | lblWeekVar->setText( str ); |
372 | } | 394 | } |
373 | void ORecurranceWidget::slotMonthLabel(int type) { | 395 | void ORecurranceWidget::slotMonthLabel(int type) { |
374 | QString str; | 396 | QString str; |
375 | if ( currInterval != Month || type > 1 ) | 397 | if ( currInterval != Month || type > 1 ) |
376 | return; | 398 | return; |
377 | if ( type == 1 ) | 399 | if ( type == 1 ) |
378 | str = strMonthDateTemplate.arg( numberPlacing(start.day()) ); | 400 | str = strMonthDateTemplate.arg( numberPlacing(start.day()) ); |
379 | else | 401 | else |
380 | str = strMonthDayTemplate.arg( numberPlacing(week(start))) | 402 | str = strMonthDayTemplate.arg( numberPlacing(week(start))) |
381 | .arg( dayLabel[start.dayOfWeek() - 1] ); | 403 | .arg( dayLabel[start.dayOfWeek() - 1] ); |
382 | lblRepeat->setText( str ); | 404 | lblRepeat->setText( str ); |
383 | } | 405 | } |
384 | void ORecurranceWidget::slotChangeStartOfWeek( bool onMonday ) { | 406 | void ORecurranceWidget::slotChangeStartOfWeek( bool onMonday ) { |
385 | startWeekOnMonday = onMonday; | 407 | startWeekOnMonday = onMonday; |
386 | // we need to make this unintrusive as possible... | 408 | // we need to make this unintrusive as possible... |
387 | int saveSpin = spinFreq->value(); | 409 | int saveSpin = spinFreq->value(); |
388 | char days = 0; | 410 | char days = 0; |
389 | int day; | 411 | int day; |
390 | QListIterator<QToolButton> itExtra( listExtra ); | 412 | QListIterator<QToolButton> itExtra( listExtra ); |
391 | for ( day = 1; *itExtra; ++itExtra, day = day << 1 ) { | 413 | for ( day = 1; *itExtra; ++itExtra, day = day << 1 ) { |
392 | if ( (*itExtra)->isOn() ) { | 414 | if ( (*itExtra)->isOn() ) { |
393 | if ( !startWeekOnMonday ) | 415 | if ( !startWeekOnMonday ) |
394 | days |= day; | 416 | days |= day; |
395 | else { | 417 | else { |
396 | if ( day == 1 ) | 418 | if ( day == 1 ) |
397 | days |= ORecur::SUN; | 419 | days |= ORecur::SUN; |
398 | else | 420 | else |
399 | days |= day >> 1; | 421 | days |= day >> 1; |
400 | } | 422 | } |
401 | } | 423 | } |
402 | } | 424 | } |
403 | setupWeekly(); | 425 | setupWeekly(); |
404 | spinFreq->setValue( saveSpin ); | 426 | spinFreq->setValue( saveSpin ); |
405 | int buttons; | 427 | int buttons; |
406 | for ( day = 0x01, buttons = 0; buttons < 7; | 428 | for ( day = 0x01, buttons = 0; buttons < 7; |
407 | day = day << 1, buttons++ ) { | 429 | day = day << 1, buttons++ ) { |
408 | if ( days & day ) { | 430 | if ( days & day ) { |
409 | if ( startWeekOnMonday ) | 431 | if ( startWeekOnMonday ) |
410 | fraExtra->setButton( buttons ); | 432 | fraExtra->setButton( buttons ); |
411 | else { | 433 | else { |
412 | if ( buttons == 7 ) | 434 | if ( buttons == 7 ) |
413 | fraExtra->setButton( 0 ); | 435 | fraExtra->setButton( 0 ); |
414 | else | 436 | else |
415 | fraExtra->setButton( buttons + 1 ); | 437 | fraExtra->setButton( buttons + 1 ); |
416 | } | 438 | } |
417 | } | 439 | } |
418 | } | 440 | } |
419 | slotWeekLabel(); | 441 | slotWeekLabel(); |
420 | } | 442 | } |
421 | void ORecurranceWidget::setupNone() { | 443 | void ORecurranceWidget::setupNone() { |
422 | lblRepeat->setText( tr("No Repeat") ); | 444 | lblRepeat->setText( tr("No Repeat") ); |
423 | lblVar1->hide(); | 445 | lblVar1->hide(); |
424 | lblVar2->hide(); | 446 | lblVar2->hide(); |
425 | hideExtras(); | 447 | hideExtras(); |
426 | cmdEnd->hide(); | 448 | cmdEnd->hide(); |
427 | lblFreq->hide(); | 449 | lblFreq->hide(); |
428 | lblEvery->hide(); | 450 | lblEvery->hide(); |
429 | lblFreq->hide(); | 451 | lblFreq->hide(); |
430 | spinFreq->hide(); | 452 | spinFreq->hide(); |
431 | lblEnd->hide(); | 453 | lblEnd->hide(); |
432 | lblWeekVar->hide(); | 454 | lblWeekVar->hide(); |
433 | } | 455 | } |
434 | void ORecurranceWidget::setupDaily() { | 456 | void ORecurranceWidget::setupDaily() { |
435 | hideExtras(); | 457 | hideExtras(); |
436 | lblWeekVar->hide(); | 458 | lblWeekVar->hide(); |
437 | spinFreq->setValue( 1 ); | 459 | spinFreq->setValue( 1 ); |
438 | lblFreq->setText( tr("day(s)") ); | 460 | lblFreq->setText( tr("day(s)") ); |
439 | lblVar2->show(); | 461 | lblVar2->show(); |
440 | showRepeatStuff(); | 462 | showRepeatStuff(); |
441 | lblRepeat->setText( strDayTemplate ); | 463 | lblRepeat->setText( strDayTemplate ); |
442 | setupRepeatLabel( 1 ); | 464 | setupRepeatLabel( 1 ); |
443 | } | 465 | } |
444 | void ORecurranceWidget::setupWeekly() { | 466 | void ORecurranceWidget::setupWeekly() { |
445 | // reshow the buttons... | 467 | // reshow the buttons... |
446 | fraExtra->setTitle( tr("Repeat On") ); | 468 | fraExtra->setTitle( tr("Repeat On") ); |
447 | fraExtra->setExclusive( FALSE ); | 469 | fraExtra->setExclusive( FALSE ); |
448 | fraExtra->show(); | 470 | fraExtra->show(); |
449 | if ( startWeekOnMonday ) { | 471 | if ( startWeekOnMonday ) { |
450 | cmdExtra1->setText( tr("Mon") ); | 472 | cmdExtra1->setText( tr("Mon") ); |
451 | cmdExtra2->setText( tr("Tue") ); | 473 | cmdExtra2->setText( tr("Tue") ); |
452 | cmdExtra3->setText( tr("Wed") ); | 474 | cmdExtra3->setText( tr("Wed") ); |
453 | cmdExtra4->setText( tr("Thu") ); | 475 | cmdExtra4->setText( tr("Thu") ); |
454 | cmdExtra5->setText( tr("Fri") ); | 476 | cmdExtra5->setText( tr("Fri") ); |
455 | cmdExtra6->setText( tr("Sat") ); | 477 | cmdExtra6->setText( tr("Sat") ); |
456 | cmdExtra7->setText( tr("Sun") ); | 478 | cmdExtra7->setText( tr("Sun") ); |
457 | } else { | 479 | } else { |
458 | cmdExtra1->setText( tr("Sun") ); | 480 | cmdExtra1->setText( tr("Sun") ); |
459 | cmdExtra2->setText( tr("Mon") ); | 481 | cmdExtra2->setText( tr("Mon") ); |
460 | cmdExtra3->setText( tr("Tue") ); | 482 | cmdExtra3->setText( tr("Tue") ); |
461 | cmdExtra4->setText( tr("Wed") ); | 483 | cmdExtra4->setText( tr("Wed") ); |
462 | cmdExtra5->setText( tr("Thu") ); | 484 | cmdExtra5->setText( tr("Thu") ); |
463 | cmdExtra6->setText( tr("Fri") ); | 485 | cmdExtra6->setText( tr("Fri") ); |
464 | cmdExtra7->setText( tr("Sat") ); | 486 | cmdExtra7->setText( tr("Sat") ); |
465 | } | 487 | } |
466 | // I hope clustering these improve performance.... | 488 | // I hope clustering these improve performance.... |
467 | cmdExtra1->setOn( FALSE ); | 489 | cmdExtra1->setOn( FALSE ); |
468 | cmdExtra2->setOn( FALSE ); | 490 | cmdExtra2->setOn( FALSE ); |
469 | cmdExtra3->setOn( FALSE ); | 491 | cmdExtra3->setOn( FALSE ); |
470 | cmdExtra4->setOn( FALSE ); | 492 | cmdExtra4->setOn( FALSE ); |
471 | cmdExtra5->setOn( FALSE ); | 493 | cmdExtra5->setOn( FALSE ); |
472 | cmdExtra6->setOn( FALSE ); | 494 | cmdExtra6->setOn( FALSE ); |
473 | cmdExtra7->setOn( FALSE ); | 495 | cmdExtra7->setOn( FALSE ); |
474 | 496 | ||
475 | cmdExtra1->show(); | 497 | cmdExtra1->show(); |
476 | cmdExtra2->show(); | 498 | cmdExtra2->show(); |
477 | cmdExtra3->show(); | 499 | cmdExtra3->show(); |
478 | cmdExtra4->show(); | 500 | cmdExtra4->show(); |
479 | cmdExtra5->show(); | 501 | cmdExtra5->show(); |
480 | cmdExtra6->show(); | 502 | cmdExtra6->show(); |
481 | cmdExtra7->show(); | 503 | cmdExtra7->show(); |
482 | 504 | ||
483 | lblWeekVar->show(); | 505 | lblWeekVar->show(); |
484 | spinFreq->setValue( 1 ); | 506 | spinFreq->setValue( 1 ); |
485 | // might as well set the day too... | 507 | // might as well set the day too... |
486 | if ( startWeekOnMonday ) { | 508 | if ( startWeekOnMonday ) { |
487 | fraExtra->setButton( start.dayOfWeek() - 1 ); | 509 | fraExtra->setButton( start.dayOfWeek() - 1 ); |
488 | } else { | 510 | } else { |
489 | fraExtra->setButton( start.dayOfWeek() % 7 ); | 511 | fraExtra->setButton( start.dayOfWeek() % 7 ); |
490 | } | 512 | } |
491 | lblFreq->setText( tr("week(s)") ); | 513 | lblFreq->setText( tr("week(s)") ); |
492 | lblVar2->show(); | 514 | lblVar2->show(); |
493 | showRepeatStuff(); | 515 | showRepeatStuff(); |
494 | setupRepeatLabel( 1 ); | 516 | setupRepeatLabel( 1 ); |
495 | } | 517 | } |
496 | void ORecurranceWidget::setupMonthly() { | 518 | void ORecurranceWidget::setupMonthly() { |
497 | hideExtras(); | 519 | hideExtras(); |
498 | lblWeekVar->hide(); | 520 | lblWeekVar->hide(); |
499 | fraExtra->setTitle( tr("Repeat By") ); | 521 | fraExtra->setTitle( tr("Repeat By") ); |
500 | fraExtra->setExclusive( TRUE ); | 522 | fraExtra->setExclusive( TRUE ); |
501 | fraExtra->show(); | 523 | fraExtra->show(); |
502 | cmdExtra1->setText( tr("Day") ); | 524 | cmdExtra1->setText( tr("Day") ); |
503 | cmdExtra1->show(); | 525 | cmdExtra1->show(); |
504 | cmdExtra2->setText( tr("Date") ); | 526 | cmdExtra2->setText( tr("Date") ); |
505 | cmdExtra2->show(); | 527 | cmdExtra2->show(); |
506 | spinFreq->setValue( 1 ); | 528 | spinFreq->setValue( 1 ); |
507 | lblFreq->setText( tr("month(s)") ); | 529 | lblFreq->setText( tr("month(s)") ); |
508 | lblVar2->show(); | 530 | lblVar2->show(); |
509 | showRepeatStuff(); | 531 | showRepeatStuff(); |
510 | setupRepeatLabel( 1 ); | 532 | setupRepeatLabel( 1 ); |
511 | } | 533 | } |
512 | void ORecurranceWidget::setupYearly() { | 534 | void ORecurranceWidget::setupYearly() { |
513 | hideExtras(); | 535 | hideExtras(); |
514 | lblWeekVar->hide(); | 536 | lblWeekVar->hide(); |
515 | spinFreq->setValue( 1 ); | 537 | spinFreq->setValue( 1 ); |
516 | lblFreq->setText( tr("year(s)") ); | 538 | lblFreq->setText( tr("year(s)") ); |
517 | lblFreq->show(); | 539 | lblFreq->show(); |
518 | lblFreq->show(); | 540 | lblFreq->show(); |
519 | showRepeatStuff(); | 541 | showRepeatStuff(); |
520 | lblVar2->show(); | 542 | lblVar2->show(); |
521 | QString strEvery = strYearTemplate.arg( start.monthName(start.month()) ).arg( numberPlacing(start.day()) ); | 543 | QString strEvery = strYearTemplate.arg( start.monthName(start.month()) ).arg( numberPlacing(start.day()) ); |
522 | lblRepeat->setText( strEvery ); | 544 | lblRepeat->setText( strEvery ); |
523 | setupRepeatLabel( 1 ); | 545 | setupRepeatLabel( 1 ); |
524 | 546 | ||
525 | } | 547 | } |
526 | void ORecurranceWidget::init() { | 548 | void ORecurranceWidget::init() { |
527 | QPopupMenu *m1 = new QPopupMenu( this ); | 549 | QPopupMenu *m1 = new QPopupMenu( this ); |
528 | repeatPicker = new DateBookMonth( m1, 0, TRUE ); | 550 | repeatPicker = new DateBookMonth( m1, 0, TRUE ); |
529 | m1->insertItem( repeatPicker ); | 551 | m1->insertItem( repeatPicker ); |
530 | cmdEnd->setPopup( m1 ); | 552 | cmdEnd->setPopup( m1 ); |
531 | cmdEnd->setPopupDelay( 0 ); | 553 | cmdEnd->setPopupDelay( 0 ); |
532 | 554 | ||
533 | QObject::connect( repeatPicker, SIGNAL(dateClicked(int, int, int)), | 555 | QObject::connect( repeatPicker, SIGNAL(dateClicked(int, int, int)), |
534 | this, SLOT(endDateChanged(int, int, int)) ); | 556 | this, SLOT(endDateChanged(int, int, int)) ); |
535 | QObject::connect( qApp, SIGNAL(weekChanged(bool)), | 557 | QObject::connect( qApp, SIGNAL(weekChanged(bool)), |
536 | this, SLOT(slotChangeStartOfWeek(bool)) ); | 558 | this, SLOT(slotChangeStartOfWeek(bool)) ); |
537 | 559 | ||
538 | listRTypeButtons.setAutoDelete( TRUE ); | 560 | listRTypeButtons.setAutoDelete( TRUE ); |
539 | listRTypeButtons.append( cmdNone ); | 561 | listRTypeButtons.append( cmdNone ); |
540 | listRTypeButtons.append( cmdDay ); | 562 | listRTypeButtons.append( cmdDay ); |
541 | listRTypeButtons.append( cmdWeek ); | 563 | listRTypeButtons.append( cmdWeek ); |
542 | listRTypeButtons.append( cmdMonth ); | 564 | listRTypeButtons.append( cmdMonth ); |
543 | listRTypeButtons.append( cmdYear ); | 565 | listRTypeButtons.append( cmdYear ); |
544 | 566 | ||
545 | listExtra.setAutoDelete( TRUE ); | 567 | listExtra.setAutoDelete( TRUE ); |
546 | listExtra.append( cmdExtra1 ); | 568 | listExtra.append( cmdExtra1 ); |
547 | listExtra.append( cmdExtra2 ); | 569 | listExtra.append( cmdExtra2 ); |
548 | listExtra.append( cmdExtra3 ); | 570 | listExtra.append( cmdExtra3 ); |
549 | listExtra.append( cmdExtra4 ); | 571 | listExtra.append( cmdExtra4 ); |
550 | listExtra.append( cmdExtra5 ); | 572 | listExtra.append( cmdExtra5 ); |
551 | listExtra.append( cmdExtra6 ); | 573 | listExtra.append( cmdExtra6 ); |
552 | listExtra.append( cmdExtra7 ); | 574 | listExtra.append( cmdExtra7 ); |
553 | } | 575 | } |
554 | void ORecurranceWidget::hideExtras() { | 576 | void ORecurranceWidget::hideExtras() { |
555 | // hide the extra buttons... | 577 | // hide the extra buttons... |
556 | fraExtra->hide(); | 578 | fraExtra->hide(); |
557 | chkNoEnd->hide(); | 579 | chkNoEnd->hide(); |
558 | QListIterator<QToolButton> it( listExtra ); | 580 | QListIterator<QToolButton> it( listExtra ); |
559 | for ( ; *it; ++it ) { | 581 | for ( ; *it; ++it ) { |
560 | (*it)->hide(); | 582 | (*it)->hide(); |
561 | (*it)->setOn( FALSE ); | 583 | (*it)->setOn( FALSE ); |
562 | } | 584 | } |
563 | } | 585 | } |
564 | void ORecurranceWidget::showRepeatStuff() { | 586 | void ORecurranceWidget::showRepeatStuff() { |
565 | cmdEnd->show(); | 587 | cmdEnd->show(); |
566 | chkNoEnd->show(); | 588 | chkNoEnd->show(); |
567 | lblFreq->show(); | 589 | lblFreq->show(); |
568 | lblEvery->show(); | 590 | lblEvery->show(); |
569 | lblFreq->show(); | 591 | lblFreq->show(); |
570 | spinFreq->show(); | 592 | spinFreq->show(); |
571 | lblEnd->show(); | 593 | lblEnd->show(); |
572 | lblRepeat->setText( tr("Every") ); | 594 | lblRepeat->setText( tr("Every") ); |
573 | } | 595 | } |
574 | 596 | ||
575 | 597 | ||
576 | static int week( const QDate &start ) | 598 | static int week( const QDate &start ) |
577 | { | 599 | { |
578 | // figure out the week... | 600 | // figure out the week... |
579 | int stop = start.day(), | 601 | int stop = start.day(), |
580 | sentinel = start.dayOfWeek(), | 602 | sentinel = start.dayOfWeek(), |
581 | dayOfWeek = QDate( start.year(), start.month(), 1 ).dayOfWeek(), | 603 | dayOfWeek = QDate( start.year(), start.month(), 1 ).dayOfWeek(), |
582 | week = 1, | 604 | week = 1, |
583 | i; | 605 | i; |
584 | for ( i = 1; i < stop; i++ ) { | 606 | for ( i = 1; i < stop; i++ ) { |
585 | if ( dayOfWeek++ == sentinel ) | 607 | if ( dayOfWeek++ == sentinel ) |
586 | week++; | 608 | week++; |
587 | if ( dayOfWeek > 7 ) | 609 | if ( dayOfWeek > 7 ) |
588 | dayOfWeek = 0; | 610 | dayOfWeek = 0; |
589 | } | 611 | } |
590 | return week; | 612 | return week; |
591 | } | 613 | } |
592 | 614 | ||
593 | static QString numberPlacing( int x ) | 615 | static QString numberPlacing( int x ) |
594 | { | 616 | { |
595 | // I hope this works in other languages besides english... | 617 | // I hope this works in other languages besides english... |
596 | QString str = QString::number( x ); | 618 | QString str = QString::number( x ); |
597 | switch ( x % 10 ) { | 619 | switch ( x % 10 ) { |
598 | case 1: | 620 | case 1: |
599 | str += QWidget::tr( "st" ); | 621 | str += QWidget::tr( "st" ); |
600 | break; | 622 | break; |
601 | case 2: | 623 | case 2: |
602 | str += QWidget::tr( "nd" ); | 624 | str += QWidget::tr( "nd" ); |
603 | break; | 625 | break; |
604 | case 3: | 626 | case 3: |
605 | str += QWidget::tr( "rd" ); | 627 | str += QWidget::tr( "rd" ); |
606 | break; | 628 | break; |
607 | default: | 629 | default: |
608 | str += QWidget::tr( "th" ); | 630 | str += QWidget::tr( "th" ); |
609 | break; | 631 | break; |
610 | } | 632 | } |
611 | return str; | 633 | return str; |
612 | } | 634 | } |
diff --git a/libopie/oticker.h b/libopie/oticker.h index 0b88919..4026eb5 100644 --- a/libopie/oticker.h +++ b/libopie/oticker.h | |||
@@ -1,146 +1,146 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> | 3 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> |
4 | =. | 4 | =. |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | 28 | ||
29 | */ | 29 | */ |
30 | 30 | ||
31 | #ifndef OTICKER_H | 31 | #ifndef OTICKER_H |
32 | #define OTICKER_H | 32 | #define OTICKER_H |
33 | 33 | ||
34 | #include <qwidget.h> | 34 | #include <qwidget.h> |
35 | #include <qpainter.h> | 35 | #include <qpainter.h> |
36 | #include <qdrawutil.h> | 36 | #include <qdrawutil.h> |
37 | #include <qpixmap.h> | 37 | #include <qpixmap.h> |
38 | #include <qstring.h> | 38 | #include <qstring.h> |
39 | #include <qslider.h> | 39 | #include <qslider.h> |
40 | #include <qlabel.h> | 40 | #include <qlabel.h> |
41 | #include <qframe.h> | 41 | #include <qframe.h> |
42 | #include <qcolor.h> | 42 | #include <qcolor.h> |
43 | 43 | ||
44 | /** | 44 | /** |
45 | * @class OTicker | 45 | * @class OTicker |
46 | * @brief The OTicker class provides a QLabel widget that scroll its contents | 46 | * @brief The OTicker class provides a QLabel widget that scroll its contents |
47 | * | 47 | * |
48 | */ | 48 | */ |
49 | class OTicker : public QLabel { | 49 | class OTicker : public QLabel { |
50 | Q_OBJECT | 50 | Q_OBJECT |
51 | 51 | ||
52 | public: | 52 | public: |
53 | 53 | ||
54 | /*! | 54 | /*! |
55 | * @fn OTicker( QWidget* parent = 0 ) | 55 | * @fn OTicker( QWidget* parent = 0 ) |
56 | * @brief Object constructor. | 56 | * @brief Object constructor. |
57 | * | 57 | * |
58 | * @param parent Pointer to parent of this control. | 58 | * @param parent Pointer to parent of this control. |
59 | 59 | ||
60 | * Constructs a new OTicker control with parent | 60 | * Constructs a new OTicker control with parent |
61 | */ | 61 | */ |
62 | OTicker( QWidget* parent=0 ); | 62 | OTicker( QWidget* parent=0 ); |
63 | /*! | 63 | /*! |
64 | * @fn ~OTicker() | 64 | * @fn ~OTicker() |
65 | * @brief Object destructor. | 65 | * @brief Object destructor. |
66 | */ | 66 | */ |
67 | ~OTicker(); | 67 | ~OTicker(); |
68 | /*! | 68 | /*! |
69 | * @fn setText(const QString& ) | 69 | * @fn setText(const QString& ) |
70 | * @brief sets text to be displayed | 70 | * @brief sets text to be displayed |
71 | * @param text QString text to be displayed. | 71 | * @param text QString text to be displayed. |
72 | * | 72 | * |
73 | */ | 73 | */ |
74 | void setText( const QString& text ) ; | 74 | void setText( const QString& text ) ; |
75 | /*! | 75 | /*! |
76 | * @fn setBackgroundColor(QColor color) | 76 | * @fn setBackgroundColor(const QColor& color) |
77 | * @brief sets color of the ticker's background | 77 | * @brief sets color of the ticker's background |
78 | * @param color QColor color to be set. | 78 | * @param color QColor color to be set. |
79 | * | 79 | * |
80 | */ | 80 | */ |
81 | void setBackgroundColor(const QColor& color); | 81 | void setBackgroundColor(const QColor& color); |
82 | /*! | 82 | /*! |
83 | * @fn setForegroundColor(QColor color) | 83 | * @fn setForegroundColor(const QColor& color) |
84 | * @brief sets color of text | 84 | * @brief sets color of text |
85 | * @param color QColor color of text | 85 | * @param color QColor color of text |
86 | * | 86 | * |
87 | */ | 87 | */ |
88 | void setForegroundColor(const QColor& color); | 88 | void setForegroundColor(const QColor& color); |
89 | /*! | 89 | /*! |
90 | * @fn setFrame(int style) | 90 | * @fn setFrame(int style) |
91 | * @brief sets frame style | 91 | * @brief sets frame style |
92 | * @param style int Frame style to be see. See Qt::WidgetFlags. | 92 | * @param style int Frame style to be see. See Qt::WidgetFlags. |
93 | * | 93 | * |
94 | */ | 94 | */ |
95 | void setFrame(int style); | 95 | void setFrame(int style); |
96 | /*! | 96 | /*! |
97 | * @fn setUpdateTime(int timeout) | 97 | * @fn setUpdateTime(int timeout) |
98 | * @brief sets time of update | 98 | * @brief sets time of update |
99 | * @param timeout int time in milliseconds between updates. | 99 | * @param timeout int time in milliseconds between updates. |
100 | * | 100 | * |
101 | */ | 101 | */ |
102 | void setUpdateTime(int timeout); | 102 | void setUpdateTime(int timeout); |
103 | /*! | 103 | /*! |
104 | * @fn setScrollLength(int length) | 104 | * @fn setScrollLength(int length) |
105 | * @brief sets amount of scrolling default is 1 | 105 | * @brief sets amount of scrolling default is 1 |
106 | * @param length int scroll length. | 106 | * @param length int scroll length. |
107 | * | 107 | * |
108 | */ | 108 | */ |
109 | void setScrollLength(int length); | 109 | void setScrollLength(int length); |
110 | signals: | 110 | signals: |
111 | /*! | 111 | /*! |
112 | * @fn mousePressed() | 112 | * @fn mousePressed() |
113 | * @brief signal mouse press event | 113 | * @brief signal mouse press event |
114 | * | 114 | * |
115 | */ | 115 | */ |
116 | void mousePressed(); | 116 | void mousePressed(); |
117 | protected: | 117 | protected: |
118 | /*! | 118 | /*! |
119 | * @fn timerEvent( QTimerEvent * e) | 119 | * @fn timerEvent( QTimerEvent * e) |
120 | * @brief timer timeout event | 120 | * @brief timer timeout event |
121 | * @param e QEvent see QEvent. | 121 | * @param e QEvent see QEvent. |
122 | * | 122 | * |
123 | */ | 123 | */ |
124 | void timerEvent( QTimerEvent * e); | 124 | void timerEvent( QTimerEvent * e); |
125 | /*! | 125 | /*! |
126 | * @fn drawContents( QPainter *p ) | 126 | * @fn drawContents( QPainter *p ) |
127 | * @brief draws widget contents | 127 | * @brief draws widget contents |
128 | * @param p QPainter. see QPainter | 128 | * @param p QPainter. see QPainter |
129 | * | 129 | * |
130 | */ | 130 | */ |
131 | void drawContents( QPainter *p ); | 131 | void drawContents( QPainter *p ); |
132 | /*! | 132 | /*! |
133 | * @fn mouseReleaseEvent( QMouseEvent *e) | 133 | * @fn mouseReleaseEvent( QMouseEvent *e) |
134 | * @brief mouse release event | 134 | * @brief mouse release event |
135 | * @param e QMouseEvent. see QMouseEvent. | 135 | * @param e QMouseEvent. see QMouseEvent. |
136 | * | 136 | * |
137 | */ | 137 | */ |
138 | void mouseReleaseEvent( QMouseEvent *e); | 138 | void mouseReleaseEvent( QMouseEvent *e); |
139 | private: | 139 | private: |
140 | QColor backgroundcolor, foregroundcolor; | 140 | QColor backgroundcolor, foregroundcolor; |
141 | QString scrollText; | 141 | QString scrollText; |
142 | QPixmap scrollTextPixmap; | 142 | QPixmap scrollTextPixmap; |
143 | int pos, updateTimerTime, scrollLength; | 143 | int pos, updateTimerTime, scrollLength; |
144 | }; | 144 | }; |
145 | 145 | ||
146 | #endif | 146 | #endif |
diff --git a/libopie/todayplugininterface.h b/libopie/todayplugininterface.h index 532f492..5dfeaa8 100644 --- a/libopie/todayplugininterface.h +++ b/libopie/todayplugininterface.h | |||
@@ -1,109 +1,133 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | Copyright (c) 2002 Maximilian Reiss <max.reiss@gmx.de> | ||
4 | =. | ||
5 | .=l. | ||
6 | .>+-= | ||
7 | _;:, .> :=|. This program is free software; you can | ||
8 | .> <`_, > . <= redistribute it and/or modify it under | ||
9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | ||
10 | .="- .-=="i, .._ License as published by the Free Software | ||
11 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
12 | ._= =} : or (at your option) any later version. | ||
13 | .%`+i> _;_. | ||
14 | .i_,=:_. -<s. This program is distributed in the hope that | ||
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
16 | : .. .:, . . . without even the implied warranty of | ||
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
19 | ..}^=.= = ; Library General Public License for more | ||
20 | ++= -. .` .: details. | ||
21 | : = ...= . :.=- | ||
22 | -. .:....=;==+<; You should have received a copy of the GNU | ||
23 | -_. . . )=. = Library General Public License along with | ||
24 | -- :-=` this library; see the file COPYING.LIB. | ||
25 | If not, write to the Free Software Foundation, | ||
26 | Inc., 59 Temple Place - Suite 330, | ||
27 | Boston, MA 02111-1307, USA. | ||
28 | |||
29 | */ | ||
30 | |||
1 | 31 | ||
2 | #ifndef TODAY_PLUGIN_INTERFACE | 32 | #ifndef TODAY_PLUGIN_INTERFACE |
3 | #define TODAY_PLUGIN_INTERFACE | 33 | #define TODAY_PLUGIN_INTERFACE |
4 | 34 | ||
5 | #include <qpe/qcom.h> | 35 | #include <qpe/qcom.h> |
6 | #include "todayconfigwidget.h" | 36 | #include "todayconfigwidget.h" |
7 | 37 | ||
8 | class QString; | 38 | class QString; |
9 | class QWidget; | 39 | class QWidget; |
10 | 40 | ||
11 | #ifndef IID_TodayPluginInterface | 41 | #ifndef IID_TodayPluginInterface |
12 | #define IID_TodayPluginInterface QUuid( 0x70481804, 0x2b50, 0x4fba, 0x80, 0xbb, 0x0b, 0xf8, 0xdc, 0x72, 0x04, 0x14) | 42 | #define IID_TodayPluginInterface QUuid( 0x70481804, 0x2b50, 0x4fba, 0x80, 0xbb, 0x0b, 0xf8, 0xdc, 0x72, 0x04, 0x14) |
13 | #endif | 43 | #endif |
14 | 44 | ||
15 | /** | 45 | /** |
16 | * | 46 | * |
17 | * A TodayPluginObject is the base for all Today Plugins. | 47 | * A TodayPluginObject is the base for all Today Plugins. |
18 | * A plugin author needs to inherit this class and implement | 48 | * A plugin author needs to inherit this class and implement |
19 | * the pure virtual methods | 49 | * the pure virtual methods |
20 | * | 50 | * |
21 | * @short base class for today plugins | 51 | * @short base class for today plugins |
22 | * @author Maximilian Reiss | 52 | * @author Maximilian Reiss |
23 | * | 53 | * |
24 | */ | 54 | */ |
25 | class TodayPluginObject { | 55 | class TodayPluginObject { |
26 | 56 | ||
27 | public: | 57 | public: |
28 | 58 | ||
29 | virtual ~TodayPluginObject() {}; | 59 | virtual ~TodayPluginObject() {}; |
30 | 60 | ||
31 | /** | 61 | /** |
32 | * The name if the plugin | 62 | * The name if the plugin |
33 | * @return The plugin should return its name here | 63 | * @return The plugin should return its name here |
34 | */ | 64 | */ |
35 | virtual QString pluginName() const = 0; | 65 | virtual QString pluginName() const = 0; |
36 | 66 | ||
37 | /** | 67 | /** |
38 | * Version numbering | 68 | * Version numbering |
39 | * @return The plugin should return the version number | 69 | * @return The plugin should return the version number |
40 | */ | 70 | */ |
41 | virtual double versionNumber() const = 0; | 71 | virtual double versionNumber() const = 0; |
42 | 72 | ||
43 | 73 | ||
44 | /** | 74 | /** |
45 | * @return the pixmap name widget?! -- FIXME | 75 | * @return the pixmap name widget?! -- FIXME |
46 | */ | 76 | */ |
47 | virtual QString pixmapNameWidget() const = 0; | 77 | virtual QString pixmapNameWidget() const = 0; |
48 | 78 | ||
49 | /** | 79 | /** |
50 | * widget for the today view | 80 | * widget for the today view |
51 | * It _needs_ a parent here. | 81 | * It _needs_ a parent here. |
52 | * Plugin authors need to take parent as parent! | 82 | * Plugin authors need to take parent as parent! |
53 | */ | 83 | */ |
54 | virtual QWidget* widget( QWidget *parent ) = 0; | 84 | virtual QWidget* widget( QWidget *parent ) = 0; |
55 | 85 | ||
56 | /** | 86 | /** |
57 | * Pixmap used in the config widget | 87 | * Pixmap used in the config widget |
58 | */ | 88 | */ |
59 | virtual QString pixmapNameConfig() const = 0; | 89 | virtual QString pixmapNameConfig() const = 0; |
60 | 90 | ||
61 | /** | 91 | /** |
62 | * Config plugin widget - optional | 92 | * Config plugin widget - optional |
63 | * If the plugin has a config widget, it _needs_ a parent here. | 93 | * If the plugin has a config widget, it _needs_ a parent here. |
64 | * may return 0 if no config widget is needed | 94 | * may return 0 if no config widget is needed |
65 | */ | 95 | */ |
66 | virtual TodayConfigWidget* configWidget( QWidget * ) = 0; | 96 | virtual TodayConfigWidget* configWidget( QWidget * ) = 0; |
67 | 97 | ||
68 | /** | 98 | /** |
69 | * The application that should be assigned to the button (pixmap) | 99 | * The application that should be assigned to the button (pixmap) |
70 | * Today will show the plugin icon. On click it tries to execute the | 100 | * Today will show the plugin icon. On click it tries to execute the |
71 | * plugin related application. | 101 | * plugin related application. |
72 | */ | 102 | */ |
73 | virtual QString appName() const = 0; | 103 | virtual QString appName() const = 0; |
74 | 104 | ||
75 | 105 | ||
76 | /** | 106 | /** |
77 | * If the plugin should take part in the periodic refresh | 107 | * If the plugin should take part in the periodic refresh |
78 | */ | 108 | */ |
79 | virtual bool excludeFromRefresh() const = 0; | 109 | virtual bool excludeFromRefresh() const = 0; |
80 | 110 | ||
81 | /** | 111 | /** |
82 | * Refresh that plugins view. For updating the plugins | 112 | * Refresh that plugins view. For updating the plugins |
83 | * | ||
84 | */ | 113 | */ |
85 | virtual void refresh() {}; | 114 | virtual void refresh() {}; |
86 | 115 | ||
87 | /** | 116 | /** |
88 | * minimum height the plugin at least should have | 117 | * reread the plugins config and act apropiate |
118 | * This is for example used when returning from the config dialog | ||
89 | */ | 119 | */ |
90 | // virtual int minHeight() const = 0; | 120 | virtual void reinitialize() {}; |
91 | |||
92 | /** | ||
93 | * maximum height that should be used before starting scrolling | ||
94 | */ | ||
95 | // virtual int maxHeight() const = 0; | ||
96 | |||
97 | }; | 121 | }; |
98 | 122 | ||
99 | /** | 123 | /** |
100 | * This is part of the QCOM works. See example plugins how to do it right | 124 | * This is part of the QCOM works. See example plugins how to do it right |
101 | */ | 125 | */ |
102 | struct TodayPluginInterface : public QUnknownInterface { | 126 | struct TodayPluginInterface : public QUnknownInterface { |
103 | /** | 127 | /** |
104 | * return the TodayPluginObject implementation | 128 | * return the TodayPluginObject implementation |
105 | */ | 129 | */ |
106 | virtual TodayPluginObject *guiPart() = 0; | 130 | virtual TodayPluginObject *guiPart() = 0; |
107 | }; | 131 | }; |
108 | 132 | ||
109 | #endif | 133 | #endif |