summaryrefslogtreecommitdiff
authorzecke <zecke>2004-02-20 00:50:32 (UTC)
committer zecke <zecke>2004-02-20 00:50:32 (UTC)
commit060b4fc7a3fd5c1b5f745167fe084f7486719b7e (patch) (unidiff)
tree76f02084f4b088a04f09cb57977b35695860cb0d
parente54e1cb01c3da0655fc6e86bd9d169b002a63e66 (diff)
downloadopie-060b4fc7a3fd5c1b5f745167fe084f7486719b7e.zip
opie-060b4fc7a3fd5c1b5f745167fe084f7486719b7e.tar.gz
opie-060b4fc7a3fd5c1b5f745167fe084f7486719b7e.tar.bz2
Update the API Documentation for DateFormat and TimeString utility classes
Add a Translator hint what M, D, Y mean
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--library/dummy_api_docu.cpp250
-rw-r--r--library/timestring.cpp4
-rw-r--r--library/timestring.h12
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
@@ -274,96 +274,346 @@
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,169 +1,169 @@
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
27class TimeStringFormatKeeper : public QObject 27class TimeStringFormatKeeper : public QObject
28{ 28{
29 Q_OBJECT 29 Q_OBJECT
30public: 30public:
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 }
37private slots: 37private slots:
38 void formatChanged( DateFormat f ) 38 void formatChanged( DateFormat f )
39 { 39 {
40 format = f; 40 format = f;
41 } 41 }
42private: 42private:
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
60TimeStringFormatKeeper *TimeStringFormatKeeper::self = 0; 60TimeStringFormatKeeper *TimeStringFormatKeeper::self = 0;
61 61
62QString DateFormat::toNumberString() const 62QString 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
85QString DateFormat::toWordString() const 85QString 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
116QString DateFormat::numberDate(const QDate &d, int v) const 116QString 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
152QString DateFormat::wordDate(const QDate &d, int v) const 152QString 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.
diff --git a/library/timestring.h b/library/timestring.h
index 0335715..875c8bf 100644
--- a/library/timestring.h
+++ b/library/timestring.h
@@ -9,132 +9,142 @@
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)
34class DateFormat 34class DateFormat
35{ 35{
36public: 36public:
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
87private: 87private:
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
94QDataStream &operator<<(QDataStream &s, const DateFormat&df); 94QDataStream &operator<<(QDataStream &s, const DateFormat&df);
95QDataStream &operator>>(QDataStream &s, DateFormat&df); 95QDataStream &operator>>(QDataStream &s, DateFormat&df);
96#endif 96#endif
97 97
98class TimeString 98class TimeString
99{ 99{
100public: 100public:
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
134private: 144private:
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