-rw-r--r-- | korganizer/kdatenavigator.cpp | 36 |
1 files changed, 25 insertions, 11 deletions
diff --git a/korganizer/kdatenavigator.cpp b/korganizer/kdatenavigator.cpp index c08f44f..e76a85a 100644 --- a/korganizer/kdatenavigator.cpp +++ b/korganizer/kdatenavigator.cpp | |||
@@ -36,44 +36,40 @@ | |||
36 | #include "koglobals.h" | 36 | #include "koglobals.h" |
37 | #include "koprefs.h" | 37 | #include "koprefs.h" |
38 | #ifndef KORG_NOPLUGINS | 38 | #ifndef KORG_NOPLUGINS |
39 | #include "kocore.h" | 39 | #include "kocore.h" |
40 | #endif | 40 | #endif |
41 | 41 | ||
42 | #include <kcalendarsystem.h> | 42 | #include <kcalendarsystem.h> |
43 | 43 | ||
44 | #include "navigatorbar.h" | 44 | #include "navigatorbar.h" |
45 | 45 | ||
46 | #include "kdatenavigator.h" | 46 | #include "kdatenavigator.h" |
47 | 47 | ||
48 | KDateNavigator::KDateNavigator( QWidget *parent, Calendar *calendar, | 48 | KDateNavigator::KDateNavigator( QWidget *parent, const char *name ) |
49 | bool show_week_nums, const char *name, | ||
50 | QDate startDate ) | ||
51 | : QFrame(parent, name), | 49 | : QFrame(parent, name), |
52 | updateTimer(0L) | 50 | updateTimer(0L) |
53 | { | 51 | { |
54 | mCalendar = calendar; | ||
55 | |||
56 | setFrameStyle(QFrame::NoFrame); | 52 | setFrameStyle(QFrame::NoFrame); |
57 | 53 | QDate startDate = QDate::currentDate(); | |
58 | QGridLayout *topLayout = new QGridLayout(this,8,8); | 54 | QGridLayout *topLayout = new QGridLayout(this,8,8); |
59 | 55 | ||
60 | if (! startDate.isValid()) { | 56 | if (! startDate.isValid()) { |
61 | qDebug("KDateNavigator::invalid startdate "); | 57 | qDebug("KDateNavigator::invalid startdate "); |
62 | startDate = QDate::currentDate(); | 58 | startDate = QDate::currentDate(); |
63 | } | 59 | } |
64 | 60 | ||
65 | mSelectedDates.append(startDate); | 61 | mSelectedDates.append(startDate); |
66 | m_MthYr = startDate; | 62 | m_MthYr = startDate; |
67 | m_bShowWeekNums = show_week_nums; | 63 | m_bShowWeekNums = true; |
68 | 64 | ||
69 | setFont( KOPrefs::instance()->mDateNavigatorFont ); | 65 | setFont( KOPrefs::instance()->mDateNavigatorFont ); |
70 | mNavigatorBar = new NavigatorBar( startDate, this ); | 66 | mNavigatorBar = new NavigatorBar( startDate, this ); |
71 | topLayout->addMultiCellWidget( mNavigatorBar, 0, 0, 0, 7 ); | 67 | topLayout->addMultiCellWidget( mNavigatorBar, 0, 0, 0, 7 ); |
72 | //mNavigatorBar->resize( 1,1); | 68 | //mNavigatorBar->resize( 1,1); |
73 | connect( mNavigatorBar, SIGNAL( goPrevYear() ), SIGNAL( goPrevYear() ) ); | 69 | connect( mNavigatorBar, SIGNAL( goPrevYear() ), SIGNAL( goPrevYear() ) ); |
74 | connect( mNavigatorBar, SIGNAL( goPrevMonth() ), SIGNAL( goPrevMonth() ) ); | 70 | connect( mNavigatorBar, SIGNAL( goPrevMonth() ), SIGNAL( goPrevMonth() ) ); |
75 | connect( mNavigatorBar, SIGNAL( goNextMonth() ), SIGNAL( goNextMonth() ) ); | 71 | connect( mNavigatorBar, SIGNAL( goNextMonth() ), SIGNAL( goNextMonth() ) ); |
76 | connect( mNavigatorBar, SIGNAL( goNextYear() ), SIGNAL( goNextYear() ) ); | 72 | connect( mNavigatorBar, SIGNAL( goNextYear() ), SIGNAL( goNextYear() ) ); |
77 | connect( mNavigatorBar, SIGNAL( monthSelected( int ) ), SIGNAL( monthSelected( int ) ) ); | 73 | connect( mNavigatorBar, SIGNAL( monthSelected( int ) ), SIGNAL( monthSelected( int ) ) ); |
78 | 74 | ||
79 | // get the day of the week on the first day | 75 | // get the day of the week on the first day |
@@ -87,49 +83,67 @@ KDateNavigator::KDateNavigator( QWidget *parent, Calendar *calendar, | |||
87 | headings[i] = new QLabel("",this); | 83 | headings[i] = new QLabel("",this); |
88 | //headings[i]->setFont(QFont("Arial", 10, QFont::Bold)); | 84 | //headings[i]->setFont(QFont("Arial", 10, QFont::Bold)); |
89 | headings[i]->setAlignment(AlignCenter); | 85 | headings[i]->setAlignment(AlignCenter); |
90 | 86 | ||
91 | topLayout->addWidget(headings[i],1,i+1); | 87 | topLayout->addWidget(headings[i],1,i+1); |
92 | } | 88 | } |
93 | 89 | ||
94 | // Create the weeknumber labels | 90 | // Create the weeknumber labels |
95 | for( i = 0; i < 6; i++ ) { | 91 | for( i = 0; i < 6; i++ ) { |
96 | weeknos[i] = new QLabel(this); | 92 | weeknos[i] = new QLabel(this); |
97 | weeknos[i]->setAlignment(AlignCenter); | 93 | weeknos[i]->setAlignment(AlignCenter); |
98 | //weeknos[i]->setFont(QFont("Arial", 10)); | 94 | //weeknos[i]->setFont(QFont("Arial", 10)); |
99 | if(!show_week_nums) { | 95 | if(!m_bShowWeekNums) { |
100 | weeknos[i]->hide(); | 96 | weeknos[i]->hide(); |
101 | } | 97 | } |
102 | weeknos[i]->installEventFilter(this); | 98 | weeknos[i]->installEventFilter(this); |
103 | 99 | ||
104 | topLayout->addWidget(weeknos[i],i+2,0); | 100 | topLayout->addWidget(weeknos[i],i+2,0); |
105 | } | 101 | } |
106 | 102 | ||
107 | daymatrix = new KODayMatrix( this, mCalendar, dayone, | 103 | daymatrix = new KODayMatrix( this, "KDateNavigator::DayMatrix"); |
108 | "KDateNavigator::DayMatrix"); | ||
109 | daymatrix->setFrameStyle(QFrame::Panel|QFrame::Sunken); | 104 | daymatrix->setFrameStyle(QFrame::Panel|QFrame::Sunken); |
110 | daymatrix->setLineWidth(1); | 105 | daymatrix->setLineWidth(1); |
111 | 106 | ||
112 | connect( daymatrix, SIGNAL( selected( const KCal::DateList & ) ), | 107 | connect( daymatrix, SIGNAL( selected( const KCal::DateList & ) ), |
113 | SIGNAL( datesSelected( const KCal::DateList & ) ) ); | 108 | SIGNAL( datesSelected( const KCal::DateList & ) ) ); |
114 | 109 | ||
115 | connect( daymatrix, SIGNAL( eventDropped( Event * ) ), | 110 | connect( daymatrix, SIGNAL( eventDropped( Event * ) ), |
116 | SIGNAL( eventDropped( Event * ) ) ); | 111 | SIGNAL( eventDropped( Event * ) ) ); |
117 | 112 | ||
118 | topLayout->addMultiCellWidget(daymatrix,2,7,1,7); | 113 | topLayout->addMultiCellWidget(daymatrix,2,7,1,7); |
119 | 114 | ||
120 | // read settings from configuration file. | 115 | // read settings from configuration file. |
121 | updateConfig(); | 116 | updateConfig(); |
122 | enableRollover(FollowMonth); | 117 | enableRollover(FollowMonth); |
123 | setFixedSize ( sizeHint() ); | 118 | //setFixedSize ( sizeHint() ); |
119 | } | ||
120 | void KDateNavigator::setCalendar( Calendar *cal ) | ||
121 | { | ||
122 | daymatrix->setCalendar( cal ); | ||
123 | } | ||
124 | |||
125 | void KDateNavigator::setBaseDate( const QDate &date ) | ||
126 | { | ||
127 | m_MthYr = date; | ||
128 | |||
129 | updateDates(); | ||
130 | updateView(); | ||
131 | |||
132 | KCal::DateList dates; | ||
133 | dates.append( date ); | ||
134 | mNavigatorBar->selectDates( dates ); | ||
135 | |||
136 | daymatrix->clearSelection(); | ||
137 | daymatrix->repaint(); | ||
124 | } | 138 | } |
125 | 139 | ||
126 | void KDateNavigator::enableRollover(RolloverType r) | 140 | void KDateNavigator::enableRollover(RolloverType r) |
127 | { | 141 | { |
128 | switch(r) | 142 | switch(r) |
129 | { | 143 | { |
130 | case None : | 144 | case None : |
131 | if (updateTimer) | 145 | if (updateTimer) |
132 | { | 146 | { |
133 | updateTimer->stop(); | 147 | updateTimer->stop(); |
134 | delete updateTimer; | 148 | delete updateTimer; |
135 | updateTimer=0L; | 149 | updateTimer=0L; |