-rw-r--r-- | library/dummy_api_docu.cpp | 250 | ||||
-rw-r--r-- | library/timestring.cpp | 4 | ||||
-rw-r--r-- | library/timestring.h | 12 |
3 files changed, 263 insertions, 3 deletions
diff --git a/library/dummy_api_docu.cpp b/library/dummy_api_docu.cpp index f2153df..97d28e8 100644 --- a/library/dummy_api_docu.cpp +++ b/library/dummy_api_docu.cpp | |||
@@ -1,369 +1,619 @@ | |||
1 | /* | 1 | /* |
2 | * A place to explain various headers | 2 | * A place to explain various headers |
3 | */ | 3 | */ |
4 | 4 | ||
5 | /* | 5 | /* |
6 | * applicationinterface.h | 6 | * applicationinterface.h |
7 | */ | 7 | */ |
8 | 8 | ||
9 | /** | 9 | /** |
10 | * \class ApplicationInterface | 10 | * \class ApplicationInterface |
11 | * \brief Application interface currently used by the quicklaunch framework | 11 | * \brief Application interface currently used by the quicklaunch framework |
12 | * | 12 | * |
13 | * This is the interface to be exposed by applications available as DSO | 13 | * This is the interface to be exposed by applications available as DSO |
14 | * Normally one would use the OApplicationFactory which does the magic of | 14 | * Normally one would use the OApplicationFactory which does the magic of |
15 | * exposing the interface. | 15 | * exposing the interface. |
16 | * | 16 | * |
17 | * Resulting dynamic shared objects (dso) need to go into the | 17 | * Resulting dynamic shared objects (dso) need to go into the |
18 | * OPIEDIR/plugins/application. | 18 | * OPIEDIR/plugins/application. |
19 | * | 19 | * |
20 | * | 20 | * |
21 | * You can use this interface to load applications into your application. | 21 | * You can use this interface to load applications into your application. |
22 | * @todo Implement Services + Trader | 22 | * @todo Implement Services + Trader |
23 | * @since Opie 1.0.2 | 23 | * @since Opie 1.0.2 |
24 | */ | 24 | */ |
25 | /** | 25 | /** |
26 | * \fn QWidget* ApplicationInterface::createMainWindow(const QString& appName, QWidget* parent, const char* name, Qt::WFlags f) | 26 | * \fn QWidget* ApplicationInterface::createMainWindow(const QString& appName, QWidget* parent, const char* name, Qt::WFlags f) |
27 | * \brief create the mainwindow for the giving application name | 27 | * \brief create the mainwindow for the giving application name |
28 | * Create a main window for the giving application name | 28 | * Create a main window for the giving application name |
29 | * | 29 | * |
30 | * @param appName The application widget to be created | 30 | * @param appName The application widget to be created |
31 | * @param parent The parent of the newly created widget | 31 | * @param parent The parent of the newly created widget |
32 | * @param name The name of the QObject | 32 | * @param name The name of the QObject |
33 | * @param f Possible Window Flags | 33 | * @param f Possible Window Flags |
34 | * | 34 | * |
35 | * @return the widget or 0l | 35 | * @return the widget or 0l |
36 | */ | 36 | */ |
37 | /** | 37 | /** |
38 | * \fn QStringList ApplicationInterface::applications()const | 38 | * \fn QStringList ApplicationInterface::applications()const |
39 | * The list of application windows supported | 39 | * The list of application windows supported |
40 | */ | 40 | */ |
41 | 41 | ||
42 | /* | 42 | /* |
43 | * Font Factory | 43 | * Font Factory |
44 | */ | 44 | */ |
45 | 45 | ||
46 | /** | 46 | /** |
47 | * \class FontFactoryInterface | 47 | * \class FontFactoryInterface |
48 | * \brief Interface for additional Font Factories | 48 | * \brief Interface for additional Font Factories |
49 | * | 49 | * |
50 | * To add special types of fonts TrueTypes or your very own | 50 | * To add special types of fonts TrueTypes or your very own |
51 | * format. If you implement this Interface you can add | 51 | * format. If you implement this Interface you can add |
52 | * custom font loading. | 52 | * custom font loading. |
53 | * | 53 | * |
54 | * The dynamic shared object goes to | 54 | * The dynamic shared object goes to |
55 | * OPIEDIR/plugins/fontfactories. | 55 | * OPIEDIR/plugins/fontfactories. |
56 | * | 56 | * |
57 | * As of version Opie 1.0.2 loading of the plugins is not | 57 | * As of version Opie 1.0.2 loading of the plugins is not |
58 | * yet implemented | 58 | * yet implemented |
59 | * | 59 | * |
60 | */ | 60 | */ |
61 | 61 | ||
62 | /** | 62 | /** |
63 | * \fn QFontFactory* FontFactoryInterface::fontFactory() | 63 | * \fn QFontFactory* FontFactoryInterface::fontFactory() |
64 | * | 64 | * |
65 | * Create a new QFontFactory and return it | 65 | * Create a new QFontFactory and return it |
66 | */ | 66 | */ |
67 | 67 | ||
68 | 68 | ||
69 | /* | 69 | /* |
70 | * ImageCodec | 70 | * ImageCodec |
71 | */ | 71 | */ |
72 | 72 | ||
73 | /** | 73 | /** |
74 | * \class ImageCodecInterface | 74 | * \class ImageCodecInterface |
75 | * \brief add Image Codecs | 75 | * \brief add Image Codecs |
76 | * | 76 | * |
77 | * This interface will be queried to add new Image loading | 77 | * This interface will be queried to add new Image loading |
78 | * and saving routines. | 78 | * and saving routines. |
79 | * | 79 | * |
80 | * The ImageCodec needs to be placed in OPIEDIR/plugins/imagecodecs. | 80 | * The ImageCodec needs to be placed in OPIEDIR/plugins/imagecodecs. |
81 | * | 81 | * |
82 | * @see QImage | 82 | * @see QImage |
83 | * @see QImageIO | 83 | * @see QImageIO |
84 | **/ | 84 | **/ |
85 | 85 | ||
86 | /** | 86 | /** |
87 | * \fn QStringList ImageCodecInterface::keys()const | 87 | * \fn QStringList ImageCodecInterface::keys()const |
88 | * \brief Query for the list of supported formats | 88 | * \brief Query for the list of supported formats |
89 | * | 89 | * |
90 | * Return a QStringList of the supported formats | 90 | * Return a QStringList of the supported formats |
91 | * | 91 | * |
92 | */ | 92 | */ |
93 | 93 | ||
94 | /** | 94 | /** |
95 | * \fn bool ImageCodecInterface::installIOHandler(const QString& format ) | 95 | * \fn bool ImageCodecInterface::installIOHandler(const QString& format ) |
96 | * \brief install codec to QIageIO for the specefic format | 96 | * \brief install codec to QIageIO for the specefic format |
97 | * | 97 | * |
98 | * Install a QImage codec for the requested format | 98 | * Install a QImage codec for the requested format |
99 | */ | 99 | */ |
100 | 100 | ||
101 | /* | 101 | /* |
102 | * Input Methods | 102 | * Input Methods |
103 | */ | 103 | */ |
104 | 104 | ||
105 | /** | 105 | /** |
106 | * \class InputMethodInterface | 106 | * \class InputMethodInterface |
107 | * \brief Interface class for inputting keyboard events | 107 | * \brief Interface class for inputting keyboard events |
108 | * | 108 | * |
109 | * InputMethods are loaded by the Launcher/Server/Taskbar | 109 | * InputMethods are loaded by the Launcher/Server/Taskbar |
110 | * and are located inside OPIEDIR/plugins/inputmethods | 110 | * and are located inside OPIEDIR/plugins/inputmethods |
111 | * | 111 | * |
112 | * Depending on the device these InputMethods are the only way | 112 | * Depending on the device these InputMethods are the only way |
113 | * to input charachters | 113 | * to input charachters |
114 | * | 114 | * |
115 | */ | 115 | */ |
116 | 116 | ||
117 | 117 | ||
118 | /** | 118 | /** |
119 | * \fn QWidget InputMethodInterface::inputMethod(QWidget*parent, Qt::WFlags f) | 119 | * \fn QWidget InputMethodInterface::inputMethod(QWidget*parent, Qt::WFlags f) |
120 | * \brief create a new widget which should be used as input | 120 | * \brief create a new widget which should be used as input |
121 | * | 121 | * |
122 | * This method will be called if the inputmethod is to be shown. | 122 | * This method will be called if the inputmethod is to be shown. |
123 | * Make sure that your widget is not too large. As of Opie1.1 InputMethods | 123 | * Make sure that your widget is not too large. As of Opie1.1 InputMethods |
124 | * can be floating as well. | 124 | * can be floating as well. |
125 | * | 125 | * |
126 | * Delete the Widget yourself. | 126 | * Delete the Widget yourself. |
127 | * | 127 | * |
128 | * | 128 | * |
129 | * @param parent The parent of the to be created Input widget. | 129 | * @param parent The parent of the to be created Input widget. |
130 | * @param f The Qt::WFlags for the widget | 130 | * @param f The Qt::WFlags for the widget |
131 | */ | 131 | */ |
132 | 132 | ||
133 | /** | 133 | /** |
134 | * \fn void InputMethodInterface::resetState() | 134 | * \fn void InputMethodInterface::resetState() |
135 | * \brief Reset the state of the inputmethod | 135 | * \brief Reset the state of the inputmethod |
136 | * | 136 | * |
137 | * If you're shown reset the state of the keyboard to the | 137 | * If you're shown reset the state of the keyboard to the |
138 | * the default. | 138 | * the default. |
139 | */ | 139 | */ |
140 | 140 | ||
141 | /** | 141 | /** |
142 | * \fn QPixmap* InputMethodInterface::icon() | 142 | * \fn QPixmap* InputMethodInterface::icon() |
143 | * \brief The icon of your Input method | 143 | * \brief The icon of your Input method |
144 | * | 144 | * |
145 | * Return a pointer to a QPixmap symboling your inputmethod | 145 | * Return a pointer to a QPixmap symboling your inputmethod |
146 | * You need to delete the pixmap later yourself. | 146 | * You need to delete the pixmap later yourself. |
147 | */ | 147 | */ |
148 | 148 | ||
149 | /** | 149 | /** |
150 | * \fn void InputMethodInterface::onKeyPress(QObject* receiver, const char* slot) | 150 | * \fn void InputMethodInterface::onKeyPress(QObject* receiver, const char* slot) |
151 | * \brief pass your key event through | 151 | * \brief pass your key event through |
152 | * | 152 | * |
153 | * In your actual Input Implementation you'll need a SIGNAL with this | 153 | * In your actual Input Implementation you'll need a SIGNAL with this |
154 | * void key(ushort,ushort,ushort,bool,bool) signal. The host of your input method | 154 | * void key(ushort,ushort,ushort,bool,bool) signal. The host of your input method |
155 | * requests you to connect your signal with the signal out of receiver and slot. | 155 | * requests you to connect your signal with the signal out of receiver and slot. |
156 | * | 156 | * |
157 | * ushort == unicode value | 157 | * ushort == unicode value |
158 | * ushort == keycode | 158 | * ushort == keycode |
159 | * ushort == modifiers from Qt::ButtonState | 159 | * ushort == modifiers from Qt::ButtonState |
160 | * bool == true if the key is pressed and false if released | 160 | * bool == true if the key is pressed and false if released |
161 | * bool == autorepeat on or off. | 161 | * bool == autorepeat on or off. |
162 | * | 162 | * |
163 | * See the QWSServer for more information about emitting keys | 163 | * See the QWSServer for more information about emitting keys |
164 | * | 164 | * |
165 | * | 165 | * |
166 | * @param receiver the receiver to QObject::connect to | 166 | * @param receiver the receiver to QObject::connect to |
167 | * @param slot the slot to QObject::connect to | 167 | * @param slot the slot to QObject::connect to |
168 | * | 168 | * |
169 | */ | 169 | */ |
170 | 170 | ||
171 | /* | 171 | /* |
172 | * MediaPlayer Plugins | 172 | * MediaPlayer Plugins |
173 | */ | 173 | */ |
174 | 174 | ||
175 | /** | 175 | /** |
176 | * \class MediaPlayerPluginInterface | 176 | * \class MediaPlayerPluginInterface |
177 | * \brief Plugins for the Opie Player I | 177 | * \brief Plugins for the Opie Player I |
178 | * | 178 | * |
179 | * You can extend the Opie Player I by plugins placed in | 179 | * You can extend the Opie Player I by plugins placed in |
180 | * OPIEDIR/plugins/codecs | 180 | * OPIEDIR/plugins/codecs |
181 | * | 181 | * |
182 | * | 182 | * |
183 | */ | 183 | */ |
184 | 184 | ||
185 | /** | 185 | /** |
186 | * \fn MediaPlayerDecoder MediaPlayerPluginInterface::decoder() | 186 | * \fn MediaPlayerDecoder MediaPlayerPluginInterface::decoder() |
187 | * | 187 | * |
188 | * Create a new MediaPlayerDecoder | 188 | * Create a new MediaPlayerDecoder |
189 | * | 189 | * |
190 | */ | 190 | */ |
191 | 191 | ||
192 | 192 | ||
193 | /* | 193 | /* |
194 | * MenuApplet Interface | 194 | * MenuApplet Interface |
195 | */ | 195 | */ |
196 | 196 | ||
197 | /** | 197 | /** |
198 | * \class MenuAppletInterface | 198 | * \class MenuAppletInterface |
199 | * \brief Plugins for the Menu Applet/StartMenu | 199 | * \brief Plugins for the Menu Applet/StartMenu |
200 | * | 200 | * |
201 | * You can extend the startmenu by plugins implementing this | 201 | * You can extend the startmenu by plugins implementing this |
202 | * interface. You need to place the plugin in plugins/applets | 202 | * interface. You need to place the plugin in plugins/applets |
203 | * from where they will be loaded. | 203 | * from where they will be loaded. |
204 | * | 204 | * |
205 | * | 205 | * |
206 | */ | 206 | */ |
207 | 207 | ||
208 | /** | 208 | /** |
209 | * \fn QString MenuAppletInterface::name()const | 209 | * \fn QString MenuAppletInterface::name()const |
210 | * \brief Translated name of the Menu Applet | 210 | * \brief Translated name of the Menu Applet |
211 | * | 211 | * |
212 | * Return a translated name using QObject::tr of your plugin | 212 | * Return a translated name using QObject::tr of your plugin |
213 | */ | 213 | */ |
214 | 214 | ||
215 | /** | 215 | /** |
216 | * \fn int MenuAppletInterface::position()const | 216 | * \fn int MenuAppletInterface::position()const |
217 | * \brief the wished position of this applet | 217 | * \brief the wished position of this applet |
218 | * | 218 | * |
219 | * The position where you want to be placed. 0 for the down most | 219 | * The position where you want to be placed. 0 for the down most |
220 | * | 220 | * |
221 | */ | 221 | */ |
222 | 222 | ||
223 | /** | 223 | /** |
224 | * \fn QIconSet MenuAppletInterface::icon()const | 224 | * \fn QIconSet MenuAppletInterface::icon()const |
225 | * \brief return a QIconSet. | 225 | * \brief return a QIconSet. |
226 | * | 226 | * |
227 | * The returned icon set will be shown next | 227 | * The returned icon set will be shown next |
228 | * to text(). | 228 | * to text(). |
229 | * Make use of AppLnk::smallIconSize() | 229 | * Make use of AppLnk::smallIconSize() |
230 | */ | 230 | */ |
231 | 231 | ||
232 | /** | 232 | /** |
233 | * \fn QString MenuAppletInterface::text()const | 233 | * \fn QString MenuAppletInterface::text()const |
234 | * \brief return a Text shown to the user in the menu | 234 | * \brief return a Text shown to the user in the menu |
235 | */ | 235 | */ |
236 | 236 | ||
237 | /** | 237 | /** |
238 | * \fn QPopupMenu* MenuAppletInterface::popup( QWidget* parent)const | 238 | * \fn QPopupMenu* MenuAppletInterface::popup( QWidget* parent)const |
239 | * \brief Provide a SubMenu popup if you want | 239 | * \brief Provide a SubMenu popup if you want |
240 | * | 240 | * |
241 | * You can provide a Submenu popup for your item as well. If you return | 241 | * You can provide a Submenu popup for your item as well. If you return |
242 | * 0 no popup will be shown. | 242 | * 0 no popup will be shown. |
243 | * | 243 | * |
244 | * You can use the QPopupMenu::aboutToShow() signal to be informed before | 244 | * You can use the QPopupMenu::aboutToShow() signal to be informed before |
245 | * showing the popup | 245 | * showing the popup |
246 | * | 246 | * |
247 | * @param parent The parent of the to be created popup. | 247 | * @param parent The parent of the to be created popup. |
248 | * @see QPopupMenu | 248 | * @see QPopupMenu |
249 | */ | 249 | */ |
250 | 250 | ||
251 | 251 | ||
252 | /** | 252 | /** |
253 | * \fn void MenuAppletInterface::activated() | 253 | * \fn void MenuAppletInterface::activated() |
254 | * \brief This method gets called once the user clicked on the item | 254 | * \brief This method gets called once the user clicked on the item |
255 | * | 255 | * |
256 | * This is the way you get informed about user input. Your plugin | 256 | * This is the way you get informed about user input. Your plugin |
257 | * has just been clicked | 257 | * has just been clicked |
258 | */ | 258 | */ |
259 | 259 | ||
260 | /* | 260 | /* |
261 | * StyleInterface | 261 | * StyleInterface |
262 | */ | 262 | */ |
263 | 263 | ||
264 | /** | 264 | /** |
265 | * \class StyleInterface | 265 | * \class StyleInterface |
266 | * \brief StyleInterface base class | 266 | * \brief StyleInterface base class |
267 | * | 267 | * |
268 | * Opie styles should implement StyleExtendedInterface. | 268 | * Opie styles should implement StyleExtendedInterface. |
269 | * StyleInterface is only for compability reasons present and should | 269 | * StyleInterface is only for compability reasons present and should |
270 | * not be used for new styles. | 270 | * not be used for new styles. |
271 | * | 271 | * |
272 | * Styles need to be put into OPIEDIR/plugins/styles | 272 | * Styles need to be put into OPIEDIR/plugins/styles |
273 | */ | 273 | */ |
274 | 274 | ||
275 | 275 | ||
276 | /** | 276 | /** |
277 | * \class StyleExtendedInterface | 277 | * \class StyleExtendedInterface |
278 | * \brief The Plugin Interface for all Opie styles | 278 | * \brief The Plugin Interface for all Opie styles |
279 | * | 279 | * |
280 | * If you want to create a new QStyle for Opie use this class. | 280 | * If you want to create a new QStyle for Opie use this class. |
281 | * | 281 | * |
282 | * key(ushort,ushort,ushort,bool,bool) | 282 | * key(ushort,ushort,ushort,bool,bool) |
283 | */ | 283 | */ |
284 | 284 | ||
285 | /* | 285 | /* |
286 | * Taskbar Applets | 286 | * Taskbar Applets |
287 | */ | 287 | */ |
288 | 288 | ||
289 | 289 | ||
290 | /** | 290 | /** |
291 | * \class TaskbarAppletInterface | 291 | * \class TaskbarAppletInterface |
292 | * | 292 | * |
293 | * This is the base class of all Applets shown in the taskbar | 293 | * This is the base class of all Applets shown in the taskbar |
294 | * An applets need to provide a position and a widget. | 294 | * An applets need to provide a position and a widget. |
295 | * | 295 | * |
296 | * Applets need to be put into OPIEDIR/plugins/applets | 296 | * Applets need to be put into OPIEDIR/plugins/applets |
297 | * | 297 | * |
298 | */ | 298 | */ |
299 | /** | 299 | /** |
300 | * \fn QWidget* TaskbarAppletInterface::applet( QWidget* parent ) | 300 | * \fn QWidget* TaskbarAppletInterface::applet( QWidget* parent ) |
301 | * \brief return the new Applet Widget | 301 | * \brief return the new Applet Widget |
302 | * | 302 | * |
303 | * @param parent The parent of the Applet normally the taskbar | 303 | * @param parent The parent of the Applet normally the taskbar |
304 | */ | 304 | */ |
305 | 305 | ||
306 | /** | 306 | /** |
307 | * \fn int TaskbarAppletInterface::position()const; | 307 | * \fn int TaskbarAppletInterface::position()const; |
308 | * \brief the wished position | 308 | * \brief the wished position |
309 | * | 309 | * |
310 | * From left to right. 0 is left. The clock uses 10 | 310 | * From left to right. 0 is left. The clock uses 10 |
311 | */ | 311 | */ |
312 | 312 | ||
313 | 313 | ||
314 | /** | 314 | /** |
315 | * \class WindowDecorationInterface | 315 | * \class WindowDecorationInterface |
316 | * | 316 | * |
317 | * Interface class for Window Decorations. Yu need to implement | 317 | * Interface class for Window Decorations. Yu need to implement |
318 | * metric and drawing functions. | 318 | * metric and drawing functions. |
319 | */ | 319 | */ |
320 | 320 | ||
321 | /** | 321 | /** |
322 | * \class WindowDecorationInterface::WindowData | 322 | * \class WindowDecorationInterface::WindowData |
323 | * | 323 | * |
324 | * Window informations like the QRect, Palette, Caption | 324 | * Window informations like the QRect, Palette, Caption |
325 | * and flag | 325 | * and flag |
326 | */ | 326 | */ |
327 | 327 | ||
328 | /** | 328 | /** |
329 | * \fn int WindowDecorationInterface::metric(Metric m,const WindowData* ) | 329 | * \fn int WindowDecorationInterface::metric(Metric m,const WindowData* ) |
330 | * | 330 | * |
331 | * Return the width for the item out of Metric. | 331 | * Return the width for the item out of Metric. |
332 | * Normally you will case Metric and default: should call the interface | 332 | * Normally you will case Metric and default: should call the interface |
333 | * method. Also return 0 | 333 | * method. Also return 0 |
334 | */ | 334 | */ |
335 | 335 | ||
336 | /** | 336 | /** |
337 | * \fn void WindowDecorationInterface::drawArea( Area a, QPainter* , const WindowData* )const | 337 | * \fn void WindowDecorationInterface::drawArea( Area a, QPainter* , const WindowData* )const |
338 | * | 338 | * |
339 | * draw the Area specefic in a to the QPainter | 339 | * draw the Area specefic in a to the QPainter |
340 | */ | 340 | */ |
341 | 341 | ||
342 | /** | 342 | /** |
343 | * \fn void WindowDecorationInterface::drawButton(Button b,QPainter*p ,const WindowData* d, int x, int y, int w,int h, QWSButton::State s)const | 343 | * \fn void WindowDecorationInterface::drawButton(Button b,QPainter*p ,const WindowData* d, int x, int y, int w,int h, QWSButton::State s)const |
344 | * | 344 | * |
345 | * @param b The Button to be drawn | 345 | * @param b The Button to be drawn |
346 | * @param p The painter to draw at | 346 | * @param p The painter to draw at |
347 | * @param d The Window Data | 347 | * @param d The Window Data |
348 | * @param x The X position of the button | 348 | * @param x The X position of the button |
349 | * @param y The Y position of the button | 349 | * @param y The Y position of the button |
350 | * @param w The width of the button | 350 | * @param w The width of the button |
351 | * @param h The height of the button | 351 | * @param h The height of the button |
352 | * @param s The state of the button | 352 | * @param s The state of the button |
353 | */ | 353 | */ |
354 | 354 | ||
355 | /** | 355 | /** |
356 | * \fn QRegion WindowDecorationInterface::mask( const WindowData* )const | 356 | * \fn QRegion WindowDecorationInterface::mask( const WindowData* )const |
357 | * | 357 | * |
358 | * The mask of the Decoration. | 358 | * The mask of the Decoration. |
359 | * | 359 | * |
360 | * \code | 360 | * \code |
361 | * int th = metric(TitleHeight,wd); | 361 | * int th = metric(TitleHeight,wd); |
362 | * QRect rect( wd->rect ); | 362 | * QRect rect( wd->rect ); |
363 | * QRect r(rect.left() - metric(LeftBorder,wd), | 363 | * QRect r(rect.left() - metric(LeftBorder,wd), |
364 | * rect.top() - th - metric(TopBorder,wd), | 364 | * rect.top() - th - metric(TopBorder,wd), |
365 | * rect.width() + metric(LeftBorder,wd) + metric(RightBorder,wd), | 365 | * rect.width() + metric(LeftBorder,wd) + metric(RightBorder,wd), |
366 | * rect.height() + th + metric(TopBorder,wd) + metric(BottomBorder,wd)); | 366 | * rect.height() + th + metric(TopBorder,wd) + metric(BottomBorder,wd)); |
367 | * return QRegion(r) - rect; | 367 | * return QRegion(r) - rect; |
368 | * \endcode | 368 | * \endcode |
369 | */ | 369 | */ |
370 | |||
371 | |||
372 | /** | ||
373 | * \class DateFormat | ||
374 | * \brief The format a Date and Time is composed | ||
375 | * | ||
376 | * Define how a Date and Time should be composed | ||
377 | * | ||
378 | * @see TimeString | ||
379 | */ | ||
380 | |||
381 | /** | ||
382 | * \enum DateFormat::Order | ||
383 | * The order of the Day,Month and Year | ||
384 | */ | ||
385 | /** | ||
386 | * \val DateFormat::Order::DayMonthYear | ||
387 | * First the Day, then the Month and the Year | ||
388 | */ | ||
389 | |||
390 | /** | ||
391 | * \val DateFormat::Order::MonthDayYear | ||
392 | * First the Month then Day and Year followed | ||
393 | */ | ||
394 | /** | ||
395 | * \val DateFormat::Order::YearMonthDay | ||
396 | * Year Month and then the Day | ||
397 | */ | ||
398 | |||
399 | /** | ||
400 | * \fn QString DateFormat::toNumberString()const | ||
401 | * Return the Order of Days as string (M/D/Y) in example | ||
402 | * this string can be shown to the user. | ||
403 | * It will extract three bits at a time and compose | ||
404 | * a string | ||
405 | */ | ||
406 | |||
407 | /** | ||
408 | * \fn QString DateFormat::toWordString()const | ||
409 | * Return the DateFormat as written words | ||
410 | * | ||
411 | */ | ||
412 | |||
413 | /** | ||
414 | * \fn DateFormat::DateFormat(QChar s,Order or) | ||
415 | * A Constructor. | ||
416 | * @param s The seperator for the short representation. As used by toNumberString | ||
417 | * @param or The order used for short and long dates | ||
418 | */ | ||
419 | |||
420 | /** | ||
421 | * \fn DateFormat::DateFormat(QChar s,Order so,Order lo) | ||
422 | * | ||
423 | * A different Constructor with different long and short representation | ||
424 | * @param s The seperator | ||
425 | * @param so The short order representation | ||
426 | * @param lo The long order representation | ||
427 | */ | ||
428 | |||
429 | |||
430 | /** | ||
431 | * \fn DateFormat::DateFormat(const DateFormat&) | ||
432 | * Copy c'tor | ||
433 | * | ||
434 | */ | ||
435 | |||
436 | /** | ||
437 | * \enum DateFormat::Verbosity | ||
438 | * The verbosity as used by DateFormat::numberDate() and DateFormat::wordDate() | ||
439 | * | ||
440 | * \enum val shortNumber Express the Year as 04 | ||
441 | * \enum val longNumber Express the Year as 2004 | ||
442 | * \enum val showWeekDay Use week day names | ||
443 | * \enum val longWord Use long word. If not set the week day will be stripped to the first three characters | ||
444 | * | ||
445 | * | ||
446 | * @see DateFormat::numberDate | ||
447 | * @see DateFormat::wordDate | ||
448 | */ | ||
449 | |||
450 | /** | ||
451 | * \fn QString DateFormat::numberDate(const QDate& d,int v)const | ||
452 | * | ||
453 | * Compose the QDate to a QString using the shortOrder() and | ||
454 | * the verbosity. The verbosity is only used to see if the | ||
455 | * year should be four positions or two positions wide. | ||
456 | * | ||
457 | * @param d The QDate to be expressed as string | ||
458 | * @param v Only DateFormat::Verbosity::shortNumber or | ||
459 | * DateFormat::Verbosity::longNumber is used. | ||
460 | * Use this to say if the year should be two or four | ||
461 | * positions wide | ||
462 | * | ||
463 | * @see DateFormat::wordDate() | ||
464 | */ | ||
465 | |||
466 | /** | ||
467 | * \fn QString DateFormat::wordDate(const QDate& d,int v )const | ||
468 | * Compose the QDate to a QString using the longOrder() options. | ||
469 | * The difference to numberDate() is the length of the resulting | ||
470 | * string. Weekday- and Monthnames are expressed as words as opposed to digits. | ||
471 | * | ||
472 | * | ||
473 | * @param d The Date to be used | ||
474 | * @param v The verbosity | ||
475 | */ | ||
476 | |||
477 | /** | ||
478 | * \fn void DateFormat::load(QDataStream&) | ||
479 | * load from the QDateStream. And set the values | ||
480 | * internally | ||
481 | */ | ||
482 | |||
483 | /** | ||
484 | * \fn void DateFormat::save(QDateStream&)const | ||
485 | * save this DateFormat into the QDataStream | ||
486 | */ | ||
487 | |||
488 | /** | ||
489 | *\fn QChar DateFormat::seperator()const | ||
490 | * The seperator used for the numberString() | ||
491 | */ | ||
492 | /** | ||
493 | * \fn DateFormat::Order DateFormat::shortOrder()const | ||
494 | * Return the DateFormat::Order for the shortOrder which will be used by numberString | ||
495 | */ | ||
496 | /** | ||
497 | * \fn DateFormat::Order DateFormat::longOrder()const | ||
498 | * Return the DateFormat::Order for the longOrder which will be used by the wordString | ||
499 | */ | ||
500 | |||
501 | /** | ||
502 | * \class TimeString | ||
503 | * \brief A frontend to DateFormat | ||
504 | * | ||
505 | * A utility class to use DateFormat more easily | ||
506 | * @todo For ODP add QDateTime and QTime operations honoring system settings | ||
507 | */ | ||
508 | |||
509 | /** | ||
510 | * \fn QString TimeString::shortDate(const QDate& d) | ||
511 | * Call the overloaded function with currentDateFormat() | ||
512 | * | ||
513 | * @param d The QDate to be transformed | ||
514 | * @see TimeString::shortDate(const QDate& d,DateFormat) | ||
515 | */ | ||
516 | /** | ||
517 | * \fn QString TimeString::dateString(const QDate& d); | ||
518 | * This function calls the overloaded function with currentDateFormat() | ||
519 | * | ||
520 | * @param d The QDate to be used | ||
521 | * @see TimeString::dateString(const QDate& d,DateFormat); | ||
522 | */ | ||
523 | /** | ||
524 | * \fn QString TimeString::longDateString(const QDate& d); | ||
525 | * | ||
526 | * This functions calls the olverloaded function with currentDateFormat() | ||
527 | * | ||
528 | * @param d The QDate to be used | ||
529 | * @see TimeString::longDateString(const QDate& d,DateFormat); | ||
530 | */ | ||
531 | /** | ||
532 | * \fn QString TimeString::dateString(const QDateTime&,bool,bool); | ||
533 | * @internal | ||
534 | */ | ||
535 | /** | ||
536 | * \fn QString TimeString::dateString(const QDateTime& t,bool) | ||
537 | * Do not use they do not honor system wide AMPM settings. | ||
538 | * Also | ||
539 | * | ||
540 | * @see numberDateString | ||
541 | * @see longNumberDateString | ||
542 | */ | ||
543 | /** | ||
544 | * \fn QString TimeString::numberDateString(const QDate& d, DateFormat f ) | ||
545 | * Return the date as String in number coding (DD/MM/YY) depending on the | ||
546 | * date format | ||
547 | * | ||
548 | * @param d The QDate to be used | ||
549 | * @param f The DateFormat to be used | ||
550 | */ | ||
551 | /** | ||
552 | * \fn QString TimeString::numberDateString(const QDate& d) | ||
553 | * This is an overloaded function and uses the currentDateFormat() | ||
554 | * of the system | ||
555 | * | ||
556 | * @see currentDateFormat() | ||
557 | * @param d The QDate to be used | ||
558 | */ | ||
559 | /** | ||
560 | * \fn QString TimeString::longNumberDateString(const QDate& d, DateFormat f ) | ||
561 | * Return the date as String in number coding (DD/MM/YYYY) depending on the | ||
562 | * date format. This uses the DateFormat::longNumber verbosity on the DateFormat::numberDate | ||
563 | * method | ||
564 | * | ||
565 | * @param d The QDate to be used | ||
566 | * @param f The DateFormat to be used | ||
567 | */ | ||
568 | /** | ||
569 | * \fn QString TimeString::longNumberDateString(const QDate& d) | ||
570 | * This is an overloaded function and uses the currentDateFormat() | ||
571 | * of the system. | ||
572 | * | ||
573 | * | ||
574 | * @see currentDateFormat() | ||
575 | * @see longNumberDateString(const QDate&,DateFormat) | ||
576 | * @param d The QDate to be used | ||
577 | */ | ||
578 | |||
579 | |||
580 | /** | ||
581 | * \fn QString TimeString::shortDate(const QDate& d,DateFormat f) | ||
582 | * Calls DateFormat::wordDate with d | ||
583 | * | ||
584 | * Example: '20 Feb 04' | ||
585 | * | ||
586 | * | ||
587 | * | ||
588 | * @param d The QDate used | ||
589 | * @param f DateFormat which will be used for composing | ||
590 | * @todo Make naming consistent with the two other functions calling wordDate | ||
591 | */ | ||
592 | |||
593 | /** | ||
594 | * \fn QString TimeString::dateString(const QDate& d,DateFormat f ) | ||
595 | * Calls and translates DateFormat::wordDate with d and | ||
596 | * DateFormat::longNumber|DateFormat::longWord | ||
597 | * This means we will translate the month name and have a 4 digit year (2004) | ||
598 | * | ||
599 | * Example: '20 Feb 2004' | ||
600 | * | ||
601 | * @param d The QDate. | ||
602 | * @param f The DateFormat which will be called | ||
603 | */ | ||
604 | |||
605 | /** | ||
606 | * \fn QSrring TimeString::longDateString(const QDate& d, DateFormat f ) | ||
607 | * Calls and translates DateFormat::wordDate with DateFormat::showWeekDay|DateFormat::longNumber|DateFormat::longWord. | ||
608 | * This means you will have a string with the week day name, monthname and a four digit year. | ||
609 | * | ||
610 | * Example: 'Fr, 20 Feb 2004' | ||
611 | * | ||
612 | * @param d The QDate | ||
613 | * | ||
614 | */ | ||
615 | |||
616 | /** | ||
617 | * \fn DateFormat currentDateFormat() | ||
618 | * Return the System DateFormat | ||
619 | */ | ||
diff --git a/library/timestring.cpp b/library/timestring.cpp index 8f60b72..2fd0191 100644 --- a/library/timestring.cpp +++ b/library/timestring.cpp | |||
@@ -1,365 +1,365 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include "timestring.h" | 21 | #include "timestring.h" |
22 | #include <qobject.h> | 22 | #include <qobject.h> |
23 | #include <qpe/qpeapplication.h> //for qApp | 23 | #include <qpe/qpeapplication.h> //for qApp |
24 | #include "config.h" | 24 | #include "config.h" |
25 | 25 | ||
26 | 26 | ||
27 | class TimeStringFormatKeeper : public QObject | 27 | class TimeStringFormatKeeper : public QObject |
28 | { | 28 | { |
29 | Q_OBJECT | 29 | Q_OBJECT |
30 | public: | 30 | public: |
31 | static DateFormat currentFormat() | 31 | static DateFormat currentFormat() |
32 | { | 32 | { |
33 | if ( !self ) | 33 | if ( !self ) |
34 | self = new TimeStringFormatKeeper; | 34 | self = new TimeStringFormatKeeper; |
35 | return self->format; | 35 | return self->format; |
36 | } | 36 | } |
37 | private slots: | 37 | private slots: |
38 | void formatChanged( DateFormat f ) | 38 | void formatChanged( DateFormat f ) |
39 | { | 39 | { |
40 | format = f; | 40 | format = f; |
41 | } | 41 | } |
42 | private: | 42 | private: |
43 | static TimeStringFormatKeeper *self; | 43 | static TimeStringFormatKeeper *self; |
44 | DateFormat format; | 44 | DateFormat format; |
45 | 45 | ||
46 | TimeStringFormatKeeper() | 46 | TimeStringFormatKeeper() |
47 | : QObject( qApp ) | 47 | : QObject( qApp ) |
48 | { | 48 | { |
49 | Config config("qpe"); | 49 | Config config("qpe"); |
50 | config.setGroup( "Date" ); | 50 | config.setGroup( "Date" ); |
51 | format = DateFormat(QChar(config.readEntry("Separator", "/")[0]), | 51 | format = DateFormat(QChar(config.readEntry("Separator", "/")[0]), |
52 | (DateFormat::Order)config .readNumEntry("ShortOrder", DateFormat::DayMonthYear), | 52 | (DateFormat::Order)config .readNumEntry("ShortOrder", DateFormat::DayMonthYear), |
53 | (DateFormat::Order)config.readNumEntry("LongOrder", DateFormat::DayMonthYear)); | 53 | (DateFormat::Order)config.readNumEntry("LongOrder", DateFormat::DayMonthYear)); |
54 | 54 | ||
55 | connect( qApp, SIGNAL( dateFormatChanged(DateFormat) ), | 55 | connect( qApp, SIGNAL( dateFormatChanged(DateFormat) ), |
56 | this, SLOT( formatChanged( DateFormat ) ) ); | 56 | this, SLOT( formatChanged( DateFormat ) ) ); |
57 | } | 57 | } |
58 | }; | 58 | }; |
59 | 59 | ||
60 | TimeStringFormatKeeper *TimeStringFormatKeeper::self = 0; | 60 | TimeStringFormatKeeper *TimeStringFormatKeeper::self = 0; |
61 | 61 | ||
62 | QString DateFormat::toNumberString() const | 62 | QString DateFormat::toNumberString() const |
63 | { | 63 | { |
64 | QString buf = ""; | 64 | QString buf = ""; |
65 | // for each part of the order | 65 | // for each part of the order |
66 | for (int i = 0; i < 3; i++) { | 66 | for (int i = 0; i < 3; i++) { |
67 | // switch on the relavent 3 bits. | 67 | // switch on the relavent 3 bits. |
68 | switch((_shortOrder >> (i * 3)) & 0x0007) { | 68 | switch((_shortOrder >> (i * 3)) & 0x0007) { |
69 | case 0x0001: | 69 | case 0x0001: |
70 | buf += QObject::tr( "D" ); | 70 | buf += QObject::tr( "D" , "Shortcut for Day"); |
71 | break; | 71 | break; |
72 | case 0x0002: | 72 | case 0x0002: |
73 | buf += QObject::tr( "M" ); | 73 | buf += QObject::tr( "M", "Shortcur for Month" ); |
74 | break; | 74 | break; |
75 | case 0x0004: | 75 | case 0x0004: |
76 | buf += QObject::tr( "Y" ); | 76 | buf += QObject::tr( "Y" ); |
77 | break; | 77 | break; |
78 | } | 78 | } |
79 | if (i < 2) | 79 | if (i < 2) |
80 | buf += _shortSeparator; | 80 | buf += _shortSeparator; |
81 | } | 81 | } |
82 | return buf; | 82 | return buf; |
83 | } | 83 | } |
84 | 84 | ||
85 | QString DateFormat::toWordString() const | 85 | QString DateFormat::toWordString() const |
86 | { | 86 | { |
87 | QString buf = ""; | 87 | QString buf = ""; |
88 | // for each part of the order | 88 | // for each part of the order |
89 | for (int i = 0; i < 3; i++) { | 89 | for (int i = 0; i < 3; i++) { |
90 | // switch on the relavent 3 bits. | 90 | // switch on the relavent 3 bits. |
91 | switch((_longOrder >> (i * 3)) & 0x0007) { | 91 | switch((_longOrder >> (i * 3)) & 0x0007) { |
92 | case 0x0001: | 92 | case 0x0001: |
93 | buf += QObject::tr( "day" ); | 93 | buf += QObject::tr( "day" ); |
94 | if (i < 2) { | 94 | if (i < 2) { |
95 | if ((_shortOrder << ((i+1) * 3)) & 0x0007) | 95 | if ((_shortOrder << ((i+1) * 3)) & 0x0007) |
96 | buf += ", "; | 96 | buf += ", "; |
97 | else | 97 | else |
98 | buf += " "; | 98 | buf += " "; |
99 | } | 99 | } |
100 | break; | 100 | break; |
101 | case 0x0002: | 101 | case 0x0002: |
102 | buf += QObject::tr( "month" ); | 102 | buf += QObject::tr( "month" ); |
103 | if (i < 2) | 103 | if (i < 2) |
104 | buf += " "; | 104 | buf += " "; |
105 | break; | 105 | break; |
106 | case 0x0004: | 106 | case 0x0004: |
107 | buf += QObject::tr( "year" ); | 107 | buf += QObject::tr( "year" ); |
108 | if (i < 2) | 108 | if (i < 2) |
109 | buf += ", "; | 109 | buf += ", "; |
110 | break; | 110 | break; |
111 | } | 111 | } |
112 | } | 112 | } |
113 | return buf; | 113 | return buf; |
114 | } | 114 | } |
115 | 115 | ||
116 | QString DateFormat::numberDate(const QDate &d, int v) const | 116 | QString DateFormat::numberDate(const QDate &d, int v) const |
117 | { | 117 | { |
118 | QString buf = ""; | 118 | QString buf = ""; |
119 | 119 | ||
120 | int pad = 2; | 120 | int pad = 2; |
121 | 121 | ||
122 | // for each part of the order | 122 | // for each part of the order |
123 | for (int i = 0; i < 3; i++) { | 123 | for (int i = 0; i < 3; i++) { |
124 | // switch on the relavent 3 bits. | 124 | // switch on the relavent 3 bits. |
125 | switch((_shortOrder >> (i * 3)) & 0x0007) { | 125 | switch((_shortOrder >> (i * 3)) & 0x0007) { |
126 | case 0x0001: | 126 | case 0x0001: |
127 | if (pad==2) buf += QString().sprintf("%02d",d.day()); | 127 | if (pad==2) buf += QString().sprintf("%02d",d.day()); |
128 | else buf += QString().sprintf("%d",d.day()); | 128 | else buf += QString().sprintf("%d",d.day()); |
129 | break; | 129 | break; |
130 | case 0x0002: | 130 | case 0x0002: |
131 | if (i==0) { // no padding with only MM/DD/YY format | 131 | if (i==0) { // no padding with only MM/DD/YY format |
132 | pad=0; | 132 | pad=0; |
133 | } | 133 | } |
134 | if (pad==2) buf += QString().sprintf("%02d",d.month()); | 134 | if (pad==2) buf += QString().sprintf("%02d",d.month()); |
135 | else buf += QString().sprintf("%d",d.month()); | 135 | else buf += QString().sprintf("%d",d.month()); |
136 | break; | 136 | break; |
137 | case 0x0004: | 137 | case 0x0004: |
138 | { | 138 | { |
139 | int year = d.year(); | 139 | int year = d.year(); |
140 | if (!(v & longNumber)) | 140 | if (!(v & longNumber)) |
141 | year = year % 100; | 141 | year = year % 100; |
142 | buf += QString().sprintf("%02d",year); | 142 | buf += QString().sprintf("%02d",year); |
143 | } | 143 | } |
144 | break; | 144 | break; |
145 | } | 145 | } |
146 | if (i < 2) | 146 | if (i < 2) |
147 | buf += _shortSeparator; | 147 | buf += _shortSeparator; |
148 | } | 148 | } |
149 | return buf; | 149 | return buf; |
150 | } | 150 | } |
151 | 151 | ||
152 | QString DateFormat::wordDate(const QDate &d, int v) const | 152 | QString DateFormat::wordDate(const QDate &d, int v) const |
153 | { | 153 | { |
154 | QString buf = ""; | 154 | QString buf = ""; |
155 | // for each part of the order | 155 | // for each part of the order |
156 | if (v & showWeekDay) { | 156 | if (v & showWeekDay) { |
157 | QString weekDay = d.dayName(d.dayOfWeek()); | 157 | QString weekDay = d.dayName(d.dayOfWeek()); |
158 | if (!(v & longWord)) { | 158 | if (!(v & longWord)) { |
159 | weekDay = weekDay.left(3); | 159 | weekDay = weekDay.left(3); |
160 | } | 160 | } |
161 | buf += weekDay; | 161 | buf += weekDay; |
162 | if ((_longOrder & 0x0007) == 0x0002) | 162 | if ((_longOrder & 0x0007) == 0x0002) |
163 | buf += ' '; | 163 | buf += ' '; |
164 | else | 164 | else |
165 | buf += ", "; | 165 | buf += ", "; |
166 | } | 166 | } |
167 | 167 | ||
168 | for (int i = 0; i < 3; i++) { | 168 | for (int i = 0; i < 3; i++) { |
169 | // switch on the relavent 3 bits. | 169 | // switch on the relavent 3 bits. |
170 | switch((_longOrder >> (i * 3)) & 0x0007) { | 170 | switch((_longOrder >> (i * 3)) & 0x0007) { |
171 | case 0x0001: | 171 | case 0x0001: |
172 | if (i==1) { | 172 | if (i==1) { |
173 | buf += QString().sprintf("%02d, ",d.day()); | 173 | buf += QString().sprintf("%02d, ",d.day()); |
174 | } else { | 174 | } else { |
175 | buf += QString().sprintf("%2d",d.day()); | 175 | buf += QString().sprintf("%2d",d.day()); |
176 | if (separator()=='.') // 2002/1/11 | 176 | if (separator()=='.') // 2002/1/11 |
177 | buf += ". "; | 177 | buf += ". "; |
178 | else | 178 | else |
179 | buf += " "; | 179 | buf += " "; |
180 | } | 180 | } |
181 | break; | 181 | break; |
182 | case 0x0002: | 182 | case 0x0002: |
183 | { | 183 | { |
184 | QString monthName = d.monthName(d.month()); | 184 | QString monthName = d.monthName(d.month()); |
185 | if (!(v & longWord)) { | 185 | if (!(v & longWord)) { |
186 | monthName = monthName.left(3); | 186 | monthName = monthName.left(3); |
187 | } | 187 | } |
188 | buf += monthName; | 188 | buf += monthName; |
189 | } | 189 | } |
190 | if (i < 2) | 190 | if (i < 2) |
191 | buf += " "; | 191 | buf += " "; |
192 | break; | 192 | break; |
193 | case 0x0004: | 193 | case 0x0004: |
194 | { | 194 | { |
195 | int year = d.year(); | 195 | int year = d.year(); |
196 | if (!(v & longNumber)) | 196 | if (!(v & longNumber)) |
197 | year = year % 100; | 197 | year = year % 100; |
198 | 198 | ||
199 | if (year < 10) | 199 | if (year < 10) |
200 | buf += "0"; | 200 | buf += "0"; |
201 | 201 | ||
202 | buf += QString::number(year); | 202 | buf += QString::number(year); |
203 | } | 203 | } |
204 | if (i < 2) | 204 | if (i < 2) |
205 | buf += ", "; | 205 | buf += ", "; |
206 | break; | 206 | break; |
207 | } | 207 | } |
208 | } | 208 | } |
209 | return buf; | 209 | return buf; |
210 | } | 210 | } |
211 | 211 | ||
212 | #ifndef QT_NO_DATASTREAM | 212 | #ifndef QT_NO_DATASTREAM |
213 | void DateFormat::save(QDataStream &d) const | 213 | void DateFormat::save(QDataStream &d) const |
214 | { | 214 | { |
215 | d << _shortSeparator.unicode(); | 215 | d << _shortSeparator.unicode(); |
216 | uint v= _shortOrder; | 216 | uint v= _shortOrder; |
217 | d << v; | 217 | d << v; |
218 | v = _longOrder; | 218 | v = _longOrder; |
219 | d << v; | 219 | d << v; |
220 | } | 220 | } |
221 | 221 | ||
222 | void DateFormat::load(QDataStream &d) | 222 | void DateFormat::load(QDataStream &d) |
223 | { | 223 | { |
224 | ushort value; | 224 | ushort value; |
225 | d >> value; | 225 | d >> value; |
226 | _shortSeparator = QChar(value); | 226 | _shortSeparator = QChar(value); |
227 | uint v = 0; | 227 | uint v = 0; |
228 | d >> v; | 228 | d >> v; |
229 | _shortOrder = (Order)v; | 229 | _shortOrder = (Order)v; |
230 | v = 0; | 230 | v = 0; |
231 | d >> v; | 231 | d >> v; |
232 | _longOrder = (Order)v; | 232 | _longOrder = (Order)v; |
233 | } | 233 | } |
234 | 234 | ||
235 | QDataStream &operator<<(QDataStream &s, const DateFormat&df) | 235 | QDataStream &operator<<(QDataStream &s, const DateFormat&df) |
236 | { | 236 | { |
237 | df.save(s); | 237 | df.save(s); |
238 | return s; | 238 | return s; |
239 | } | 239 | } |
240 | QDataStream &operator>>(QDataStream &s, DateFormat&df) | 240 | QDataStream &operator>>(QDataStream &s, DateFormat&df) |
241 | { | 241 | { |
242 | df.load(s); | 242 | df.load(s); |
243 | return s; | 243 | return s; |
244 | } | 244 | } |
245 | #endif | 245 | #endif |
246 | 246 | ||
247 | QString TimeString::shortDate( const QDate &d, DateFormat dtf ) | 247 | QString TimeString::shortDate( const QDate &d, DateFormat dtf ) |
248 | { | 248 | { |
249 | return dtf.wordDate(d); | 249 | return dtf.wordDate(d); |
250 | } | 250 | } |
251 | 251 | ||
252 | QString TimeString::dateString( const QDate &d, DateFormat dtf ) | 252 | QString TimeString::dateString( const QDate &d, DateFormat dtf ) |
253 | { | 253 | { |
254 | return QObject::tr( dtf.wordDate(d, DateFormat::longNumber | DateFormat::longWord) ); | 254 | return QObject::tr( dtf.wordDate(d, DateFormat::longNumber | DateFormat::longWord) ); |
255 | } | 255 | } |
256 | 256 | ||
257 | 257 | ||
258 | QString TimeString::longDateString( const QDate &d, DateFormat dtf ) | 258 | QString TimeString::longDateString( const QDate &d, DateFormat dtf ) |
259 | { | 259 | { |
260 | return QObject::tr( dtf.wordDate(d, DateFormat::showWeekDay | DateFormat::longNumber | 260 | return QObject::tr( dtf.wordDate(d, DateFormat::showWeekDay | DateFormat::longNumber |
261 | | DateFormat::longWord) ); | 261 | | DateFormat::longWord) ); |
262 | } | 262 | } |
263 | 263 | ||
264 | DateFormat TimeString::currentDateFormat() | 264 | DateFormat TimeString::currentDateFormat() |
265 | { | 265 | { |
266 | return TimeStringFormatKeeper::currentFormat(); | 266 | return TimeStringFormatKeeper::currentFormat(); |
267 | } | 267 | } |
268 | 268 | ||
269 | 269 | ||
270 | QString TimeString::dateString( const QDateTime &dt, bool ampm, bool seconds, DateFormat dtf ) | 270 | QString TimeString::dateString( const QDateTime &dt, bool ampm, bool seconds, DateFormat dtf ) |
271 | { | 271 | { |
272 | const QDate& d = dt.date(); | 272 | const QDate& d = dt.date(); |
273 | const QTime& t = dt.time(); | 273 | const QTime& t = dt.time(); |
274 | 274 | ||
275 | // based on QDateTime::toString() | 275 | // based on QDateTime::toString() |
276 | QString buf = timeString(t,ampm,seconds); | 276 | QString buf = timeString(t,ampm,seconds); |
277 | buf += " "; | 277 | buf += " "; |
278 | buf += longDateString( d, dtf ); | 278 | buf += longDateString( d, dtf ); |
279 | 279 | ||
280 | return buf; | 280 | return buf; |
281 | } | 281 | } |
282 | 282 | ||
283 | QString TimeString::timeString( const QTime &t, bool ampm, bool seconds ) | 283 | QString TimeString::timeString( const QTime &t, bool ampm, bool seconds ) |
284 | { | 284 | { |
285 | if ( !ampm ) { | 285 | if ( !ampm ) { |
286 | if ( seconds ) | 286 | if ( seconds ) |
287 | return t.toString(); | 287 | return t.toString(); |
288 | QString r = QString::number(t.hour()); | 288 | QString r = QString::number(t.hour()); |
289 | if ( t.hour() < 10 ) r.prepend( "0" ); | 289 | if ( t.hour() < 10 ) r.prepend( "0" ); |
290 | r.append( ":" ); | 290 | r.append( ":" ); |
291 | if ( t.minute() < 10 ) r.append( "0" ); | 291 | if ( t.minute() < 10 ) r.append( "0" ); |
292 | r.append(QString::number(t.minute())); | 292 | r.append(QString::number(t.minute())); |
293 | return r; | 293 | return r; |
294 | } | 294 | } |
295 | // ### else the hard case that should disappear in Qt 3.0 | 295 | // ### else the hard case that should disappear in Qt 3.0 |
296 | QString argString = seconds ? "%4:%5:%6 %7" : "%4:%5 %7"; | 296 | QString argString = seconds ? "%4:%5:%6 %7" : "%4:%5 %7"; |
297 | int hour = t.hour(); | 297 | int hour = t.hour(); |
298 | QString strMin = QString::number( t.minute() ); | 298 | QString strMin = QString::number( t.minute() ); |
299 | QString strSec = QString::number( t.second() ); | 299 | QString strSec = QString::number( t.second() ); |
300 | if ( hour > 12 ) | 300 | if ( hour > 12 ) |
301 | argString = argString.arg( hour - 12, 2 ); | 301 | argString = argString.arg( hour - 12, 2 ); |
302 | else { | 302 | else { |
303 | if ( hour == 0 ) | 303 | if ( hour == 0 ) |
304 | argString = argString.arg( 12 ); | 304 | argString = argString.arg( 12 ); |
305 | else | 305 | else |
306 | argString = argString.arg( hour, 2 ); | 306 | argString = argString.arg( hour, 2 ); |
307 | } | 307 | } |
308 | if ( t.minute() < 10 ) | 308 | if ( t.minute() < 10 ) |
309 | strMin.prepend( "0" ); | 309 | strMin.prepend( "0" ); |
310 | if ( t.second() < 10 ) | 310 | if ( t.second() < 10 ) |
311 | strSec.prepend( "0" ); | 311 | strSec.prepend( "0" ); |
312 | argString = argString.arg( strMin ); | 312 | argString = argString.arg( strMin ); |
313 | if ( seconds ) | 313 | if ( seconds ) |
314 | argString = argString.arg( strSec ); | 314 | argString = argString.arg( strSec ); |
315 | if ( hour >= 12 ) | 315 | if ( hour >= 12 ) |
316 | argString = argString.arg( QObject::tr("PM") ); | 316 | argString = argString.arg( QObject::tr("PM") ); |
317 | else | 317 | else |
318 | argString = argString.arg( QObject::tr("AM") ); | 318 | argString = argString.arg( QObject::tr("AM") ); |
319 | return argString; | 319 | return argString; |
320 | } | 320 | } |
321 | 321 | ||
322 | QString TimeString::shortTime( bool ampm, bool seconds ) | 322 | QString TimeString::shortTime( bool ampm, bool seconds ) |
323 | { | 323 | { |
324 | static const char* const day[] = { | 324 | static const char* const day[] = { |
325 | QT_TRANSLATE_NOOP( "QObject", "Mon" ), | 325 | QT_TRANSLATE_NOOP( "QObject", "Mon" ), |
326 | QT_TRANSLATE_NOOP( "QObject", "Tue" ), | 326 | QT_TRANSLATE_NOOP( "QObject", "Tue" ), |
327 | QT_TRANSLATE_NOOP( "QObject", "Wed" ), | 327 | QT_TRANSLATE_NOOP( "QObject", "Wed" ), |
328 | QT_TRANSLATE_NOOP( "QObject", "Thu" ), | 328 | QT_TRANSLATE_NOOP( "QObject", "Thu" ), |
329 | QT_TRANSLATE_NOOP( "QObject", "Fri" ), | 329 | QT_TRANSLATE_NOOP( "QObject", "Fri" ), |
330 | QT_TRANSLATE_NOOP( "QObject", "Sat" ), | 330 | QT_TRANSLATE_NOOP( "QObject", "Sat" ), |
331 | QT_TRANSLATE_NOOP( "QObject", "Sun" ) | 331 | QT_TRANSLATE_NOOP( "QObject", "Sun" ) |
332 | }; | 332 | }; |
333 | // just create a shorter time String | 333 | // just create a shorter time String |
334 | QDateTime dtTmp = QDateTime::currentDateTime(); | 334 | QDateTime dtTmp = QDateTime::currentDateTime(); |
335 | QString strTime; | 335 | QString strTime; |
336 | strTime = QObject::tr( day[dtTmp.date().dayOfWeek()-1] ) + " " + | 336 | strTime = QObject::tr( day[dtTmp.date().dayOfWeek()-1] ) + " " + |
337 | timeString( dtTmp.time(), ampm, seconds ); | 337 | timeString( dtTmp.time(), ampm, seconds ); |
338 | return strTime; | 338 | return strTime; |
339 | } | 339 | } |
340 | 340 | ||
341 | QString TimeString::dateString( const QDateTime &t, bool ampm ) | 341 | QString TimeString::dateString( const QDateTime &t, bool ampm ) |
342 | { | 342 | { |
343 | return dateString(t,ampm,FALSE); | 343 | return dateString(t,ampm,FALSE); |
344 | } | 344 | } |
345 | 345 | ||
346 | QString TimeString::timeString( const QTime &t, bool ampm) | 346 | QString TimeString::timeString( const QTime &t, bool ampm) |
347 | { | 347 | { |
348 | return timeString(t,ampm,FALSE); | 348 | return timeString(t,ampm,FALSE); |
349 | } | 349 | } |
350 | 350 | ||
351 | QString TimeString::shortTime( bool ampm ) | 351 | QString TimeString::shortTime( bool ampm ) |
352 | { | 352 | { |
353 | return shortTime(ampm,FALSE); | 353 | return shortTime(ampm,FALSE); |
354 | } | 354 | } |
355 | 355 | ||
356 | QString TimeString::numberDateString( const QDate &d, DateFormat dtf ) | 356 | QString TimeString::numberDateString( const QDate &d, DateFormat dtf ) |
357 | { | 357 | { |
358 | return dtf.numberDate(d); | 358 | return dtf.numberDate(d); |
359 | } | 359 | } |
360 | QString TimeString::longNumberDateString( const QDate &d, DateFormat dtf ) | 360 | QString TimeString::longNumberDateString( const QDate &d, DateFormat dtf ) |
361 | { | 361 | { |
362 | return dtf.numberDate(d,DateFormat::longNumber); | 362 | return dtf.numberDate(d,DateFormat::longNumber); |
363 | } | 363 | } |
364 | 364 | ||
365 | #include "timestring.moc" | 365 | #include "timestring.moc" |
diff --git a/library/timestring.h b/library/timestring.h index 0335715..875c8bf 100644 --- a/library/timestring.h +++ b/library/timestring.h | |||
@@ -1,140 +1,150 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #ifndef _TIMESTRING_H_ | 21 | #ifndef _TIMESTRING_H_ |
22 | #define _TIMESTRING_H_ | 22 | #define _TIMESTRING_H_ |
23 | #include <qdatetime.h> | 23 | #include <qdatetime.h> |
24 | #include <qstring.h> | 24 | #include <qstring.h> |
25 | 25 | ||
26 | #if (QT_VERSION-0 >= 0x030000) | 26 | #if (QT_VERSION-0 >= 0x030000) |
27 | #define DateFormat QPEDateFormat | 27 | #define DateFormat QPEDateFormat |
28 | #endif | 28 | #endif |
29 | 29 | ||
30 | // return a string with the time based on whether or not you want | 30 | // return a string with the time based on whether or not you want |
31 | // you want it in 12 hour form. if ampm is true, then return | 31 | // you want it in 12 hour form. if ampm is true, then return |
32 | // it in 12 hour (am/pm) form otherwise return it in 24 hour form | 32 | // it in 12 hour (am/pm) form otherwise return it in 24 hour form |
33 | // in theory Qt 3,0 handles this better (hopefully obsoleteing this) | 33 | // in theory Qt 3,0 handles this better (hopefully obsoleteing this) |
34 | class DateFormat | 34 | class DateFormat |
35 | { | 35 | { |
36 | public: | 36 | public: |
37 | // date format type 001,010,100 = day month year | 37 | // date format type 001,010,100 = day month year |
38 | enum Order { | 38 | enum Order { |
39 | DayMonthYear = 0x0111, // 0x001 + 0x010(0x2 << 3) + 0x100(0x4 << 3) | 39 | DayMonthYear = 0x0111, // 0x001 + 0x010(0x2 << 3) + 0x100(0x4 << 3) |
40 | MonthDayYear = 0x010A, | 40 | MonthDayYear = 0x010A, |
41 | YearMonthDay = 0x0054 | 41 | YearMonthDay = 0x0054 |
42 | }; | 42 | }; |
43 | 43 | ||
44 | DateFormat(QChar s = '/', Order so = MonthDayYear) : _shortOrder(so), | 44 | DateFormat(QChar s = '/', Order so = MonthDayYear) : _shortOrder(so), |
45 | _longOrder(so), _shortSeparator(s) { } | 45 | _longOrder(so), _shortSeparator(s) { } |
46 | DateFormat(QChar s, Order so, Order lo) : _shortOrder(so), | 46 | DateFormat(QChar s, Order so, Order lo) : _shortOrder(so), |
47 | _longOrder(lo), _shortSeparator(s) { } | 47 | _longOrder(lo), _shortSeparator(s) { } |
48 | DateFormat(const DateFormat &o) : _shortOrder(o._shortOrder), | 48 | DateFormat(const DateFormat &o) : _shortOrder(o._shortOrder), |
49 | _longOrder(o._longOrder), _shortSeparator(o._shortSeparator) { } | 49 | _longOrder(o._longOrder), _shortSeparator(o._shortSeparator) { } |
50 | 50 | ||
51 | bool operator==(const DateFormat &o) | 51 | bool operator==(const DateFormat &o) |
52 | { | 52 | { |
53 | if (o._shortOrder == _shortOrder && o._longOrder == _longOrder && | 53 | if (o._shortOrder == _shortOrder && o._longOrder == _longOrder && |
54 | o._shortSeparator == _shortSeparator) | 54 | o._shortSeparator == _shortSeparator) |
55 | return TRUE; | 55 | return TRUE; |
56 | return FALSE; | 56 | return FALSE; |
57 | } | 57 | } |
58 | 58 | ||
59 | // verbosity specifiers | 59 | // verbosity specifiers |
60 | enum Verbosity { | 60 | enum Verbosity { |
61 | shortNumber = 0x01, // default | 61 | shortNumber = 0x01, // default |
62 | longNumber = 0x02, | 62 | longNumber = 0x02, |
63 | 63 | ||
64 | padNumber = 0x04, | 64 | padNumber = 0x04, |
65 | 65 | ||
66 | shortWord = 0x08, // default | 66 | shortWord = 0x08, // default |
67 | longWord = 0x10, | 67 | longWord = 0x10, |
68 | 68 | ||
69 | showWeekDay = 0x20 | 69 | showWeekDay = 0x20 |
70 | }; | 70 | }; |
71 | 71 | ||
72 | QString toNumberString() const; // the M/D/Y string. | 72 | QString toNumberString() const; // the M/D/Y string. |
73 | QString toWordString() const; // the Month day, year string. | 73 | QString toWordString() const; // the Month day, year string. |
74 | 74 | ||
75 | QString numberDate(const QDate &d, int v = 0) const; | 75 | QString numberDate(const QDate &d, int v = 0) const; |
76 | QString wordDate(const QDate &d, int v = 0) const; | 76 | QString wordDate(const QDate &d, int v = 0) const; |
77 | 77 | ||
78 | #ifndef QT_NO_DATASTREAM | 78 | #ifndef QT_NO_DATASTREAM |
79 | void load(QDataStream&); | 79 | void load(QDataStream&); |
80 | void save(QDataStream&) const; | 80 | void save(QDataStream&) const; |
81 | #endif | 81 | #endif |
82 | 82 | ||
83 | QChar separator() const { return _shortSeparator; }; | 83 | QChar separator() const { return _shortSeparator; }; |
84 | Order shortOrder() const { return _shortOrder; }; | 84 | Order shortOrder() const { return _shortOrder; }; |
85 | Order longOrder() const { return _longOrder; }; | 85 | Order longOrder() const { return _longOrder; }; |
86 | 86 | ||
87 | private: | 87 | private: |
88 | Order _shortOrder; | 88 | Order _shortOrder; |
89 | Order _longOrder; | 89 | Order _longOrder; |
90 | QChar _shortSeparator; | 90 | QChar _shortSeparator; |
91 | }; | 91 | }; |
92 | 92 | ||
93 | #ifndef QT_NO_DATASTREAM | 93 | #ifndef QT_NO_DATASTREAM |
94 | QDataStream &operator<<(QDataStream &s, const DateFormat&df); | 94 | QDataStream &operator<<(QDataStream &s, const DateFormat&df); |
95 | QDataStream &operator>>(QDataStream &s, DateFormat&df); | 95 | QDataStream &operator>>(QDataStream &s, DateFormat&df); |
96 | #endif | 96 | #endif |
97 | 97 | ||
98 | class TimeString | 98 | class TimeString |
99 | { | 99 | { |
100 | public: | 100 | public: |
101 | 101 | ||
102 | //enum DateFormat { MonthDayYear, DayMonthYear, ISO8601, | 102 | //enum DateFormat { MonthDayYear, DayMonthYear, ISO8601, |
103 | //YearMonthDay = ISO8601 }; | 103 | //YearMonthDay = ISO8601 }; |
104 | 104 | ||
105 | 105 | /** | |
106 | * @name Convience functions which use currentDateFormat | ||
107 | */ | ||
108 | //@{ | ||
106 | static QString shortDate( const QDate &d ) | 109 | static QString shortDate( const QDate &d ) |
107 | { return shortDate( d, currentDateFormat() ); } | 110 | { return shortDate( d, currentDateFormat() ); } |
108 | static QString dateString( const QDate &d ) | 111 | static QString dateString( const QDate &d ) |
109 | { return dateString( d, currentDateFormat() ); } | 112 | { return dateString( d, currentDateFormat() ); } |
110 | static QString longDateString( const QDate &d ) | 113 | static QString longDateString( const QDate &d ) |
111 | { return longDateString( d, currentDateFormat() ); } | 114 | { return longDateString( d, currentDateFormat() ); } |
115 | //@} | ||
112 | static QString dateString( const QDateTime &dt, bool ampm, bool seconds ) | 116 | static QString dateString( const QDateTime &dt, bool ampm, bool seconds ) |
113 | { return dateString( dt, ampm, seconds, currentDateFormat() ); } | 117 | { return dateString( dt, ampm, seconds, currentDateFormat() ); } |
114 | 118 | ||
119 | |||
120 | /** @name Do not use as they don't honor system settings for AMPM | ||
121 | * | ||
122 | */ | ||
123 | //@{ | ||
115 | static QString dateString( const QDateTime &t, bool ampm = false ); | 124 | static QString dateString( const QDateTime &t, bool ampm = false ); |
116 | static QString timeString( const QTime &t, bool ampm, bool seconds ); | 125 | static QString timeString( const QTime &t, bool ampm, bool seconds ); |
117 | static QString timeString( const QTime &t, bool ampm = false ); | 126 | static QString timeString( const QTime &t, bool ampm = false ); |
118 | static QString shortTime( bool ampm, bool seconds ); | 127 | static QString shortTime( bool ampm, bool seconds ); |
119 | static QString shortTime( bool ampm = false ); | 128 | static QString shortTime( bool ampm = false ); |
129 | //@} | ||
120 | 130 | ||
121 | static QString numberDateString( const QDate &d, DateFormat ); | 131 | static QString numberDateString( const QDate &d, DateFormat ); |
122 | static QString numberDateString( const QDate &d ) | 132 | static QString numberDateString( const QDate &d ) |
123 | { return numberDateString( d, currentDateFormat() ); } | 133 | { return numberDateString( d, currentDateFormat() ); } |
124 | static QString longNumberDateString( const QDate &d, DateFormat ); | 134 | static QString longNumberDateString( const QDate &d, DateFormat ); |
125 | static QString longNumberDateString( const QDate &d ) | 135 | static QString longNumberDateString( const QDate &d ) |
126 | { return longNumberDateString( d, currentDateFormat() ); } | 136 | { return longNumberDateString( d, currentDateFormat() ); } |
127 | 137 | ||
128 | static QString shortDate( const QDate &, DateFormat ); | 138 | static QString shortDate( const QDate &, DateFormat ); |
129 | static QString dateString( const QDate &, DateFormat ); | 139 | static QString dateString( const QDate &, DateFormat ); |
130 | static QString longDateString( const QDate &, DateFormat ); | 140 | static QString longDateString( const QDate &, DateFormat ); |
131 | 141 | ||
132 | static DateFormat currentDateFormat(); | 142 | static DateFormat currentDateFormat(); |
133 | 143 | ||
134 | private: | 144 | private: |
135 | static QString dateString( const QDateTime &t, bool ampm, bool seconds, DateFormat ); | 145 | static QString dateString( const QDateTime &t, bool ampm, bool seconds, DateFormat ); |
136 | 146 | ||
137 | 147 | ||
138 | }; | 148 | }; |
139 | 149 | ||
140 | #endif | 150 | #endif |