summaryrefslogtreecommitdiff
path: root/library
Unidiff
Diffstat (limited to 'library') (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
@@ -354,16 +354,266 @@
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
@@ -54,36 +54,36 @@ private:
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++) {
diff --git a/library/timestring.h b/library/timestring.h
index 0335715..875c8bf 100644
--- a/library/timestring.h
+++ b/library/timestring.h
@@ -89,47 +89,57 @@ private:
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 );