-rw-r--r-- | microkde/KDGanttMinimizeSplitter.cpp | 10 | ||||
-rw-r--r-- | microkde/kcalendarsystemgregorian.cpp | 8 |
2 files changed, 9 insertions, 9 deletions
diff --git a/microkde/KDGanttMinimizeSplitter.cpp b/microkde/KDGanttMinimizeSplitter.cpp index 60b8bc7..567ae54 100644 --- a/microkde/KDGanttMinimizeSplitter.cpp +++ b/microkde/KDGanttMinimizeSplitter.cpp | |||
@@ -7,66 +7,66 @@ | |||
7 | ** | 7 | ** |
8 | ** This file is part of the KDGantt library. | 8 | ** This file is part of the KDGantt library. |
9 | ** | 9 | ** |
10 | ** This file may be distributed and/or modified under the terms of the | 10 | ** This file may be distributed and/or modified under the terms of the |
11 | ** GNU General Public License version 2 as published by the Free Software | 11 | ** GNU General Public License version 2 as published by the Free Software |
12 | ** Foundation and appearing in the file LICENSE.GPL included in the | 12 | ** Foundation and appearing in the file LICENSE.GPL included in the |
13 | ** packaging of this file. | 13 | ** packaging of this file. |
14 | ** | 14 | ** |
15 | ** Licensees holding valid commercial KDGantt licenses may use this file in | 15 | ** Licensees holding valid commercial KDGantt licenses may use this file in |
16 | ** accordance with the KDGantt Commercial License Agreement provided with | 16 | ** accordance with the KDGantt Commercial License Agreement provided with |
17 | ** the Software. | 17 | ** the Software. |
18 | ** | 18 | ** |
19 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 19 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
20 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 20 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
21 | ** | 21 | ** |
22 | ** See http://www.klaralvdalens-datakonsult.se/Public/products/ for | 22 | ** See http://www.klaralvdalens-datakonsult.se/Public/products/ for |
23 | ** information about KDGantt Commercial License Agreements. | 23 | ** information about KDGantt Commercial License Agreements. |
24 | ** | 24 | ** |
25 | ** Contact info@klaralvdalens-datakonsult.se if any conditions of this | 25 | ** Contact info@klaralvdalens-datakonsult.se if any conditions of this |
26 | ** licensing are not clear to you. | 26 | ** licensing are not clear to you. |
27 | ** | 27 | ** |
28 | ** As a special exception, permission is given to link this program | 28 | ** As a special exception, permission is given to link this program |
29 | ** with any edition of Qt, and distribute the resulting executable, | 29 | ** with any edition of Qt, and distribute the resulting executable, |
30 | ** without including the source code for Qt in the source distribution. | 30 | ** without including the source code for Qt in the source distribution. |
31 | ** | 31 | ** |
32 | **********************************************************************/ | 32 | **********************************************************************/ |
33 | 33 | ||
34 | #include "KDGanttMinimizeSplitter.h" | 34 | #include "KDGanttMinimizeSplitter.h" |
35 | #ifndef QT_NO_SPLITTER___ | 35 | #ifndef QT_NO_SPLITTER___ |
36 | 36 | ||
37 | #include "qpainter.h" | 37 | #include "qpainter.h" |
38 | #include "qdrawutil.h" | 38 | #include "qdrawutil.h" |
39 | #include "qbitmap.h" | 39 | #include "qbitmap.h" |
40 | #if QT_VERSION >= 300 | 40 | #if QT_VERSION >= 0x030000 |
41 | #include "qptrlist.h" | 41 | #include "qptrlist.h" |
42 | #include "qmemarray.h" | 42 | #include "qmemarray.h" |
43 | #else | 43 | #else |
44 | #include <qlist.h> | 44 | #include <qlist.h> |
45 | #include <qarray.h> | 45 | #include <qarray.h> |
46 | #define QPtrList QList | 46 | #define QPtrList QList |
47 | #define QMemArray QArray | 47 | #define QMemArray QArray |
48 | #endif | 48 | #endif |
49 | #include "qlayoutengine_p.h" | 49 | #include "qlayoutengine_p.h" |
50 | #include "qobjectlist.h" | 50 | #include "qobjectlist.h" |
51 | #include "qstyle.h" | 51 | #include "qstyle.h" |
52 | #include "qapplication.h" //sendPostedEvents | 52 | #include "qapplication.h" //sendPostedEvents |
53 | #include <qvaluelist.h> | 53 | #include <qvaluelist.h> |
54 | #include <qcursor.h> | 54 | #include <qcursor.h> |
55 | #ifndef KDGANTT_MASTER_CVS | 55 | #ifndef KDGANTT_MASTER_CVS |
56 | //#include "KDGanttMinimizeSplitter.moc" | 56 | //#include "KDGanttMinimizeSplitter.moc" |
57 | #endif | 57 | #endif |
58 | 58 | ||
59 | 59 | ||
60 | 60 | ||
61 | #ifndef DOXYGEN_SKIP_INTERNAL | 61 | #ifndef DOXYGEN_SKIP_INTERNAL |
62 | 62 | ||
63 | #if QT_VERSION >= 232 | 63 | #if QT_VERSION >= 232 |
64 | static int mouseOffset; | 64 | static int mouseOffset; |
65 | static int opaqueOldPos = -1; //### there's only one mouse, but this is a bit risky | 65 | static int opaqueOldPos = -1; //### there's only one mouse, but this is a bit risky |
66 | 66 | ||
67 | 67 | ||
68 | KDGanttSplitterHandle::KDGanttSplitterHandle( Qt::Orientation o, | 68 | KDGanttSplitterHandle::KDGanttSplitterHandle( Qt::Orientation o, |
69 | KDGanttMinimizeSplitter *parent, const char * name ) | 69 | KDGanttMinimizeSplitter *parent, const char * name ) |
70 | : QWidget( parent, name ), _activeButton( 0 ), _collapsed( false ) | 70 | : QWidget( parent, name ), _activeButton( 0 ), _collapsed( false ) |
71 | { | 71 | { |
72 | 72 | ||
@@ -598,65 +598,65 @@ void KDGanttMinimizeSplitter::childEvent( QChildEvent *c ) | |||
598 | while ( s ) { | 598 | while ( s ) { |
599 | if ( s->wid == c->child() ) { | 599 | if ( s->wid == c->child() ) { |
600 | data->list.removeRef( s ); | 600 | data->list.removeRef( s ); |
601 | delete s; | 601 | delete s; |
602 | if ( p && p->isSplitter ) { | 602 | if ( p && p->isSplitter ) { |
603 | data->list.removeRef( p ); | 603 | data->list.removeRef( p ); |
604 | delete p->wid; //will call childEvent | 604 | delete p->wid; //will call childEvent |
605 | delete p; | 605 | delete p; |
606 | } | 606 | } |
607 | recalcId(); | 607 | recalcId(); |
608 | doResize(); | 608 | doResize(); |
609 | return; | 609 | return; |
610 | } | 610 | } |
611 | p = s; | 611 | p = s; |
612 | s = data->list.next(); | 612 | s = data->list.next(); |
613 | } | 613 | } |
614 | } | 614 | } |
615 | } | 615 | } |
616 | 616 | ||
617 | 617 | ||
618 | /*! | 618 | /*! |
619 | Shows a rubber band at position \a p. If \a p is negative, the | 619 | Shows a rubber band at position \a p. If \a p is negative, the |
620 | rubber band is removed. | 620 | rubber band is removed. |
621 | */ | 621 | */ |
622 | void KDGanttMinimizeSplitter::setRubberband( int p ) | 622 | void KDGanttMinimizeSplitter::setRubberband( int p ) |
623 | { | 623 | { |
624 | QPainter paint( this ); | 624 | QPainter paint( this ); |
625 | paint.setPen( gray ); | 625 | paint.setPen( gray ); |
626 | paint.setBrush( gray ); | 626 | paint.setBrush( gray ); |
627 | paint.setRasterOp( XorROP ); | 627 | paint.setRasterOp( XorROP ); |
628 | QRect r = contentsRect(); | 628 | QRect r = contentsRect(); |
629 | const int rBord = 3; //Themable???? | 629 | const int rBord = 3; //Themable???? |
630 | #if QT_VERSION >= 300 | 630 | #if QT_VERSION >= 0x030000 |
631 | int sw = style().pixelMetric(QStyle::PM_SplitterWidth, this); | 631 | int sw = style().pixelMetric(QStyle::PM_SplitterWidth, this); |
632 | #else | 632 | #else |
633 | int sw = style().splitterWidth(); | 633 | int sw = style().splitterWidth(); |
634 | #endif | 634 | #endif |
635 | if ( orient == Horizontal ) { | 635 | if ( orient == Horizontal ) { |
636 | if ( opaqueOldPos >= 0 ) | 636 | if ( opaqueOldPos >= 0 ) |
637 | paint.drawRect( opaqueOldPos + sw/2 - rBord , r.y(), | 637 | paint.drawRect( opaqueOldPos + sw/2 - rBord , r.y(), |
638 | 2*rBord, r.height() ); | 638 | 2*rBord, r.height() ); |
639 | if ( p >= 0 ) | 639 | if ( p >= 0 ) |
640 | paint.drawRect( p + sw/2 - rBord, r.y(), 2*rBord, r.height() ); | 640 | paint.drawRect( p + sw/2 - rBord, r.y(), 2*rBord, r.height() ); |
641 | } else { | 641 | } else { |
642 | if ( opaqueOldPos >= 0 ) | 642 | if ( opaqueOldPos >= 0 ) |
643 | paint.drawRect( r.x(), opaqueOldPos + sw/2 - rBord, | 643 | paint.drawRect( r.x(), opaqueOldPos + sw/2 - rBord, |
644 | r.width(), 2*rBord ); | 644 | r.width(), 2*rBord ); |
645 | if ( p >= 0 ) | 645 | if ( p >= 0 ) |
646 | paint.drawRect( r.x(), p + sw/2 - rBord, r.width(), 2*rBord ); | 646 | paint.drawRect( r.x(), p + sw/2 - rBord, r.width(), 2*rBord ); |
647 | } | 647 | } |
648 | opaqueOldPos = p; | 648 | opaqueOldPos = p; |
649 | } | 649 | } |
650 | 650 | ||
651 | 651 | ||
652 | /*! \reimp */ | 652 | /*! \reimp */ |
653 | bool KDGanttMinimizeSplitter::event( QEvent *e ) | 653 | bool KDGanttMinimizeSplitter::event( QEvent *e ) |
654 | { | 654 | { |
655 | if ( e->type() == QEvent::LayoutHint || ( e->type() == QEvent::Show && data->firstShow ) ) { | 655 | if ( e->type() == QEvent::LayoutHint || ( e->type() == QEvent::Show && data->firstShow ) ) { |
656 | recalc( isVisible() ); | 656 | recalc( isVisible() ); |
657 | if ( e->type() == QEvent::Show ) | 657 | if ( e->type() == QEvent::Show ) |
658 | data->firstShow = FALSE; | 658 | data->firstShow = FALSE; |
659 | } | 659 | } |
660 | return QWidget::event( e ); | 660 | return QWidget::event( e ); |
661 | } | 661 | } |
662 | 662 | ||
@@ -880,65 +880,65 @@ void KDGanttMinimizeSplitter::getRange( int id, int *min, int *max ) | |||
880 | int minA = 0; | 880 | int minA = 0; |
881 | int maxA = 0;//after | 881 | int maxA = 0;//after |
882 | int n = data->list.count(); | 882 | int n = data->list.count(); |
883 | if ( id < 0 || id >= n ) | 883 | if ( id < 0 || id >= n ) |
884 | return; | 884 | return; |
885 | int i; | 885 | int i; |
886 | for ( i = 0; i < id; i++ ) { | 886 | for ( i = 0; i < id; i++ ) { |
887 | QSplitterLayoutStruct *s = data->list.at(i); | 887 | QSplitterLayoutStruct *s = data->list.at(i); |
888 | if ( s->wid->isHidden() ) { | 888 | if ( s->wid->isHidden() ) { |
889 | //ignore | 889 | //ignore |
890 | } else if ( s->isSplitter ) { | 890 | } else if ( s->isSplitter ) { |
891 | minB += s->sizer; | 891 | minB += s->sizer; |
892 | maxB += s->sizer; | 892 | maxB += s->sizer; |
893 | } else { | 893 | } else { |
894 | minB += pick( minSize(s->wid) ); | 894 | minB += pick( minSize(s->wid) ); |
895 | maxB += pick( s->wid->maximumSize() ); | 895 | maxB += pick( s->wid->maximumSize() ); |
896 | } | 896 | } |
897 | } | 897 | } |
898 | for ( i = id; i < n; i++ ) { | 898 | for ( i = id; i < n; i++ ) { |
899 | QSplitterLayoutStruct *s = data->list.at(i); | 899 | QSplitterLayoutStruct *s = data->list.at(i); |
900 | if ( s->wid->isHidden() ) { | 900 | if ( s->wid->isHidden() ) { |
901 | //ignore | 901 | //ignore |
902 | } else if ( s->isSplitter ) { | 902 | } else if ( s->isSplitter ) { |
903 | minA += s->sizer; | 903 | minA += s->sizer; |
904 | maxA += s->sizer; | 904 | maxA += s->sizer; |
905 | } else { | 905 | } else { |
906 | minA += pick( minSize(s->wid) ); | 906 | minA += pick( minSize(s->wid) ); |
907 | maxA += pick( s->wid->maximumSize() ); | 907 | maxA += pick( s->wid->maximumSize() ); |
908 | } | 908 | } |
909 | } | 909 | } |
910 | QRect r = contentsRect(); | 910 | QRect r = contentsRect(); |
911 | if ( orient == Horizontal && false ) { | 911 | if ( orient == Horizontal && false ) { |
912 | #if QT_VERSION >= 300 | 912 | #if QT_VERSION >= 0x030000 |
913 | int splitterWidth = style().pixelMetric(QStyle::PM_SplitterWidth, this); | 913 | int splitterWidth = style().pixelMetric(QStyle::PM_SplitterWidth, this); |
914 | #else | 914 | #else |
915 | int splitterWidth = style().splitterWidth(); | 915 | int splitterWidth = style().splitterWidth(); |
916 | #endif | 916 | #endif |
917 | 917 | ||
918 | if ( min ) | 918 | if ( min ) |
919 | *min = pick(r.topRight()) - QMIN( maxB, pick(r.size())-minA ) - splitterWidth; | 919 | *min = pick(r.topRight()) - QMIN( maxB, pick(r.size())-minA ) - splitterWidth; |
920 | if ( max ) | 920 | if ( max ) |
921 | *max = pick(r.topRight()) - QMAX( minB, pick(r.size())-maxA ) - splitterWidth; | 921 | *max = pick(r.topRight()) - QMAX( minB, pick(r.size())-maxA ) - splitterWidth; |
922 | } else { | 922 | } else { |
923 | if ( min ) | 923 | if ( min ) |
924 | *min = pick(r.topLeft()) + QMAX( minB, pick(r.size())-maxA ); | 924 | *min = pick(r.topLeft()) + QMAX( minB, pick(r.size())-maxA ); |
925 | if ( max ) | 925 | if ( max ) |
926 | *max = pick(r.topLeft()) + QMIN( maxB, pick(r.size())-minA ); | 926 | *max = pick(r.topLeft()) + QMIN( maxB, pick(r.size())-minA ); |
927 | } | 927 | } |
928 | } | 928 | } |
929 | 929 | ||
930 | 930 | ||
931 | /*! | 931 | /*! |
932 | Returns the closest legal position to \a p of the splitter with id \a id. | 932 | Returns the closest legal position to \a p of the splitter with id \a id. |
933 | 933 | ||
934 | \sa idAfter() | 934 | \sa idAfter() |
935 | */ | 935 | */ |
936 | 936 | ||
937 | int KDGanttMinimizeSplitter::adjustPos( int p, int id ) | 937 | int KDGanttMinimizeSplitter::adjustPos( int p, int id ) |
938 | { | 938 | { |
939 | int min = 0; | 939 | int min = 0; |
940 | int max = 0; | 940 | int max = 0; |
941 | getRange( id, &min, &max ); | 941 | getRange( id, &min, &max ); |
942 | p = QMAX( min, QMIN( p, max ) ); | 942 | p = QMAX( min, QMIN( p, max ) ); |
943 | 943 | ||
944 | return p; | 944 | return p; |
@@ -1358,65 +1358,65 @@ void KDGanttMinimizeSplitter::setSizes( QValueList<int> list ) | |||
1358 | processChildEvents(); | 1358 | processChildEvents(); |
1359 | QValueList<int>::Iterator it = list.begin(); | 1359 | QValueList<int>::Iterator it = list.begin(); |
1360 | QSplitterLayoutStruct *s = data->list.first(); | 1360 | QSplitterLayoutStruct *s = data->list.first(); |
1361 | while ( s && it != list.end() ) { | 1361 | while ( s && it != list.end() ) { |
1362 | if ( !s->isSplitter ) { | 1362 | if ( !s->isSplitter ) { |
1363 | s->sizer = *it; | 1363 | s->sizer = *it; |
1364 | ++it; | 1364 | ++it; |
1365 | } | 1365 | } |
1366 | s = data->list.next(); | 1366 | s = data->list.next(); |
1367 | } | 1367 | } |
1368 | doResize(); | 1368 | doResize(); |
1369 | } | 1369 | } |
1370 | 1370 | ||
1371 | 1371 | ||
1372 | /*! | 1372 | /*! |
1373 | Gets all posted child events, ensuring that the internal state of | 1373 | Gets all posted child events, ensuring that the internal state of |
1374 | the splitter is consistent. | 1374 | the splitter is consistent. |
1375 | */ | 1375 | */ |
1376 | 1376 | ||
1377 | void KDGanttMinimizeSplitter::processChildEvents() | 1377 | void KDGanttMinimizeSplitter::processChildEvents() |
1378 | { | 1378 | { |
1379 | QApplication::sendPostedEvents( this, QEvent::ChildInserted ); | 1379 | QApplication::sendPostedEvents( this, QEvent::ChildInserted ); |
1380 | } | 1380 | } |
1381 | 1381 | ||
1382 | 1382 | ||
1383 | /*! | 1383 | /*! |
1384 | \reimp | 1384 | \reimp |
1385 | */ | 1385 | */ |
1386 | 1386 | ||
1387 | void KDGanttMinimizeSplitter::styleChange( QStyle& old ) | 1387 | void KDGanttMinimizeSplitter::styleChange( QStyle& old ) |
1388 | { | 1388 | { |
1389 | 1389 | ||
1390 | #if QT_VERSION >= 300 | 1390 | #if QT_VERSION >= 0x030000 |
1391 | int sw = style().pixelMetric(QStyle::PM_SplitterWidth, this); | 1391 | int sw = style().pixelMetric(QStyle::PM_SplitterWidth, this); |
1392 | #else | 1392 | #else |
1393 | int sw = style().splitterWidth(); | 1393 | int sw = style().splitterWidth(); |
1394 | #endif | 1394 | #endif |
1395 | QSplitterLayoutStruct *s = data->list.first(); | 1395 | QSplitterLayoutStruct *s = data->list.first(); |
1396 | while ( s ) { | 1396 | while ( s ) { |
1397 | if ( s->isSplitter ) | 1397 | if ( s->isSplitter ) |
1398 | s->sizer = sw; | 1398 | s->sizer = sw; |
1399 | s = data->list.next(); | 1399 | s = data->list.next(); |
1400 | } | 1400 | } |
1401 | doResize(); | 1401 | doResize(); |
1402 | QFrame::styleChange( old ); | 1402 | QFrame::styleChange( old ); |
1403 | } | 1403 | } |
1404 | 1404 | ||
1405 | #endif | 1405 | #endif |
1406 | 1406 | ||
1407 | /*! | 1407 | /*! |
1408 | Specifies the direction of the minimize buttons. | 1408 | Specifies the direction of the minimize buttons. |
1409 | If the orientation of the splitter is horizontal then with | 1409 | If the orientation of the splitter is horizontal then with |
1410 | KDGanttMinimizeSplitter::Left or KDGanttMinimizeSplitter::Right should be used, | 1410 | KDGanttMinimizeSplitter::Left or KDGanttMinimizeSplitter::Right should be used, |
1411 | otherwise either KDGanttMinimizeSplitter::Up or KDGanttMinimizeSplitter::Down | 1411 | otherwise either KDGanttMinimizeSplitter::Up or KDGanttMinimizeSplitter::Down |
1412 | should be used. | 1412 | should be used. |
1413 | */ | 1413 | */ |
1414 | void KDGanttMinimizeSplitter::setMinimizeDirection( Direction direction ) | 1414 | void KDGanttMinimizeSplitter::setMinimizeDirection( Direction direction ) |
1415 | { | 1415 | { |
1416 | _direction = direction; | 1416 | _direction = direction; |
1417 | } | 1417 | } |
1418 | 1418 | ||
1419 | /*! | 1419 | /*! |
1420 | Returns the direction of the minimize buttons. | 1420 | Returns the direction of the minimize buttons. |
1421 | */ | 1421 | */ |
1422 | KDGanttMinimizeSplitter::Direction KDGanttMinimizeSplitter::minimizeDirection() const | 1422 | KDGanttMinimizeSplitter::Direction KDGanttMinimizeSplitter::minimizeDirection() const |
diff --git a/microkde/kcalendarsystemgregorian.cpp b/microkde/kcalendarsystemgregorian.cpp index 7c5b62a..cc12b9f 100644 --- a/microkde/kcalendarsystemgregorian.cpp +++ b/microkde/kcalendarsystemgregorian.cpp | |||
@@ -25,83 +25,83 @@ | |||
25 | #include <qstring.h> | 25 | #include <qstring.h> |
26 | 26 | ||
27 | #include <klocale.h> | 27 | #include <klocale.h> |
28 | #include <kdebug.h> | 28 | #include <kdebug.h> |
29 | 29 | ||
30 | #include "kcalendarsystemgregorian.h" | 30 | #include "kcalendarsystemgregorian.h" |
31 | 31 | ||
32 | KCalendarSystemGregorian::KCalendarSystemGregorian(const KLocale * locale) | 32 | KCalendarSystemGregorian::KCalendarSystemGregorian(const KLocale * locale) |
33 | : KCalendarSystem(locale) | 33 | : KCalendarSystem(locale) |
34 | { | 34 | { |
35 | kdDebug(5400) << "Created gregorian calendar" << endl; | 35 | kdDebug(5400) << "Created gregorian calendar" << endl; |
36 | } | 36 | } |
37 | 37 | ||
38 | KCalendarSystemGregorian::~KCalendarSystemGregorian() | 38 | KCalendarSystemGregorian::~KCalendarSystemGregorian() |
39 | { | 39 | { |
40 | } | 40 | } |
41 | 41 | ||
42 | int KCalendarSystemGregorian::year(const QDate& date) const | 42 | int KCalendarSystemGregorian::year(const QDate& date) const |
43 | { | 43 | { |
44 | // kdDebug(5400) << "Gregorian year..." << endl; | 44 | // kdDebug(5400) << "Gregorian year..." << endl; |
45 | return date.year(); | 45 | return date.year(); |
46 | } | 46 | } |
47 | 47 | ||
48 | int KCalendarSystemGregorian::monthsInYear( const QDate & ) const | 48 | int KCalendarSystemGregorian::monthsInYear( const QDate & ) const |
49 | { | 49 | { |
50 | // kdDebug(5400) << "Gregorian monthsInYear" << endl; | 50 | // kdDebug(5400) << "Gregorian monthsInYear" << endl; |
51 | 51 | ||
52 | return 12; | 52 | return 12; |
53 | } | 53 | } |
54 | 54 | ||
55 | int KCalendarSystemGregorian::weeksInYear(int year) const | 55 | int KCalendarSystemGregorian::weeksInYear(int year) const |
56 | { | 56 | { |
57 | #if QT_VERSION >= 300 | 57 | #if QT_VERSION >= 0x030000 |
58 | QDate temp; | 58 | QDate temp; |
59 | temp.setYMD(year, 12, 31); | 59 | temp.setYMD(year, 12, 31); |
60 | 60 | ||
61 | // If the last day of the year is in the first week, we have to check the | 61 | // If the last day of the year is in the first week, we have to check the |
62 | // week before | 62 | // week before |
63 | if ( temp.weekNumber() == 1 ) | 63 | if ( temp.weekNumber() == 1 ) |
64 | temp.addDays(-7); | 64 | temp.addDays(-7); |
65 | 65 | ||
66 | return temp.weekNumber(); | 66 | return temp.weekNumber(); |
67 | #else | 67 | #else |
68 | return 52; | 68 | return 52; |
69 | #endif | 69 | #endif |
70 | } | 70 | } |
71 | 71 | ||
72 | int KCalendarSystemGregorian::weekNumber(const QDate& date, | 72 | int KCalendarSystemGregorian::weekNumber(const QDate& date, |
73 | int * yearNum) const | 73 | int * yearNum) const |
74 | { | 74 | { |
75 | #if QT_VERSION >= 300 | 75 | #if QT_VERSION >= 0x030000 |
76 | return date.weekNumber(yearNum); | 76 | return date.weekNumber(yearNum); |
77 | #else | 77 | #else |
78 | return 1; | 78 | return 1; |
79 | #endif | 79 | #endif |
80 | } | 80 | } |
81 | 81 | ||
82 | QString KCalendarSystemGregorian::monthName(const QDate& date, | 82 | QString KCalendarSystemGregorian::monthName(const QDate& date, |
83 | bool shortName) const | 83 | bool shortName) const |
84 | { | 84 | { |
85 | return monthName(month(date), shortName); | 85 | return monthName(month(date), shortName); |
86 | } | 86 | } |
87 | 87 | ||
88 | QString KCalendarSystemGregorian::monthNamePossessive(const QDate& date, bool shortName) const | 88 | QString KCalendarSystemGregorian::monthNamePossessive(const QDate& date, bool shortName) const |
89 | { | 89 | { |
90 | return monthNamePossessive(month(date), shortName); | 90 | return monthNamePossessive(month(date), shortName); |
91 | } | 91 | } |
92 | 92 | ||
93 | QString KCalendarSystemGregorian::monthName(int month, bool shortName) const | 93 | QString KCalendarSystemGregorian::monthName(int month, bool shortName) const |
94 | { | 94 | { |
95 | // kdDebug(5400) << "Gregorian getMonthName" << endl; | 95 | // kdDebug(5400) << "Gregorian getMonthName" << endl; |
96 | 96 | ||
97 | if ( shortName ) | 97 | if ( shortName ) |
98 | switch ( month ) | 98 | switch ( month ) |
99 | { | 99 | { |
100 | case 1: | 100 | case 1: |
101 | return locale()->translate("January", "Jan"); | 101 | return locale()->translate("January", "Jan"); |
102 | case 2: | 102 | case 2: |
103 | return locale()->translate("February", "Feb"); | 103 | return locale()->translate("February", "Feb"); |
104 | case 3: | 104 | case 3: |
105 | return locale()->translate("March", "Mar"); | 105 | return locale()->translate("March", "Mar"); |
106 | case 4: | 106 | case 4: |
107 | return locale()->translate("April", "Apr"); | 107 | return locale()->translate("April", "Apr"); |
@@ -202,79 +202,79 @@ QString KCalendarSystemGregorian::monthNamePossessive(int month, | |||
202 | return locale()->translate("of May long", "of May"); | 202 | return locale()->translate("of May long", "of May"); |
203 | case 6: | 203 | case 6: |
204 | return locale()->translate("of June"); | 204 | return locale()->translate("of June"); |
205 | case 7: | 205 | case 7: |
206 | return locale()->translate("of July"); | 206 | return locale()->translate("of July"); |
207 | case 8: | 207 | case 8: |
208 | return locale()->translate("of August"); | 208 | return locale()->translate("of August"); |
209 | case 9: | 209 | case 9: |
210 | return locale()->translate("of September"); | 210 | return locale()->translate("of September"); |
211 | case 10: | 211 | case 10: |
212 | return locale()->translate("of October"); | 212 | return locale()->translate("of October"); |
213 | case 11: | 213 | case 11: |
214 | return locale()->translate("of November"); | 214 | return locale()->translate("of November"); |
215 | case 12: | 215 | case 12: |
216 | return locale()->translate("of December"); | 216 | return locale()->translate("of December"); |
217 | } | 217 | } |
218 | 218 | ||
219 | return QString::null; | 219 | return QString::null; |
220 | } | 220 | } |
221 | 221 | ||
222 | bool KCalendarSystemGregorian::setYMD(QDate & date, int y, int m, int d) const | 222 | bool KCalendarSystemGregorian::setYMD(QDate & date, int y, int m, int d) const |
223 | { | 223 | { |
224 | // We don't want Qt to add 1900 to them | 224 | // We don't want Qt to add 1900 to them |
225 | if ( y >= 0 && y <= 99 ) | 225 | if ( y >= 0 && y <= 99 ) |
226 | return false; | 226 | return false; |
227 | 227 | ||
228 | // QDate supports gregorian internally | 228 | // QDate supports gregorian internally |
229 | return date.setYMD(y, m, d); | 229 | return date.setYMD(y, m, d); |
230 | } | 230 | } |
231 | 231 | ||
232 | QDate KCalendarSystemGregorian::addYears(const QDate & date, int nyears) const | 232 | QDate KCalendarSystemGregorian::addYears(const QDate & date, int nyears) const |
233 | { | 233 | { |
234 | #if QT_VERSION >= 300 | 234 | #if QT_VERSION >= 0x030000 |
235 | return date.addYears(nyears); | 235 | return date.addYears(nyears); |
236 | #else | 236 | #else |
237 | int year = date.year() + nyears; | 237 | int year = date.year() + nyears; |
238 | int month = date.month(); | 238 | int month = date.month(); |
239 | int day = date.day(); | 239 | int day = date.day(); |
240 | QDate newDate( year, month, 1 ); | 240 | QDate newDate( year, month, 1 ); |
241 | if ( day > newDate.daysInMonth() ) day = newDate.daysInMonth(); | 241 | if ( day > newDate.daysInMonth() ) day = newDate.daysInMonth(); |
242 | return QDate( year, month, day ); | 242 | return QDate( year, month, day ); |
243 | #endif | 243 | #endif |
244 | } | 244 | } |
245 | 245 | ||
246 | QDate KCalendarSystemGregorian::addMonths(const QDate & date, int nmonths) const | 246 | QDate KCalendarSystemGregorian::addMonths(const QDate & date, int nmonths) const |
247 | { | 247 | { |
248 | #if QT_VERSION >= 300 | 248 | #if QT_VERSION >= 0x030000 |
249 | return date.addMonths(nmonths); | 249 | return date.addMonths(nmonths); |
250 | #else | 250 | #else |
251 | int month = date.month(); | 251 | int month = date.month(); |
252 | int nyears; | 252 | int nyears; |
253 | if ( nmonths >= 0 ) { | 253 | if ( nmonths >= 0 ) { |
254 | month += nmonths; | 254 | month += nmonths; |
255 | nyears = ( month - 1 ) / 12; | 255 | nyears = ( month - 1 ) / 12; |
256 | month = ( ( month - 1 ) % 12 ) + 1; | 256 | month = ( ( month - 1 ) % 12 ) + 1; |
257 | } else { | 257 | } else { |
258 | nyears = nmonths / 12; | 258 | nyears = nmonths / 12; |
259 | // nmonths += nyears * 12; | 259 | // nmonths += nyears * 12; |
260 | nmonths = nmonths % 12; | 260 | nmonths = nmonths % 12; |
261 | month += nmonths; | 261 | month += nmonths; |
262 | if ( month <= 0 ) { | 262 | if ( month <= 0 ) { |
263 | month += 12; | 263 | month += 12; |
264 | --nyears; | 264 | --nyears; |
265 | } | 265 | } |
266 | } | 266 | } |
267 | int year = date.year() + nyears; | 267 | int year = date.year() + nyears; |
268 | int day = date.day(); | 268 | int day = date.day(); |
269 | QDate newDate( year, month, 1 ); | 269 | QDate newDate( year, month, 1 ); |
270 | if ( day > newDate.daysInMonth() ) day = newDate.daysInMonth(); | 270 | if ( day > newDate.daysInMonth() ) day = newDate.daysInMonth(); |
271 | return QDate( year, month, day ); | 271 | return QDate( year, month, day ); |
272 | #endif | 272 | #endif |
273 | } | 273 | } |
274 | 274 | ||
275 | QDate KCalendarSystemGregorian::addDays(const QDate & date, int ndays) const | 275 | QDate KCalendarSystemGregorian::addDays(const QDate & date, int ndays) const |
276 | { | 276 | { |
277 | return date.addDays(ndays); | 277 | return date.addDays(ndays); |
278 | } | 278 | } |
279 | 279 | ||
280 | QString KCalendarSystemGregorian::weekDayName(int col, bool shortName) const | 280 | QString KCalendarSystemGregorian::weekDayName(int col, bool shortName) const |