author | zautrix <zautrix> | 2005-03-22 16:21:03 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-03-22 16:21:03 (UTC) |
commit | ab8db23d665b276caa28471bb4db37e6b0de44ef (patch) (unidiff) | |
tree | 4697da2d9426f155237614368f993328560d0b21 | |
parent | f36f0308a955f869f18c88ab359f9d605e838f1c (diff) | |
download | kdepimpi-ab8db23d665b276caa28471bb4db37e6b0de44ef.zip kdepimpi-ab8db23d665b276caa28471bb4db37e6b0de44ef.tar.gz kdepimpi-ab8db23d665b276caa28471bb4db37e6b0de44ef.tar.bz2 |
fix
-rw-r--r-- | korganizer/datenavigatorcontainer.cpp | 35 | ||||
-rw-r--r-- | korganizer/datenavigatorcontainer.h | 2 | ||||
-rw-r--r-- | korganizer/kodaymatrix.cpp | 21 |
3 files changed, 33 insertions, 25 deletions
diff --git a/korganizer/datenavigatorcontainer.cpp b/korganizer/datenavigatorcontainer.cpp index 9720146..ba97fa6 100644 --- a/korganizer/datenavigatorcontainer.cpp +++ b/korganizer/datenavigatorcontainer.cpp | |||
@@ -1,386 +1,391 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | 3 | ||
4 | Copyright (c) 2001,2002,2003 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2001,2002,2003 Cornelius Schumacher <schumacher@kde.org> |
5 | Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com> | 5 | Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com> |
6 | 6 | ||
7 | This program is free software; you can redistribute it and/or modify | 7 | This program is free software; you can redistribute it and/or modify |
8 | it under the terms of the GNU General Public License as published by | 8 | it under the terms of the GNU General Public License as published by |
9 | the Free Software Foundation; either version 2 of the License, or | 9 | the Free Software Foundation; either version 2 of the License, or |
10 | (at your option) any later version. | 10 | (at your option) any later version. |
11 | 11 | ||
12 | This program is distributed in the hope that it will be useful, | 12 | This program is distributed in the hope that it will be useful, |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | GNU General Public License for more details. | 15 | GNU General Public License for more details. |
16 | 16 | ||
17 | You should have received a copy of the GNU General Public License | 17 | You should have received a copy of the GNU General Public License |
18 | along with this program; if not, write to the Free Software | 18 | along with this program; if not, write to the Free Software |
19 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 19 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
20 | 20 | ||
21 | As a special exception, permission is given to link this program | 21 | As a special exception, permission is given to link this program |
22 | with any edition of Qt, and distribute the resulting executable, | 22 | with any edition of Qt, and distribute the resulting executable, |
23 | without including the source code for Qt in the source distribution. | 23 | without including the source code for Qt in the source distribution. |
24 | */ | 24 | */ |
25 | 25 | ||
26 | #include <kdebug.h> | 26 | #include <kdebug.h> |
27 | #include <klocale.h> | 27 | #include <klocale.h> |
28 | 28 | ||
29 | //#include "koglobals.h" | 29 | //#include "koglobals.h" |
30 | #include "navigatorbar.h" | 30 | #include "navigatorbar.h" |
31 | #include "kdatenavigator.h" | 31 | #include "kdatenavigator.h" |
32 | 32 | ||
33 | #include <kcalendarsystem.h> | 33 | #include <kcalendarsystem.h> |
34 | 34 | ||
35 | #include "datenavigatorcontainer.h" | 35 | #include "datenavigatorcontainer.h" |
36 | #include "koprefs.h" | 36 | #include "koprefs.h" |
37 | 37 | ||
38 | DateNavigatorContainer::DateNavigatorContainer( QWidget *parent, | 38 | DateNavigatorContainer::DateNavigatorContainer( QWidget *parent, |
39 | const char *name ) | 39 | const char *name ) |
40 | : QWidget( parent, name ), mCalendar( 0 ), | 40 | : QWidget( parent, name ), mCalendar( 0 ), |
41 | mHorizontalCount( 1 ), mVerticalCount( 1 ) | 41 | mHorizontalCount( 1 ), mVerticalCount( 1 ) |
42 | { | 42 | { |
43 | mExtraViews.setAutoDelete( true ); | 43 | mExtraViews.setAutoDelete( true ); |
44 | 44 | ||
45 | mNavigatorView = new KDateNavigator( this, name ); | 45 | mNavigatorView = new KDateNavigator( this, name ); |
46 | 46 | ||
47 | connectNavigatorView( mNavigatorView ); | 47 | connectNavigatorView( mNavigatorView ); |
48 | //setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); | 48 | //setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); |
49 | mLastDisplayedDN = 0; | 49 | mLastDisplayedDN = 0; |
50 | mUpdateTimer; | ||
51 | mUpdateTimer = new QTimer( this ); | ||
52 | connect (mUpdateTimer ,SIGNAL(timeout()), this, SLOT ( checkUpdateDayMatrixDates() )); | ||
50 | } | 53 | } |
51 | 54 | ||
52 | DateNavigatorContainer::~DateNavigatorContainer() | 55 | DateNavigatorContainer::~DateNavigatorContainer() |
53 | { | 56 | { |
54 | } | 57 | } |
55 | 58 | ||
56 | void DateNavigatorContainer::connectNavigatorView( KDateNavigator *v ) | 59 | void DateNavigatorContainer::connectNavigatorView( KDateNavigator *v ) |
57 | { | 60 | { |
58 | connect( v, SIGNAL( datesSelected( const KCal::DateList & ) ), | 61 | connect( v, SIGNAL( datesSelected( const KCal::DateList & ) ), |
59 | SIGNAL( datesSelected( const KCal::DateList & ) ) ); | 62 | SIGNAL( datesSelected( const KCal::DateList & ) ) ); |
60 | #if 0 | 63 | #if 0 |
61 | connect( v, SIGNAL( incidenceDropped( Incidence *, const QDate & ) ), | 64 | connect( v, SIGNAL( incidenceDropped( Incidence *, const QDate & ) ), |
62 | SIGNAL( incidenceDropped( Incidence *, const QDate & ) ) ); | 65 | SIGNAL( incidenceDropped( Incidence *, const QDate & ) ) ); |
63 | connect( v, SIGNAL( incidenceDroppedMove( Incidence *, const QDate & ) ), | 66 | connect( v, SIGNAL( incidenceDroppedMove( Incidence *, const QDate & ) ), |
64 | SIGNAL( incidenceDroppedMove( Incidence *, const QDate & ) ) ); | 67 | SIGNAL( incidenceDroppedMove( Incidence *, const QDate & ) ) ); |
65 | #endif | 68 | #endif |
66 | connect( v, SIGNAL( weekClicked( const QDate & ) ), | 69 | connect( v, SIGNAL( weekClicked( const QDate & ) ), |
67 | SIGNAL( weekClicked( const QDate & ) ) ); | 70 | SIGNAL( weekClicked( const QDate & ) ) ); |
68 | 71 | ||
69 | connect( v, SIGNAL( goPrevious() ), SIGNAL( goPrevious() ) ); | 72 | connect( v, SIGNAL( goPrevious() ), SIGNAL( goPrevious() ) ); |
70 | connect( v, SIGNAL( goNext() ), SIGNAL( goNext() ) ); | 73 | connect( v, SIGNAL( goNext() ), SIGNAL( goNext() ) ); |
71 | 74 | ||
72 | connect( v, SIGNAL( goNextMonth() ), SIGNAL( goNextMonth() ) ); | 75 | connect( v, SIGNAL( goNextMonth() ), SIGNAL( goNextMonth() ) ); |
73 | connect( v, SIGNAL( goPrevMonth() ), SIGNAL( goPrevMonth() ) ); | 76 | connect( v, SIGNAL( goPrevMonth() ), SIGNAL( goPrevMonth() ) ); |
74 | connect( v, SIGNAL( goNextYear() ), SIGNAL( goNextYear() ) ); | 77 | connect( v, SIGNAL( goNextYear() ), SIGNAL( goNextYear() ) ); |
75 | connect( v, SIGNAL( goPrevYear() ), SIGNAL( goPrevYear() ) ); | 78 | connect( v, SIGNAL( goPrevYear() ), SIGNAL( goPrevYear() ) ); |
76 | 79 | ||
77 | connect( v, SIGNAL( monthSelected( int ) ), SLOT( slotMonthSelected( int ) ) ); | 80 | connect( v, SIGNAL( monthSelected( int ) ), SLOT( slotMonthSelected( int ) ) ); |
78 | } | 81 | } |
79 | 82 | ||
80 | void DateNavigatorContainer::slotMonthSelected( int month ) | 83 | void DateNavigatorContainer::slotMonthSelected( int month ) |
81 | { | 84 | { |
82 | //qDebug("slotMonthSelected %d ", month); | 85 | //qDebug("slotMonthSelected %d ", month); |
83 | QDate baseDate = mNavigatorView->baseDate(); | 86 | QDate baseDate = mNavigatorView->baseDate(); |
84 | if ( baseDate.month() == month ) | 87 | if ( baseDate.month() == month ) |
85 | return; | 88 | return; |
86 | //qDebug("month %d %d ",baseDate.month(),month); | 89 | //qDebug("month %d %d ",baseDate.month(),month); |
87 | QDate date = QDate ( baseDate.year(), baseDate.month() , 15 ); | 90 | QDate date = QDate ( baseDate.year(), baseDate.month() , 15 ); |
88 | date = date.addDays( -(baseDate.month()-month ) *30 ); | 91 | date = date.addDays( -(baseDate.month()-month ) *30 ); |
89 | QDate newBase = QDate ( date.year(), date.month() , baseDate.day() ); | 92 | QDate newBase = QDate ( date.year(), date.month() , baseDate.day() ); |
90 | 93 | ||
91 | #if 0 | 94 | #if 0 |
92 | mFirstSelectedDate = dateList.first() ; | 95 | mFirstSelectedDate = dateList.first() ; |
93 | mSelectedDateCount = dateList.count() ; | 96 | mSelectedDateCount = dateList.count() ; |
94 | 97 | ||
95 | KDateNavigator *view = mExtraViews.at( 0 ); | 98 | KDateNavigator *view = mExtraViews.at( 0 ); |
96 | QDate date = view->baseDate(); | 99 | QDate date = view->baseDate(); |
97 | 100 | ||
98 | QDate curEnd = date.addDays( (mLastDisplayedDN)*30 +7); | 101 | QDate curEnd = date.addDays( (mLastDisplayedDN)*30 +7); |
99 | //qDebug("End %s %s ",lDate.toString().latin1(),curEnd.toString().latin1() ); | 102 | //qDebug("End %s %s ",lDate.toString().latin1(),curEnd.toString().latin1() ); |
100 | if ( lDate < curEnd && date.addDays( -30 ) < fDate) { | 103 | if ( lDate < curEnd && date.addDays( -30 ) < fDate) { |
101 | mNavigatorView->dayMatrix()->setSelectedDaysFrom( fDate , lDate ); | 104 | mNavigatorView->dayMatrix()->setSelectedDaysFrom( fDate , lDate ); |
102 | mNavigatorView->dayMatrix()->repaint( false ); | 105 | mNavigatorView->dayMatrix()->repaint( false ); |
103 | for( uint i = 0; i < mLastDisplayedDN; ++i ) { | 106 | for( uint i = 0; i < mLastDisplayedDN; ++i ) { |
104 | KDateNavigator *n = mExtraViews.at( i ); | 107 | KDateNavigator *n = mExtraViews.at( i ); |
105 | if ( n->dayMatrix()->setSelectedDaysFrom( fDate , lDate ) ) { | 108 | if ( n->dayMatrix()->setSelectedDaysFrom( fDate , lDate ) ) { |
106 | n->dayMatrix()->repaint( false ); | 109 | n->dayMatrix()->repaint( false ); |
107 | } | 110 | } |
108 | } | 111 | } |
109 | return; | 112 | return; |
110 | } | 113 | } |
111 | #endif | 114 | #endif |
112 | //qDebug("NEW BASE %s", newBase.toString().latin1()); | 115 | //qDebug("NEW BASE %s", newBase.toString().latin1()); |
113 | mNavigatorView->setBaseDate( newBase ); | 116 | mNavigatorView->setBaseDate( newBase ); |
114 | QDate last = lastAvailableDate(); | 117 | QDate last = lastAvailableDate(); |
115 | QDate first = firstAvailableDate(); | 118 | QDate first = firstAvailableDate(); |
116 | 119 | ||
117 | QDate selFirst = mFirstSelectedDate; | 120 | QDate selFirst = mFirstSelectedDate; |
118 | QDate selLast = selFirst.addDays( mSelectedDateCount-1 ); | 121 | QDate selLast = selFirst.addDays( mSelectedDateCount-1 ); |
119 | if ( selFirst >= first && selLast <= last ) { | 122 | if ( selFirst >= first && selLast <= last ) { |
120 | setBaseDates(); | 123 | setBaseDates(); |
121 | updateDayMatrixDates(); | 124 | updateDayMatrixDates(); |
122 | } | 125 | } |
123 | else { | 126 | else { |
124 | setBaseDates(); | 127 | setBaseDates(); |
125 | updateDayMatrixDates(); | 128 | updateDayMatrixDates(); |
126 | emit monthSelected( month ); | 129 | emit monthSelected( month ); |
127 | } | 130 | } |
128 | } | 131 | } |
129 | void DateNavigatorContainer::setCalendar( Calendar *cal ) | 132 | void DateNavigatorContainer::setCalendar( Calendar *cal ) |
130 | { | 133 | { |
131 | mCalendar = cal; | 134 | mCalendar = cal; |
132 | mNavigatorView->setCalendar( cal ); | 135 | mNavigatorView->setCalendar( cal ); |
133 | for( uint i = 0; i < mLastDisplayedDN; ++i ) { | 136 | for( uint i = 0; i < mLastDisplayedDN; ++i ) { |
134 | KDateNavigator *n = mExtraViews.at( i ); | 137 | KDateNavigator *n = mExtraViews.at( i ); |
135 | n->setCalendar( cal ); | 138 | n->setCalendar( cal ); |
136 | } | 139 | } |
137 | } | 140 | } |
141 | void DateNavigatorContainer::checkUpdateDayMatrixDates() | ||
142 | { | ||
143 | QDate last = lastAvailableDate(); | ||
144 | QDate first = firstAvailableDate(); | ||
145 | |||
146 | QDate selFirst = mFirstSelectedDate; | ||
147 | QDate selLast = selFirst.addDays( mSelectedDateCount-1 ); | ||
148 | if ( selFirst >= first && selLast <= last ) { | ||
149 | updateDayMatrixDates(); | ||
150 | } | ||
151 | else { | ||
152 | updateDayMatrixDates(); | ||
153 | emit monthSelected( mFirstSelectedDate.month() ); | ||
154 | } | ||
155 | } | ||
138 | void DateNavigatorContainer::updateDayMatrixDates() | 156 | void DateNavigatorContainer::updateDayMatrixDates() |
139 | { | 157 | { |
140 | 158 | mUpdateTimer->stop(); | |
141 | QDate fDate = mFirstSelectedDate; | 159 | QDate fDate = mFirstSelectedDate; |
142 | QDate lDate = fDate.addDays( mSelectedDateCount - 1 ); | 160 | QDate lDate = fDate.addDays( mSelectedDateCount - 1 ); |
143 | mNavigatorView->dayMatrix()->setSelectedDaysFrom( fDate , lDate ); | 161 | mNavigatorView->dayMatrix()->setSelectedDaysFrom( fDate , lDate ); |
144 | mNavigatorView->dayMatrix()->repaint( false ); | 162 | mNavigatorView->dayMatrix()->repaint( false ); |
145 | for( uint i = 0; i < mLastDisplayedDN; ++i ) { | 163 | for( uint i = 0; i < mLastDisplayedDN; ++i ) { |
146 | KDateNavigator *n = mExtraViews.at( i ); | 164 | KDateNavigator *n = mExtraViews.at( i ); |
147 | if ( n->dayMatrix()->setSelectedDaysFrom( fDate , lDate ) ) { | 165 | if ( n->dayMatrix()->setSelectedDaysFrom( fDate , lDate ) ) { |
148 | n->dayMatrix()->repaint( false ); | 166 | n->dayMatrix()->repaint( false ); |
149 | } | 167 | } |
150 | } | 168 | } |
151 | } | 169 | } |
152 | 170 | ||
153 | void DateNavigatorContainer::updateDayMatrix() | 171 | void DateNavigatorContainer::updateDayMatrix() |
154 | { | 172 | { |
155 | mNavigatorView->updateDayMatrix(); | 173 | mNavigatorView->updateDayMatrix(); |
156 | for( uint i = 0; i < mLastDisplayedDN; ++i ) { | 174 | for( uint i = 0; i < mLastDisplayedDN; ++i ) { |
157 | KDateNavigator *n = mExtraViews.at( i ); | 175 | KDateNavigator *n = mExtraViews.at( i ); |
158 | n->updateDayMatrix(); | 176 | n->updateDayMatrix(); |
159 | } | 177 | } |
160 | } | 178 | } |
161 | 179 | ||
162 | void DateNavigatorContainer::updateToday() | 180 | void DateNavigatorContainer::updateToday() |
163 | { | 181 | { |
164 | qDebug("DateNavigatorContainer::updateToday() NOT IMPL "); | 182 | qDebug("DateNavigatorContainer::updateToday() NOT IMPL "); |
165 | #if 0 | 183 | #if 0 |
166 | mNavigatorView->updateToday(); | 184 | mNavigatorView->updateToday(); |
167 | KDateNavigator *n; | 185 | KDateNavigator *n; |
168 | for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { | 186 | for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { |
169 | n->updateToday(); | 187 | n->updateToday(); |
170 | } | 188 | } |
171 | #endif | 189 | #endif |
172 | } | 190 | } |
173 | 191 | ||
174 | void DateNavigatorContainer::updateView() | 192 | void DateNavigatorContainer::updateView() |
175 | { | 193 | { |
176 | mNavigatorView->updateView(); | 194 | mNavigatorView->updateView(); |
177 | for( uint i = 0; i < mLastDisplayedDN; ++i ) { | 195 | for( uint i = 0; i < mLastDisplayedDN; ++i ) { |
178 | KDateNavigator *n = mExtraViews.at( i ); | 196 | KDateNavigator *n = mExtraViews.at( i ); |
179 | n->updateView(); | 197 | n->updateView(); |
180 | } | 198 | } |
181 | } | 199 | } |
182 | 200 | ||
183 | void DateNavigatorContainer::updateConfig() | 201 | void DateNavigatorContainer::updateConfig() |
184 | { | 202 | { |
185 | mNavigatorView->updateConfig(); | 203 | mNavigatorView->updateConfig(); |
186 | for( uint i = 0; i < mLastDisplayedDN; ++i ) { | 204 | for( uint i = 0; i < mLastDisplayedDN; ++i ) { |
187 | KDateNavigator *n = mExtraViews.at( i ); | 205 | KDateNavigator *n = mExtraViews.at( i ); |
188 | n->updateConfig(); | 206 | n->updateConfig(); |
189 | } | 207 | } |
190 | } | 208 | } |
191 | QDate DateNavigatorContainer::lastAvailableDate() const | 209 | QDate DateNavigatorContainer::lastAvailableDate() const |
192 | { | 210 | { |
193 | QDate date = mNavigatorView->baseDate(); | 211 | QDate date = mNavigatorView->baseDate(); |
194 | QDate last = QDate ( date.year(), date.month(), date.daysInMonth() ); | 212 | QDate last = QDate ( date.year(), date.month(), date.daysInMonth() ); |
195 | int iii = mLastDisplayedDN; | 213 | int iii = mLastDisplayedDN; |
196 | if ( mLastDisplayedDN ) | 214 | if ( mLastDisplayedDN ) |
197 | last = last.addDays( 1); | 215 | last = last.addDays( 1); |
198 | while ( iii ) { | 216 | while ( iii ) { |
199 | last = last.addDays( last.daysInMonth ()); | 217 | last = last.addDays( last.daysInMonth ()); |
200 | //qDebug("DATE %s ", last.toString().latin1() ); | 218 | //qDebug("DATE %s ", last.toString().latin1() ); |
201 | --iii; | 219 | --iii; |
202 | } | 220 | } |
203 | if ( mLastDisplayedDN ) | 221 | if ( mLastDisplayedDN ) |
204 | last = last.addDays( -1); | 222 | last = last.addDays( -1); |
205 | return last; | 223 | return last; |
206 | } | 224 | } |
207 | QDate DateNavigatorContainer::firstAvailableDate() const | 225 | QDate DateNavigatorContainer::firstAvailableDate() const |
208 | { | 226 | { |
209 | return QDate ( mNavigatorView->baseDate().year(), mNavigatorView->baseDate().month(), 1 ); | 227 | return QDate ( mNavigatorView->baseDate().year(), mNavigatorView->baseDate().month(), 1 ); |
210 | } | 228 | } |
211 | void DateNavigatorContainer::selectDates( const DateList &dateList ) | 229 | void DateNavigatorContainer::selectDates( const DateList &dateList ) |
212 | { | 230 | { |
213 | mFirstSelectedDate = dateList.first() ; | 231 | mFirstSelectedDate = dateList.first() ; |
214 | mSelectedDateCount = dateList.count() ; | 232 | mSelectedDateCount = dateList.count() ; |
215 | if ( !mLastDisplayedDN ) { | 233 | if ( !mLastDisplayedDN ) { |
216 | mNavigatorView->selectDates( dateList ); | 234 | mNavigatorView->selectDates( dateList ); |
217 | return; | 235 | return; |
218 | } | 236 | } |
219 | QDate fDate = dateList.first(); | 237 | QDate fDate = dateList.first(); |
220 | QDate lDate = dateList.last(); | 238 | QDate lDate = dateList.last(); |
221 | if ( mLastDisplayedDN <= 2 ) { | ||
222 | mNavigatorView->selectDates( dateList ); | ||
223 | KDateNavigator *view = mExtraViews.at( 0 ); | ||
224 | QDate bDate = fDate.addDays( fDate.daysInMonth () - fDate.day() +1 ); | ||
225 | view->setBaseDate( bDate, false ); | ||
226 | view->dayMatrix()->setSelectedDaysFrom(fDate , lDate); | ||
227 | if ( mLastDisplayedDN == 2 ) { | ||
228 | view = mExtraViews.at( 1 ); | ||
229 | bDate = bDate.addDays( bDate.daysInMonth () - bDate.day() +1 ); | ||
230 | view->setBaseDate( bDate, false ); | ||
231 | view->dayMatrix()->setSelectedDaysFrom(fDate , lDate); | ||
232 | } | ||
233 | return; | ||
234 | } | ||
235 | //qDebug("%s %s ", lastAvailableDate().toString().latin1(), firstAvailableDate().toString().latin1() ); | 239 | //qDebug("%s %s ", lastAvailableDate().toString().latin1(), firstAvailableDate().toString().latin1() ); |
236 | //qDebug("End %s %s ",lDate.toString().latin1(),curEnd.toString().latin1() ); | 240 | //qDebug("End %s %s ",lDate.toString().latin1(),curEnd.toString().latin1() ); |
237 | if ( lDate <= lastAvailableDate() && firstAvailableDate() <= fDate) { | 241 | if ( lDate <= lastAvailableDate() && firstAvailableDate() <= fDate) { |
238 | updateDayMatrixDates(); | 242 | updateDayMatrixDates(); |
239 | return; | 243 | return; |
240 | } | 244 | } |
241 | mNavigatorView->selectDates( dateList ); | 245 | mNavigatorView->selectDates( dateList ); |
242 | setBaseDates(); | 246 | setBaseDates(); |
243 | if ( mLastDisplayedDN ) { | 247 | if ( mLastDisplayedDN ) { |
244 | KDateNavigator *view = mExtraViews.at( 0 ); | 248 | KDateNavigator *view = mExtraViews.at( 0 ); |
245 | view->dayMatrix()->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end())); | 249 | view->dayMatrix()->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end())); |
246 | view->dayMatrix()->repaint( false ); | 250 | view->dayMatrix()->repaint( false ); |
247 | if ( mLastDisplayedDN > 1 ) { | 251 | if ( mLastDisplayedDN > 1 ) { |
248 | KDateNavigator *view = mExtraViews.at( 1 ); | 252 | KDateNavigator *view = mExtraViews.at( 1 ); |
249 | view->dayMatrix()->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end())); | 253 | view->dayMatrix()->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end())); |
250 | view->dayMatrix()->repaint( false ); | 254 | view->dayMatrix()->repaint( false ); |
251 | } | 255 | } |
252 | } | 256 | } |
253 | } | 257 | } |
254 | 258 | ||
255 | void DateNavigatorContainer::setBaseDates() | 259 | void DateNavigatorContainer::setBaseDates() |
256 | { | 260 | { |
257 | QDate baseDate = mNavigatorView->baseDate(); | 261 | QDate baseDate = mNavigatorView->baseDate(); |
258 | bool doRepaint = true; | 262 | bool doRepaint = true; |
259 | for( uint i = 0; i < mLastDisplayedDN; ++i ) { | 263 | for( uint i = 0; i < mLastDisplayedDN; ++i ) { |
260 | KDateNavigator *n = mExtraViews.at( i ); | 264 | KDateNavigator *n = mExtraViews.at( i ); |
261 | baseDate = baseDate.addDays( baseDate.daysInMonth () - baseDate.day() +1 ); | 265 | baseDate = baseDate.addDays( baseDate.daysInMonth () - baseDate.day() +1 ); |
262 | n->setBaseDate( baseDate, doRepaint ); | 266 | n->setBaseDate( baseDate, doRepaint ); |
263 | } | 267 | } |
264 | } | 268 | } |
265 | 269 | ||
266 | void DateNavigatorContainer::resizeEvent( QResizeEvent * e ) | 270 | void DateNavigatorContainer::resizeEvent( QResizeEvent * e ) |
267 | { | 271 | { |
268 | #if 0 | 272 | #if 0 |
269 | kdDebug(5850) << "DateNavigatorContainer::resizeEvent()" << endl; | 273 | kdDebug(5850) << "DateNavigatorContainer::resizeEvent()" << endl; |
270 | kdDebug(5850) << " CURRENT SIZE: " << size() << endl; | 274 | kdDebug(5850) << " CURRENT SIZE: " << size() << endl; |
271 | kdDebug(5850) << " MINIMUM SIZEHINT: " << minimumSizeHint() << endl; | 275 | kdDebug(5850) << " MINIMUM SIZEHINT: " << minimumSizeHint() << endl; |
272 | kdDebug(5850) << " SIZEHINT: " << sizeHint() << endl; | 276 | kdDebug(5850) << " SIZEHINT: " << sizeHint() << endl; |
273 | kdDebug(5850) << " MINIMUM SIZE: " << minimumSize() << endl; | 277 | kdDebug(5850) << " MINIMUM SIZE: " << minimumSize() << endl; |
274 | #endif | 278 | #endif |
275 | //QSize minSize = mNavigatorView->sizeHintTwoButtons(); | 279 | //QSize minSize = mNavigatorView->sizeHintTwoButtons(); |
276 | QSize minSize = mNavigatorView->yourSizeHint(); | 280 | QSize minSize = mNavigatorView->yourSizeHint(); |
277 | 281 | ||
278 | // kdDebug(5850) << " NAVIGATORVIEW minimumSizeHint: " << minSize << endl; | 282 | // kdDebug(5850) << " NAVIGATORVIEW minimumSizeHint: " << minSize << endl; |
279 | 283 | ||
280 | int verticalCount = size().height() / minSize.height(); | 284 | int verticalCount = size().height() / minSize.height(); |
281 | int horizontalCount = size().width() / minSize.width(); | 285 | int horizontalCount = size().width() / minSize.width(); |
282 | //qDebug(" wattdatt %d new %d %d ", size().width() ,e->size().width() , minSize.width() ); | 286 | //qDebug(" wattdatt %d new %d %d ", size().width() ,e->size().width() , minSize.width() ); |
283 | //qDebug("COUNT %d %d %d %d ", verticalCount, horizontalCount , mVerticalCount, mHorizontalCount ); | 287 | //qDebug("COUNT %d %d %d %d ", verticalCount, horizontalCount , mVerticalCount, mHorizontalCount ); |
284 | bool fontchange = false; | 288 | bool fontchange = false; |
285 | if ( horizontalCount == 1) | 289 | if ( horizontalCount == 1) |
286 | horizontalCount = size().width() / mNavigatorView->yourFullSizeHint().width(); | 290 | horizontalCount = size().width() / mNavigatorView->yourFullSizeHint().width(); |
287 | QFont fo; | 291 | QFont fo; |
288 | if ( horizontalCount != mHorizontalCount || | 292 | if ( horizontalCount != mHorizontalCount || |
289 | verticalCount != mVerticalCount ) { | 293 | verticalCount != mVerticalCount ) { |
290 | uint count = horizontalCount * verticalCount; | 294 | uint count = horizontalCount * verticalCount; |
291 | if ( count == 0 ) { | 295 | if ( count == 0 ) { |
292 | bool ok; | 296 | bool ok; |
293 | fo = mNavigatorView->yourFontHint( size() , &ok ); | 297 | fo = mNavigatorView->yourFontHint( size() , &ok ); |
294 | //mNavigatorView->resize( size() ); | 298 | //mNavigatorView->resize( size() ); |
295 | //if ( ! ok ) | 299 | //if ( ! ok ) |
296 | // return; | 300 | // return; |
297 | int butt = 2; | 301 | int butt = 2; |
298 | horizontalCount = size().width() / mNavigatorView->sizeHintTwoButtons( ).width(); | 302 | horizontalCount = size().width() / mNavigatorView->sizeHintTwoButtons( ).width(); |
299 | if ( horizontalCount <= 1 ) | 303 | if ( horizontalCount <= 1 ) |
300 | minSize = mNavigatorView->sizeHintTwoButtons( 4 ); | 304 | minSize = mNavigatorView->sizeHintTwoButtons( 4 ); |
301 | else | 305 | else |
302 | minSize = mNavigatorView->sizeHintTwoButtons(); | 306 | minSize = mNavigatorView->sizeHintTwoButtons(); |
303 | verticalCount = size().height() / minSize.height(); | 307 | verticalCount = size().height() / minSize.height(); |
304 | horizontalCount = size().width() / minSize.width(); | 308 | horizontalCount = size().width() / minSize.width(); |
305 | if ( horizontalCount == 0 ) | 309 | if ( horizontalCount == 0 ) |
306 | horizontalCount = 1; | 310 | horizontalCount = 1; |
307 | if ( verticalCount == 0 ) | 311 | if ( verticalCount == 0 ) |
308 | verticalCount = 1; | 312 | verticalCount = 1; |
309 | fontchange = true; | 313 | fontchange = true; |
310 | count = horizontalCount * verticalCount; | 314 | count = horizontalCount * verticalCount; |
311 | } else { | 315 | } else { |
312 | if ( mNavigatorView->fontChanged() ) { | 316 | if ( mNavigatorView->fontChanged() ) { |
313 | fontchange = true; | 317 | fontchange = true; |
314 | fo = KOPrefs::instance()->mDateNavigatorFont; | 318 | fo = KOPrefs::instance()->mDateNavigatorFont; |
315 | mNavigatorView->changeFont( fo ); | 319 | mNavigatorView->changeFont( fo ); |
316 | mNavigatorView->unsetFontChanged(); | 320 | mNavigatorView->unsetFontChanged(); |
317 | } | 321 | } |
318 | } | 322 | } |
319 | 323 | ||
320 | mLastDisplayedDN = horizontalCount*verticalCount-1; | 324 | mLastDisplayedDN = horizontalCount*verticalCount-1; |
321 | while ( count > ( mExtraViews.count() + 1 ) ) { | 325 | while ( count > ( mExtraViews.count() + 1 ) ) { |
322 | KDateNavigator *n = new KDateNavigator( this ); | 326 | KDateNavigator *n = new KDateNavigator( this ); |
323 | n->setMonthSignalOffset ( mExtraViews.count()+1 ); | 327 | n->setMonthSignalOffset ( mExtraViews.count()+1 ); |
324 | mExtraViews.append( n ); | 328 | mExtraViews.append( n ); |
325 | n->setCalendar( mCalendar ); | 329 | n->setCalendar( mCalendar ); |
326 | connectNavigatorView( n ); | 330 | connectNavigatorView( n ); |
327 | n->show(); | 331 | n->show(); |
328 | } | 332 | } |
329 | int iii = 0; | 333 | int iii = 0; |
330 | while ( iii < ( mExtraViews.count() ) ) { | 334 | while ( iii < ( mExtraViews.count() ) ) { |
331 | if ( iii < count-1 ) | 335 | if ( iii < count-1 ) |
332 | mExtraViews.at( iii )->show(); | 336 | mExtraViews.at( iii )->show(); |
333 | else | 337 | else |
334 | mExtraViews.at( iii )->hide(); | 338 | mExtraViews.at( iii )->hide(); |
335 | ++iii; | 339 | ++iii; |
336 | } | 340 | } |
337 | 341 | ||
338 | setBaseDates(); | 342 | setBaseDates(); |
339 | if ( fontchange ) { | 343 | if ( fontchange ) { |
340 | //mNavigatorView->changeFont( fo ); | 344 | //mNavigatorView->changeFont( fo ); |
341 | uint i; | 345 | uint i; |
342 | for( i = 0; i < mExtraViews.count(); ++i ) { | 346 | for( i = 0; i < mExtraViews.count(); ++i ) { |
343 | KDateNavigator *view = mExtraViews.at( i ); | 347 | KDateNavigator *view = mExtraViews.at( i ); |
344 | view->changeFont( fo ); | 348 | view->changeFont( fo ); |
345 | } | 349 | } |
346 | } | 350 | } |
347 | mHorizontalCount = horizontalCount; | 351 | mHorizontalCount = horizontalCount; |
348 | mVerticalCount = verticalCount; | 352 | mVerticalCount = verticalCount; |
349 | 353 | ||
350 | } | 354 | } |
351 | //qDebug("COUNT %d ", mExtraViews.count()); | 355 | //qDebug("COUNT %d ", mExtraViews.count()); |
352 | int height = size().height() / verticalCount; | 356 | int height = size().height() / verticalCount; |
353 | int width = size().width() / horizontalCount; | 357 | int width = size().width() / horizontalCount; |
354 | 358 | ||
355 | NavigatorBar *bar = mNavigatorView->navigatorBar(); | 359 | NavigatorBar *bar = mNavigatorView->navigatorBar(); |
356 | if ( horizontalCount > 1 ) bar->showButtons( true, false ); | 360 | if ( horizontalCount > 1 ) bar->showButtons( true, false ); |
357 | else bar->showButtons( true, true ); | 361 | else bar->showButtons( true, true ); |
358 | 362 | ||
359 | mNavigatorView->setGeometry(0, | 363 | mNavigatorView->setGeometry(0, |
360 | 0, width, height ); | 364 | 0, width, height ); |
361 | for( uint i = 0; i < mLastDisplayedDN; ++i ) { | 365 | for( uint i = 0; i < mLastDisplayedDN; ++i ) { |
362 | int x = ( i + 1 ) % horizontalCount; | 366 | int x = ( i + 1 ) % horizontalCount; |
363 | int y = ( i + 1 ) / horizontalCount; | 367 | int y = ( i + 1 ) / horizontalCount; |
364 | 368 | ||
365 | KDateNavigator *view = mExtraViews.at( i ); | 369 | KDateNavigator *view = mExtraViews.at( i ); |
366 | bar = view->navigatorBar(); | 370 | bar = view->navigatorBar(); |
367 | if ( y > 0 ) bar->showButtons( false, false ); | 371 | if ( y > 0 ) bar->showButtons( false, false ); |
368 | else { | 372 | else { |
369 | if ( x + 1 == horizontalCount ) bar->showButtons( false, true ); | 373 | if ( x + 1 == horizontalCount ) bar->showButtons( false, true ); |
370 | else bar->showButtons( false, false ); | 374 | else bar->showButtons( false, false ); |
371 | } | 375 | } |
372 | view->setGeometry( x * width, | 376 | view->setGeometry( x * width, |
373 | y * height, width, height ); | 377 | y * height, width, height ); |
374 | } | 378 | } |
379 | mUpdateTimer->start( 250 ); | ||
375 | //updateDayMatrixDates(); | 380 | //updateDayMatrixDates(); |
376 | } | 381 | } |
377 | 382 | ||
378 | QSize DateNavigatorContainer::minimumSizeHint() const | 383 | QSize DateNavigatorContainer::minimumSizeHint() const |
379 | { | 384 | { |
380 | return mNavigatorView->minimumSizeHint(); | 385 | return mNavigatorView->minimumSizeHint(); |
381 | } | 386 | } |
382 | 387 | ||
383 | QSize DateNavigatorContainer::sizeHint() const | 388 | QSize DateNavigatorContainer::sizeHint() const |
384 | { | 389 | { |
385 | return mNavigatorView->yourSizeHint(); | 390 | return mNavigatorView->yourSizeHint(); |
386 | } | 391 | } |
diff --git a/korganizer/datenavigatorcontainer.h b/korganizer/datenavigatorcontainer.h index d5e5adf..df8efae 100644 --- a/korganizer/datenavigatorcontainer.h +++ b/korganizer/datenavigatorcontainer.h | |||
@@ -1,97 +1,99 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | 3 | ||
4 | Copyright (c) 2004 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2004 Cornelius Schumacher <schumacher@kde.org> |
5 | Copyright (C) 2004 Reinhold Kainhofer <reinhold@kainhofer.com> | 5 | Copyright (C) 2004 Reinhold Kainhofer <reinhold@kainhofer.com> |
6 | 6 | ||
7 | This program is free software; you can redistribute it and/or modify | 7 | This program is free software; you can redistribute it and/or modify |
8 | it under the terms of the GNU General Public License as published by | 8 | it under the terms of the GNU General Public License as published by |
9 | the Free Software Foundation; either version 2 of the License, or | 9 | the Free Software Foundation; either version 2 of the License, or |
10 | (at your option) any later version. | 10 | (at your option) any later version. |
11 | 11 | ||
12 | This program is distributed in the hope that it will be useful, | 12 | This program is distributed in the hope that it will be useful, |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | GNU General Public License for more details. | 15 | GNU General Public License for more details. |
16 | 16 | ||
17 | You should have received a copy of the GNU General Public License | 17 | You should have received a copy of the GNU General Public License |
18 | along with this program; if not, write to the Free Software | 18 | along with this program; if not, write to the Free Software |
19 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 19 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
20 | 20 | ||
21 | As a special exception, permission is given to link this program | 21 | As a special exception, permission is given to link this program |
22 | with any edition of Qt, and distribute the resulting executable, | 22 | with any edition of Qt, and distribute the resulting executable, |
23 | without including the source code for Qt in the source distribution. | 23 | without including the source code for Qt in the source distribution. |
24 | */ | 24 | */ |
25 | #ifndef DATENAVIGATORCONTAINER_H | 25 | #ifndef DATENAVIGATORCONTAINER_H |
26 | #define DATENAVIGATORCONTAINER_H | 26 | #define DATENAVIGATORCONTAINER_H |
27 | 27 | ||
28 | class KDateNavigator; | 28 | class KDateNavigator; |
29 | 29 | ||
30 | #include <qwidget.h> | 30 | #include <qwidget.h> |
31 | #include <libkcal/calendar.h> | 31 | #include <libkcal/calendar.h> |
32 | using namespace KCal; | 32 | using namespace KCal; |
33 | 33 | ||
34 | class DateNavigatorContainer: public QWidget | 34 | class DateNavigatorContainer: public QWidget |
35 | { | 35 | { |
36 | Q_OBJECT | 36 | Q_OBJECT |
37 | public: | 37 | public: |
38 | DateNavigatorContainer( QWidget *parent = 0, const char *name = 0 ); | 38 | DateNavigatorContainer( QWidget *parent = 0, const char *name = 0 ); |
39 | ~DateNavigatorContainer(); | 39 | ~DateNavigatorContainer(); |
40 | 40 | ||
41 | /** | 41 | /** |
42 | Associate date navigator with a calendar. It is used by KODayMatrix. | 42 | Associate date navigator with a calendar. It is used by KODayMatrix. |
43 | */ | 43 | */ |
44 | void setCalendar( Calendar * ); | 44 | void setCalendar( Calendar * ); |
45 | 45 | ||
46 | QSize minimumSizeHint() const; | 46 | QSize minimumSizeHint() const; |
47 | QSize sizeHint() const; | 47 | QSize sizeHint() const; |
48 | KDateNavigator * navigatorView() { return mNavigatorView;} | 48 | KDateNavigator * navigatorView() { return mNavigatorView;} |
49 | QDate lastAvailableDate() const ; | 49 | QDate lastAvailableDate() const ; |
50 | QDate firstAvailableDate() const ; | 50 | QDate firstAvailableDate() const ; |
51 | 51 | ||
52 | public slots: | 52 | public slots: |
53 | void selectDates( const KCal::DateList & ); | 53 | void selectDates( const KCal::DateList & ); |
54 | void updateView(); | 54 | void updateView(); |
55 | void updateConfig(); | 55 | void updateConfig(); |
56 | void updateDayMatrix(); | 56 | void updateDayMatrix(); |
57 | void updateDayMatrixDates(); | 57 | void updateDayMatrixDates(); |
58 | void checkUpdateDayMatrixDates(); | ||
58 | void updateToday(); | 59 | void updateToday(); |
59 | void slotMonthSelected( int month ); | 60 | void slotMonthSelected( int month ); |
60 | 61 | ||
61 | signals: | 62 | signals: |
62 | void datesSelected( const KCal::DateList & ); | 63 | void datesSelected( const KCal::DateList & ); |
63 | void incidenceDropped( Incidence *, const QDate & ); | 64 | void incidenceDropped( Incidence *, const QDate & ); |
64 | void incidenceDroppedMove( Incidence *, const QDate & ); | 65 | void incidenceDroppedMove( Incidence *, const QDate & ); |
65 | void weekClicked( const QDate &); | 66 | void weekClicked( const QDate &); |
66 | 67 | ||
67 | void goPrevious(); | 68 | void goPrevious(); |
68 | void goNext(); | 69 | void goNext(); |
69 | 70 | ||
70 | void goNextMonth(); | 71 | void goNextMonth(); |
71 | void goPrevMonth(); | 72 | void goPrevMonth(); |
72 | void goNextYear(); | 73 | void goNextYear(); |
73 | void goPrevYear(); | 74 | void goPrevYear(); |
74 | 75 | ||
75 | void monthSelected( int month ); | 76 | void monthSelected( int month ); |
76 | 77 | ||
77 | protected: | 78 | protected: |
78 | void resizeEvent( QResizeEvent * ); | 79 | void resizeEvent( QResizeEvent * ); |
79 | 80 | ||
80 | void setBaseDates(); | 81 | void setBaseDates(); |
81 | void connectNavigatorView( KDateNavigator *v ); | 82 | void connectNavigatorView( KDateNavigator *v ); |
82 | 83 | ||
83 | private: | 84 | private: |
85 | QTimer* mUpdateTimer; | ||
84 | int mLastDisplayedDN; | 86 | int mLastDisplayedDN; |
85 | QDate mFirstSelectedDate; | 87 | QDate mFirstSelectedDate; |
86 | int mSelectedDateCount; | 88 | int mSelectedDateCount; |
87 | KDateNavigator *mNavigatorView; | 89 | KDateNavigator *mNavigatorView; |
88 | 90 | ||
89 | KCal::Calendar *mCalendar; | 91 | KCal::Calendar *mCalendar; |
90 | 92 | ||
91 | QPtrList<KDateNavigator> mExtraViews; | 93 | QPtrList<KDateNavigator> mExtraViews; |
92 | 94 | ||
93 | int mHorizontalCount; | 95 | int mHorizontalCount; |
94 | int mVerticalCount; | 96 | int mVerticalCount; |
95 | }; | 97 | }; |
96 | 98 | ||
97 | #endif | 99 | #endif |
diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp index 366e8b8..59618bf 100644 --- a/korganizer/kodaymatrix.cpp +++ b/korganizer/kodaymatrix.cpp | |||
@@ -471,472 +471,473 @@ QString KODayMatrix::getHolidayLabel(int offset) | |||
471 | } | 471 | } |
472 | 472 | ||
473 | int KODayMatrix::getDayIndexFrom(int x, int y) | 473 | int KODayMatrix::getDayIndexFrom(int x, int y) |
474 | { | 474 | { |
475 | int colModulo = (width()-2) % 7; | 475 | int colModulo = (width()-2) % 7; |
476 | int rowModulo = (height()-2) % 6; | 476 | int rowModulo = (height()-2) % 6; |
477 | #if 0 | 477 | #if 0 |
478 | return 7*(y/daysize.height()) + (KOGlobals::self()->reverseLayout() ? | 478 | return 7*(y/daysize.height()) + (KOGlobals::self()->reverseLayout() ? |
479 | 6 - x/daysize.width() : x/daysize.width()); | 479 | 6 - x/daysize.width() : x/daysize.width()); |
480 | #endif | 480 | #endif |
481 | int xVal = (x-colModulo/2-2)/daysize.width(); | 481 | int xVal = (x-colModulo/2-2)/daysize.width(); |
482 | int yVal = (y-rowModulo/2-2)/daysize.height(); | 482 | int yVal = (y-rowModulo/2-2)/daysize.height(); |
483 | 483 | ||
484 | 484 | ||
485 | return 7*(yVal) + xVal; | 485 | return 7*(yVal) + xVal; |
486 | 486 | ||
487 | } | 487 | } |
488 | 488 | ||
489 | // ---------------------------------------------------------------------------- | 489 | // ---------------------------------------------------------------------------- |
490 | // M O U S E E V E N T H A N D L I N G | 490 | // M O U S E E V E N T H A N D L I N G |
491 | // ---------------------------------------------------------------------------- | 491 | // ---------------------------------------------------------------------------- |
492 | 492 | ||
493 | void KODayMatrix::mousePressEvent (QMouseEvent* e) | 493 | void KODayMatrix::mousePressEvent (QMouseEvent* e) |
494 | { | 494 | { |
495 | 495 | ||
496 | if ( e->button() == LeftButton ) | 496 | if ( e->button() == LeftButton ) |
497 | mouseDown = true; | 497 | mouseDown = true; |
498 | mSelStart = getDayIndexFrom(e->x(), e->y()); | 498 | mSelStart = getDayIndexFrom(e->x(), e->y()); |
499 | if (mSelStart > NUMDAYS-1) mSelStart=NUMDAYS-1; | 499 | if (mSelStart > NUMDAYS-1) mSelStart=NUMDAYS-1; |
500 | mSelInit = mSelStart; | 500 | mSelInit = mSelStart; |
501 | mSelEnd = mSelStart; | 501 | mSelEnd = mSelStart; |
502 | repaint(false); | 502 | repaint(false); |
503 | } | 503 | } |
504 | 504 | ||
505 | void KODayMatrix::mouseReleaseEvent (QMouseEvent* e) | 505 | void KODayMatrix::mouseReleaseEvent (QMouseEvent* e) |
506 | { | 506 | { |
507 | if ( e->button() == LeftButton ) | 507 | if ( e->button() == LeftButton ) |
508 | if ( ! mouseDown ) { | 508 | if ( ! mouseDown ) { |
509 | return; | 509 | return; |
510 | } | 510 | } |
511 | else | 511 | else |
512 | mouseDown = false; | 512 | mouseDown = false; |
513 | int tmp = getDayIndexFrom(e->x(), e->y()); | 513 | int tmp = getDayIndexFrom(e->x(), e->y()); |
514 | if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; | 514 | if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; |
515 | 515 | ||
516 | if (mSelInit > tmp) { | 516 | if (mSelInit > tmp) { |
517 | mSelEnd = mSelInit; | 517 | mSelEnd = mSelInit; |
518 | if (tmp != mSelStart) { | 518 | if (tmp != mSelStart) { |
519 | mSelStart = tmp; | 519 | mSelStart = tmp; |
520 | repaint(false); | 520 | repaint(false); |
521 | } | 521 | } |
522 | } else { | 522 | } else { |
523 | mSelStart = mSelInit; | 523 | mSelStart = mSelInit; |
524 | 524 | ||
525 | //repaint only if selection has changed | 525 | //repaint only if selection has changed |
526 | if (tmp != mSelEnd) { | 526 | if (tmp != mSelEnd) { |
527 | mSelEnd = tmp; | 527 | mSelEnd = tmp; |
528 | repaint(false); | 528 | repaint(false); |
529 | } | 529 | } |
530 | } | 530 | } |
531 | 531 | ||
532 | DateList daylist; | 532 | DateList daylist; |
533 | if ( mSelStart < 0 ) | 533 | if ( mSelStart < 0 ) |
534 | mSelStart = 0; | 534 | mSelStart = 0; |
535 | for (int i = mSelStart; i <= mSelEnd; i++) { | 535 | for (int i = mSelStart; i <= mSelEnd; i++) { |
536 | daylist.append(days[i]); | 536 | daylist.append(days[i]); |
537 | } | 537 | } |
538 | emit selected((const DateList)daylist); | 538 | emit selected((const DateList)daylist); |
539 | 539 | ||
540 | } | 540 | } |
541 | 541 | ||
542 | void KODayMatrix::mouseMoveEvent (QMouseEvent* e) | 542 | void KODayMatrix::mouseMoveEvent (QMouseEvent* e) |
543 | { | 543 | { |
544 | if ( ! mouseDown ) { | 544 | if ( ! mouseDown ) { |
545 | return; | 545 | return; |
546 | } | 546 | } |
547 | int tmp = getDayIndexFrom(e->x(), e->y()); | 547 | int tmp = getDayIndexFrom(e->x(), e->y()); |
548 | if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; | 548 | if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; |
549 | 549 | ||
550 | if (mSelInit > tmp) { | 550 | if (mSelInit > tmp) { |
551 | mSelEnd = mSelInit; | 551 | mSelEnd = mSelInit; |
552 | if (tmp != mSelStart) { | 552 | if (tmp != mSelStart) { |
553 | mSelStart = tmp; | 553 | mSelStart = tmp; |
554 | repaint(false); | 554 | repaint(false); |
555 | } | 555 | } |
556 | } else { | 556 | } else { |
557 | mSelStart = mSelInit; | 557 | mSelStart = mSelInit; |
558 | 558 | ||
559 | //repaint only if selection has changed | 559 | //repaint only if selection has changed |
560 | if (tmp != mSelEnd) { | 560 | if (tmp != mSelEnd) { |
561 | mSelEnd = tmp; | 561 | mSelEnd = tmp; |
562 | repaint(false); | 562 | repaint(false); |
563 | } | 563 | } |
564 | } | 564 | } |
565 | } | 565 | } |
566 | 566 | ||
567 | // ---------------------------------------------------------------------------- | 567 | // ---------------------------------------------------------------------------- |
568 | // D R A G ' N D R O P H A N D L I N G | 568 | // D R A G ' N D R O P H A N D L I N G |
569 | // ---------------------------------------------------------------------------- | 569 | // ---------------------------------------------------------------------------- |
570 | 570 | ||
571 | void KODayMatrix::dragEnterEvent(QDragEnterEvent *e) | 571 | void KODayMatrix::dragEnterEvent(QDragEnterEvent *e) |
572 | { | 572 | { |
573 | #ifndef KORG_NODND | 573 | #ifndef KORG_NODND |
574 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { | 574 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { |
575 | e->ignore(); | 575 | e->ignore(); |
576 | return; | 576 | return; |
577 | } | 577 | } |
578 | 578 | ||
579 | // some visual feedback | 579 | // some visual feedback |
580 | // oldPalette = palette(); | 580 | // oldPalette = palette(); |
581 | // setPalette(my_HilitePalette); | 581 | // setPalette(my_HilitePalette); |
582 | // update(); | 582 | // update(); |
583 | #endif | 583 | #endif |
584 | } | 584 | } |
585 | 585 | ||
586 | void KODayMatrix::dragMoveEvent(QDragMoveEvent *e) | 586 | void KODayMatrix::dragMoveEvent(QDragMoveEvent *e) |
587 | { | 587 | { |
588 | #ifndef KORG_NODND | 588 | #ifndef KORG_NODND |
589 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { | 589 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { |
590 | e->ignore(); | 590 | e->ignore(); |
591 | return; | 591 | return; |
592 | } | 592 | } |
593 | 593 | ||
594 | e->accept(); | 594 | e->accept(); |
595 | #endif | 595 | #endif |
596 | } | 596 | } |
597 | 597 | ||
598 | void KODayMatrix::dragLeaveEvent(QDragLeaveEvent */*dl*/) | 598 | void KODayMatrix::dragLeaveEvent(QDragLeaveEvent */*dl*/) |
599 | { | 599 | { |
600 | #ifndef KORG_NODND | 600 | #ifndef KORG_NODND |
601 | // setPalette(oldPalette); | 601 | // setPalette(oldPalette); |
602 | // update(); | 602 | // update(); |
603 | #endif | 603 | #endif |
604 | } | 604 | } |
605 | 605 | ||
606 | void KODayMatrix::dropEvent(QDropEvent *e) | 606 | void KODayMatrix::dropEvent(QDropEvent *e) |
607 | { | 607 | { |
608 | #ifndef KORG_NODND | 608 | #ifndef KORG_NODND |
609 | // kdDebug() << "KODayMatrix::dropEvent(e) begin" << endl; | 609 | // kdDebug() << "KODayMatrix::dropEvent(e) begin" << endl; |
610 | 610 | ||
611 | if (!mCalendar || !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { | 611 | if (!mCalendar || !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { |
612 | e->ignore(); | 612 | e->ignore(); |
613 | return; | 613 | return; |
614 | } | 614 | } |
615 | 615 | ||
616 | DndFactory factory( mCalendar ); | 616 | DndFactory factory( mCalendar ); |
617 | Event *event = factory.createDrop(e); | 617 | Event *event = factory.createDrop(e); |
618 | 618 | ||
619 | if (event) { | 619 | if (event) { |
620 | e->acceptAction(); | 620 | e->acceptAction(); |
621 | 621 | ||
622 | Event *existingEvent = mCalendar->event(event->uid()); | 622 | Event *existingEvent = mCalendar->event(event->uid()); |
623 | 623 | ||
624 | if(existingEvent) { | 624 | if(existingEvent) { |
625 | // uniquify event | 625 | // uniquify event |
626 | event->recreate(); | 626 | event->recreate(); |
627 | /* | 627 | /* |
628 | KMessageBox::sorry(this, | 628 | KMessageBox::sorry(this, |
629 | i18n("Event already exists in this calendar."), | 629 | i18n("Event already exists in this calendar."), |
630 | i18n("Drop Event")); | 630 | i18n("Drop Event")); |
631 | delete event; | 631 | delete event; |
632 | return; | 632 | return; |
633 | */ | 633 | */ |
634 | } | 634 | } |
635 | // kdDebug() << "Drop new Event" << endl; | 635 | // kdDebug() << "Drop new Event" << endl; |
636 | // Adjust date | 636 | // Adjust date |
637 | QDateTime start = event->dtStart(); | 637 | QDateTime start = event->dtStart(); |
638 | QDateTime end = event->dtEnd(); | 638 | QDateTime end = event->dtEnd(); |
639 | int duration = start.daysTo(end); | 639 | int duration = start.daysTo(end); |
640 | int idx = getDayIndexFrom(e->pos().x(), e->pos().y()); | 640 | int idx = getDayIndexFrom(e->pos().x(), e->pos().y()); |
641 | 641 | ||
642 | start.setDate(days[idx]); | 642 | start.setDate(days[idx]); |
643 | end.setDate(days[idx].addDays(duration)); | 643 | end.setDate(days[idx].addDays(duration)); |
644 | 644 | ||
645 | event->setDtStart(start); | 645 | event->setDtStart(start); |
646 | event->setDtEnd(end); | 646 | event->setDtEnd(end); |
647 | mCalendar->addEvent(event); | 647 | mCalendar->addEvent(event); |
648 | 648 | ||
649 | emit eventDropped(event); | 649 | emit eventDropped(event); |
650 | } else { | 650 | } else { |
651 | // kdDebug() << "KODayMatrix::dropEvent(): Event from drop not decodable" << endl; | 651 | // kdDebug() << "KODayMatrix::dropEvent(): Event from drop not decodable" << endl; |
652 | e->ignore(); | 652 | e->ignore(); |
653 | } | 653 | } |
654 | #endif | 654 | #endif |
655 | } | 655 | } |
656 | 656 | ||
657 | // ---------------------------------------------------------------------------- | 657 | // ---------------------------------------------------------------------------- |
658 | // P A I N T E V E N T H A N D L I N G | 658 | // P A I N T E V E N T H A N D L I N G |
659 | // ---------------------------------------------------------------------------- | 659 | // ---------------------------------------------------------------------------- |
660 | 660 | ||
661 | void KODayMatrix::paintEvent(QPaintEvent * pevent) | 661 | void KODayMatrix::paintEvent(QPaintEvent * pevent) |
662 | { | 662 | { |
663 | QRect sz = frameRect(); | 663 | |
664 | if ( sz.width() <= 0 || sz.height() <= 0 ) | 664 | if ( width() <= 0 || height() <= 0 ) |
665 | return; | 665 | return; |
666 | if ( mPendingUpdateBeforeRepaint ) { | 666 | if ( mPendingUpdateBeforeRepaint ) { |
667 | updateViewTimed(); | 667 | updateViewTimed(); |
668 | mPendingUpdateBeforeRepaint = false; | 668 | mPendingUpdateBeforeRepaint = false; |
669 | } | 669 | } |
670 | if ( myPix.width() != sz.width() || myPix.height()!=sz.height() ) { | 670 | if ( myPix.width() != width() || myPix.height()!=height() ) { |
671 | myPix.resize(sz.size() ); | 671 | myPix.resize(size() ); |
672 | } | 672 | } |
673 | QPainter p(&myPix); | 673 | QPainter p(&myPix); |
674 | p.setFont(font()); | 674 | p.setFont(font()); |
675 | 675 | ||
676 | 676 | ||
677 | int dheight = daysize.height(); | 677 | int dheight = daysize.height(); |
678 | int dwidth = daysize.width(); | 678 | int dwidth = daysize.width(); |
679 | int row,col; | 679 | int row,col; |
680 | int selw, selh; | 680 | int selw, selh; |
681 | int xyOff = frameWidth(); | 681 | int xyOff = frameWidth(); |
682 | int colModulo = sz.width() % 7; | 682 | int colModulo = (width()-2) % 7; |
683 | int rowModulo = sz.height() % 6; | 683 | int rowModulo = (height()-2) % 6; |
684 | //qDebug("col %d row %d ",colModulo,rowModulo ); | 684 | //qDebug("col %d row %d ",colModulo,rowModulo ); |
685 | 685 | ||
686 | bool isRTL = KOGlobals::self()->reverseLayout(); | 686 | bool isRTL = KOGlobals::self()->reverseLayout(); |
687 | 687 | ||
688 | // draw background and topleft frame | 688 | // draw background and topleft frame |
689 | p.fillRect(pevent->rect(), mDefaultBackColor); | 689 | p.fillRect(0,0,width(),height(), mDefaultBackColor); |
690 | p.setPen(mDefaultTextColor); | 690 | p.setPen(mDefaultTextColor); |
691 | p.drawRect(0, 0, sz.width()+1, sz.height()+1); | 691 | p.drawRect(0, 0, width(), height()); |
692 | int mSelStartT = mSelStart; | 692 | int mSelStartT = mSelStart; |
693 | int mSelEndT = mSelEnd; | 693 | int mSelEndT = mSelEnd; |
694 | if ( mSelEndT >= NUMDAYS ) | 694 | if ( mSelEndT >= NUMDAYS ) |
695 | mSelEndT = NUMDAYS-1; | 695 | mSelEndT = NUMDAYS-1; |
696 | // draw selected days with highlighted background color | 696 | // draw selected days with highlighted background color |
697 | if (mSelStart != NOSELECTION) { | 697 | if (mSelStart != NOSELECTION) { |
698 | bool skip = false; | 698 | bool skip = false; |
699 | if ( ! mouseDown ) { | 699 | if ( ! mouseDown ) { |
700 | int mo = days[20].month(); | 700 | int mo = days[20].month(); |
701 | //qDebug("-- %d %d ", mSelStartT, mSelEndT); | 701 | //qDebug("-- %d %d ", mSelStartT, mSelEndT); |
702 | //qDebug("%d %d %d - d %d", mo, days[mSelStartT].month() , days[mSelEndT].month(), days[mSelEndT].day() ); | 702 | //qDebug("%d %d %d - d %d", mo, days[mSelStartT].month() , days[mSelEndT].month(), days[mSelEndT].day() ); |
703 | int startMo = days[mSelStartT].month(); | 703 | int startMo = days[mSelStartT].month(); |
704 | int endMo = days[mSelEndT].month(); | 704 | int endMo = days[mSelEndT].month(); |
705 | if ( startMo == 12 && mo == 1 && endMo <= 2 ) | 705 | if ( startMo == 12 && mo == 1 && endMo <= 2 ) |
706 | startMo = 1; | 706 | startMo = 1; |
707 | if ( endMo == 1 && mo == 12 ) | 707 | if ( endMo == 1 && mo == 12 ) |
708 | endMo = 12; | 708 | endMo = 12; |
709 | if ( mo == 12 && startMo == 1 ) | 709 | if ( mo == 12 && startMo == 1 ) |
710 | startMo = 13; | 710 | startMo = 13; |
711 | if ( (startMo > mo || endMo < mo) ) { | 711 | if ( (startMo > mo || endMo < mo) ) { |
712 | skip = true; | 712 | skip = true; |
713 | } else { | 713 | } else { |
714 | if ( days[mSelStartT].month() != mo ) { | 714 | if ( days[mSelStartT].month() != mo ) { |
715 | int add = days[mSelStartT].daysInMonth ()-days[mSelStartT].day(); | 715 | int add = days[mSelStartT].daysInMonth ()-days[mSelStartT].day(); |
716 | mSelStartT += add +1; | 716 | mSelStartT += add +1; |
717 | } | 717 | } |
718 | if ( days[mSelEndT].month() != mo ) { | 718 | if ( days[mSelEndT].month() != mo ) { |
719 | int sub = days[mSelEndT].day(); | 719 | int sub = days[mSelEndT].day(); |
720 | mSelEndT -= sub ; | 720 | mSelEndT -= sub ; |
721 | } | 721 | } |
722 | } | 722 | } |
723 | } | 723 | } |
724 | //qDebug("SKIP %d ", skip); | 724 | //qDebug("SKIP %d ", skip); |
725 | if ( ! skip ) { | 725 | if ( ! skip ) { |
726 | row = mSelStartT/7; | 726 | row = mSelStartT/7; |
727 | col = mSelStartT -row*7; | 727 | col = mSelStartT -row*7; |
728 | QColor selcol = KOPrefs::instance()->mHighlightColor; | 728 | QColor selcol = KOPrefs::instance()->mHighlightColor; |
729 | int addCol = 0; | 729 | int addCol = 0; |
730 | int addRow = 0; | 730 | int addRow = 0; |
731 | int addRow2 = 0; | 731 | int addRow2 = 0; |
732 | int addCol2 = 0; | 732 | int addCol2 = 0; |
733 | if (row == mSelEndT/7) { | 733 | if (row == mSelEndT/7) { |
734 | if ( rowModulo ) { | 734 | if ( rowModulo ) { |
735 | if ( row >= 6 - rowModulo ) | 735 | if ( row >= 6 - rowModulo ) |
736 | addRow = row - 5 + rowModulo; | 736 | addRow = row - 5 + rowModulo; |
737 | } | 737 | } |
738 | if ( colModulo ) { | 738 | if ( colModulo ) { |
739 | int colt1 = mSelEndT%7; | 739 | int colt1 = mSelEndT%7; |
740 | //qDebug("colt1 %d ", colt1 ); | 740 | //qDebug("colt1 %d ", colt1 ); |
741 | if ( colt1 >= 7 - colModulo ) | 741 | if ( colt1 >= 7 - colModulo ) |
742 | addCol = colt1 - 7 + colModulo+1; | 742 | addCol = colt1 - 7 + colModulo+1; |
743 | int colt = mSelStartT%7; | 743 | int colt = mSelStartT%7; |
744 | if ( colt >= 7 - colModulo ) | 744 | if ( colt >= 7 - colModulo ) |
745 | addCol2 = colt - 7 + colModulo; | 745 | addCol2 = colt - 7 + colModulo; |
746 | addCol -= addCol2; | 746 | addCol -= addCol2; |
747 | //qDebug("COL %d %d %d %d ",col , colt1 ,addCol ,addCol2 ); | 747 | //qDebug("COL %d %d %d %d ",col , colt1 ,addCol ,addCol2 ); |
748 | } | 748 | } |
749 | // Single row selection | 749 | // Single row selection |
750 | if ( row == 0) | 750 | if ( row == 0) |
751 | addRow = 1; | 751 | addRow = 1; |
752 | p.fillRect(isRTL ? (7 - (mSelEndT-mSelStartT+1) - col)*dwidth : col*dwidth+1+addCol2, | 752 | p.fillRect(isRTL ? (7 - (mSelEndT-mSelStartT+1) - col)*dwidth : col*dwidth+1+addCol2, |
753 | row*dheight+addRow, (mSelEndT-mSelStartT+1)*dwidth+addCol, dheight+1, selcol); | 753 | row*dheight+addRow, (mSelEndT-mSelStartT+1)*dwidth+addCol, dheight+1, selcol); |
754 | } else { | 754 | } else { |
755 | // draw first row to the right | 755 | // draw first row to the right |
756 | if ( colModulo ) { | 756 | if ( colModulo ) { |
757 | if ( col >= 7 - colModulo ) | 757 | if ( col >= 7 - colModulo ) |
758 | addCol2 = col - 7 + colModulo; | 758 | addCol2 = col - 7 + colModulo; |
759 | } | 759 | } |
760 | if ( rowModulo ) { | 760 | if ( rowModulo ) { |
761 | if ( row >= 6 - rowModulo ) | 761 | if ( row >= 6 - rowModulo ) |
762 | addRow = row - 5 + rowModulo; | 762 | addRow = row - 5 + rowModulo; |
763 | } | 763 | } |
764 | if ( row == 0) | 764 | if ( row == 0) |
765 | addRow = 1; | 765 | addRow = 1; |
766 | p.fillRect(isRTL ? 0 : col*dwidth+1+addCol2, row*dheight+addRow, (7-col)*dwidth+colModulo, | 766 | int drawWid = width()-(col*dwidth+1+addCol2)-1; |
767 | p.fillRect(isRTL ? 0 : col*dwidth+1+addCol2, row*dheight+addRow, drawWid, | ||
767 | dheight+1, selcol); | 768 | dheight+1, selcol); |
768 | // draw full block till last line | 769 | // draw full block till last line |
769 | selh = mSelEndT/7-row; | 770 | selh = mSelEndT/7-row; |
770 | addRow = 0; | 771 | addRow = 0; |
771 | if ( rowModulo ) { | 772 | if ( rowModulo ) { |
772 | if ( mSelEndT/7 >= 6 - rowModulo ) | 773 | if ( mSelEndT/7 >= 6 - rowModulo ) |
773 | addRow = mSelEndT/7 - 5 + rowModulo; | 774 | addRow = mSelEndT/7 - 5 + rowModulo; |
774 | } | 775 | } |
775 | if (selh > 1) { | 776 | if (selh > 1) { |
776 | p.fillRect(1, (row+1)*dheight, 7*dwidth+colModulo, (selh-1)*dheight+addRow,selcol); | 777 | p.fillRect(1, (row+1)*dheight, 7*dwidth+colModulo, (selh-1)*dheight+addRow,selcol); |
777 | } | 778 | } |
778 | // draw last block from left to mSelEndT | 779 | // draw last block from left to mSelEndT |
779 | selw = mSelEndT-7*(mSelEndT/7)+1; | 780 | selw = mSelEndT-7*(mSelEndT/7)+1; |
780 | //qDebug("esl %d ",selw ); | 781 | //qDebug("esl %d ",selw ); |
781 | int add = 0; | 782 | int add = 0; |
782 | if ( colModulo ) { | 783 | if ( colModulo ) { |
783 | add = 7 - colModulo; | 784 | add = 7 - colModulo; |
784 | if ( selw > add ) | 785 | if ( selw > add ) |
785 | add = selw - add; | 786 | add = selw - add; |
786 | else | 787 | else |
787 | add = 0; | 788 | add = 0; |
788 | } | 789 | } |
789 | //qDebug("add %d ", add); | 790 | //qDebug("add %d ", add); |
790 | p.fillRect(isRTL ? (7-selw)*dwidth : 1, (row+selh)*dheight+addRow, | 791 | p.fillRect(isRTL ? (7-selw)*dwidth : 1, (row+selh)*dheight+addRow, |
791 | selw*dwidth+add, dheight+1, selcol); | 792 | selw*dwidth+add, dheight+1, selcol); |
792 | } | 793 | } |
793 | } | 794 | } |
794 | } | 795 | } |
795 | 796 | ||
796 | // iterate over all days in the matrix and draw the day label in appropriate colors | 797 | // iterate over all days in the matrix and draw the day label in appropriate colors |
797 | QColor actcol = mDefaultTextColorShaded; | 798 | QColor actcol = mDefaultTextColorShaded; |
798 | p.setPen(actcol); | 799 | p.setPen(actcol); |
799 | QPen tmppen; | 800 | QPen tmppen; |
800 | for(int i = 0; i < NUMDAYS; i++) { | 801 | for(int i = 0; i < NUMDAYS; i++) { |
801 | row = i/7; | 802 | row = i/7; |
802 | col = isRTL ? 6-(i-row*7) : i-row*7; | 803 | col = isRTL ? 6-(i-row*7) : i-row*7; |
803 | 804 | ||
804 | // if it is the first day of a month switch color from normal to shaded and vice versa | 805 | // if it is the first day of a month switch color from normal to shaded and vice versa |
805 | if ( KOGlobals::self()->calendarSystem()->day( days[i] ) == 1) { | 806 | if ( KOGlobals::self()->calendarSystem()->day( days[i] ) == 1) { |
806 | if (actcol == mDefaultTextColorShaded) { | 807 | if (actcol == mDefaultTextColorShaded) { |
807 | actcol = mDefaultTextColor; | 808 | actcol = mDefaultTextColor; |
808 | } else { | 809 | } else { |
809 | actcol = mDefaultTextColorShaded; | 810 | actcol = mDefaultTextColorShaded; |
810 | } | 811 | } |
811 | p.setPen(actcol); | 812 | p.setPen(actcol); |
812 | } | 813 | } |
813 | if (actcol == mDefaultTextColorShaded) { | 814 | if (actcol == mDefaultTextColorShaded) { |
814 | if ( ! mouseDown ) { | 815 | if ( ! mouseDown ) { |
815 | continue; | 816 | continue; |
816 | } | 817 | } |
817 | } | 818 | } |
818 | //Reset pen color after selected days block | 819 | //Reset pen color after selected days block |
819 | if (i == mSelEndT+1) { | 820 | if (i == mSelEndT+1) { |
820 | p.setPen(actcol); | 821 | p.setPen(actcol); |
821 | } | 822 | } |
822 | 823 | ||
823 | // if today then draw rectangle around day | 824 | // if today then draw rectangle around day |
824 | if (today == i) { | 825 | if (today == i) { |
825 | tmppen = p.pen(); | 826 | tmppen = p.pen(); |
826 | QPen mTodayPen(p.pen()); | 827 | QPen mTodayPen(p.pen()); |
827 | if ( daysize.width() < 20 ) | 828 | if ( daysize.width() < 20 ) |
828 | mTodayPen.setWidth(1); | 829 | mTodayPen.setWidth(1); |
829 | else | 830 | else |
830 | mTodayPen.setWidth(mTodayMarginWidth); | 831 | mTodayPen.setWidth(mTodayMarginWidth); |
831 | //draw red rectangle for holidays | 832 | //draw red rectangle for holidays |
832 | if (!mHolidays[i].isNull()) { | 833 | if (!mHolidays[i].isNull()) { |
833 | if (actcol == mDefaultTextColor) { | 834 | if (actcol == mDefaultTextColor) { |
834 | mTodayPen.setColor(KOPrefs::instance()->mHolidayColor); | 835 | mTodayPen.setColor(KOPrefs::instance()->mHolidayColor); |
835 | } else { | 836 | } else { |
836 | mTodayPen.setColor(mHolidayColorShaded); | 837 | mTodayPen.setColor(mHolidayColorShaded); |
837 | } | 838 | } |
838 | } | 839 | } |
839 | //draw gray rectangle for today if in selection | 840 | //draw gray rectangle for today if in selection |
840 | if (i >= mSelStartT && i <= mSelEndT) { | 841 | if (i >= mSelStartT && i <= mSelEndT) { |
841 | QColor grey("grey"); | 842 | QColor grey("grey"); |
842 | mTodayPen.setColor(grey); | 843 | mTodayPen.setColor(grey); |
843 | } | 844 | } |
844 | p.setPen(mTodayPen); | 845 | p.setPen(mTodayPen); |
845 | 846 | ||
846 | 847 | ||
847 | int addCol = 0; | 848 | int addCol = 0; |
848 | int addRow = 0; | 849 | int addRow = 0; |
849 | if (rowModulo) { | 850 | if (rowModulo) { |
850 | if ( row >= 6 - rowModulo ) | 851 | if ( row >= 6 - rowModulo ) |
851 | addRow = row - 5 + rowModulo; | 852 | addRow = row - 5 + rowModulo; |
852 | } | 853 | } |
853 | if ( colModulo ) { | 854 | if ( colModulo ) { |
854 | if ( col >= 7 - colModulo ) | 855 | if ( col >= 7 - colModulo ) |
855 | addCol = col - 6 + colModulo-1; | 856 | addCol = col - 6 + colModulo-1; |
856 | } | 857 | } |
857 | 858 | ||
858 | addCol += 1; | 859 | addCol += 1; |
859 | p.drawRect(col*dwidth+addCol, row*dheight+addRow, dwidth, dheight+1); | 860 | p.drawRect(col*dwidth+addCol, row*dheight+addRow, dwidth, dheight+1); |
860 | p.setPen(tmppen); | 861 | p.setPen(tmppen); |
861 | } | 862 | } |
862 | 863 | ||
863 | // if any events are on that day then draw it using a bold font | 864 | // if any events are on that day then draw it using a bold font |
864 | if (events[i] > 0) { | 865 | if (events[i] > 0) { |
865 | QFont myFont = font(); | 866 | QFont myFont = font(); |
866 | myFont.setBold(true); | 867 | myFont.setBold(true); |
867 | p.setFont(myFont); | 868 | p.setFont(myFont); |
868 | } | 869 | } |
869 | 870 | ||
870 | // if it is a holiday then use the default holiday color | 871 | // if it is a holiday then use the default holiday color |
871 | if (!mHolidays[i].isNull()) { | 872 | if (!mHolidays[i].isNull()) { |
872 | if ( bDays.testBit(i) ) { | 873 | if ( bDays.testBit(i) ) { |
873 | p.setPen(Qt::green); | 874 | p.setPen(Qt::green); |
874 | } else { | 875 | } else { |
875 | if (actcol == mDefaultTextColor) { | 876 | if (actcol == mDefaultTextColor) { |
876 | p.setPen(KOPrefs::instance()->mHolidayColor); | 877 | p.setPen(KOPrefs::instance()->mHolidayColor); |
877 | } else { | 878 | } else { |
878 | p.setPen(mHolidayColorShaded); | 879 | p.setPen(mHolidayColorShaded); |
879 | } | 880 | } |
880 | } | 881 | } |
881 | } | 882 | } |
882 | 883 | ||
883 | // draw selected days with special color | 884 | // draw selected days with special color |
884 | // DO NOT specially highlight holidays in selection ! | 885 | // DO NOT specially highlight holidays in selection ! |
885 | if (i >= mSelStartT && i <= mSelEndT) { | 886 | if (i >= mSelStartT && i <= mSelEndT) { |
886 | ;//p.setPen(mSelectedDaysColor); | 887 | ;//p.setPen(mSelectedDaysColor); |
887 | } | 888 | } |
888 | 889 | ||
889 | int addCol = 0; | 890 | int addCol = 0; |
890 | int addRow = 0; | 891 | int addRow = 0; |
891 | if ( colModulo ) { | 892 | if ( colModulo ) { |
892 | if ( col >= 7 - colModulo ) | 893 | if ( col >= 7 - colModulo ) |
893 | addCol = col - 7 + colModulo; | 894 | addCol = col - 7 + colModulo; |
894 | } | 895 | } |
895 | if ( rowModulo ) { | 896 | if ( rowModulo ) { |
896 | if ( row >= 6 - rowModulo ) | 897 | if ( row >= 6 - rowModulo ) |
897 | addRow = row - 5 + rowModulo; | 898 | addRow = row - 5 + rowModulo; |
898 | } | 899 | } |
899 | //qDebug("add %d %d -- %d %d ", col, addCol, row, addRow); | 900 | //qDebug("add %d %d -- %d %d ", col, addCol, row, addRow); |
900 | ++addCol;//++addCol; | 901 | ++addCol;//++addCol; |
901 | if ( row == 0) | 902 | if ( row == 0) |
902 | addRow = 1; | 903 | addRow = 1; |
903 | p.drawText(col*dwidth+addCol, row*dheight+addRow, dwidth, dheight, | 904 | p.drawText(col*dwidth+addCol, row*dheight+addRow, dwidth, dheight, |
904 | Qt::AlignHCenter | Qt::AlignVCenter, daylbls[i]); | 905 | Qt::AlignHCenter | Qt::AlignVCenter, daylbls[i]); |
905 | 906 | ||
906 | // reset color to actual color | 907 | // reset color to actual color |
907 | if (!mHolidays[i].isNull()) { | 908 | if (!mHolidays[i].isNull()) { |
908 | p.setPen(actcol); | 909 | p.setPen(actcol); |
909 | } | 910 | } |
910 | // reset bold font to plain font | 911 | // reset bold font to plain font |
911 | if (events[i] > 0) { | 912 | if (events[i] > 0) { |
912 | QFont myFont = font(); | 913 | QFont myFont = font(); |
913 | myFont.setBold(false); | 914 | myFont.setBold(false); |
914 | p.setFont(myFont); | 915 | p.setFont(myFont); |
915 | } | 916 | } |
916 | } | 917 | } |
917 | int off = xyOff; | 918 | int off = 0;//xyOff; |
918 | bitBlt (this, off, off, &myPix, 0 ,0,width(), height() ,CopyROP); | 919 | bitBlt (this, off, off, &myPix, 0 ,0,width(), height() ,CopyROP); |
919 | //qDebug("ffffffffff %d ", off); | 920 | //qDebug("ffffffffff %d ", off); |
920 | } | 921 | } |
921 | 922 | ||
922 | // ---------------------------------------------------------------------------- | 923 | // ---------------------------------------------------------------------------- |
923 | // R E SI Z E E V E N T H A N D L I N G | 924 | // R E SI Z E E V E N T H A N D L I N G |
924 | // ---------------------------------------------------------------------------- | 925 | // ---------------------------------------------------------------------------- |
925 | 926 | ||
926 | void KODayMatrix::resizeEvent(QResizeEvent *) | 927 | void KODayMatrix::resizeEvent(QResizeEvent *) |
927 | { | 928 | { |
928 | QRect sz = frameRect(); | 929 | QRect sz = frameRect(); |
929 | daysize.setHeight(sz.height()*7 / NUMDAYS); | 930 | daysize.setHeight(sz.height()*7 / NUMDAYS); |
930 | daysize.setWidth(sz.width() / 7); | 931 | daysize.setWidth(sz.width() / 7); |
931 | } | 932 | } |
932 | 933 | ||
933 | QSize KODayMatrix::sizeHint() const | 934 | QSize KODayMatrix::sizeHint() const |
934 | { | 935 | { |
935 | 936 | ||
936 | QFontMetrics fm ( font() ); | 937 | QFontMetrics fm ( font() ); |
937 | int wid = fm.width( "30") *7+3; | 938 | int wid = fm.width( "30") *7+3; |
938 | int hei = fm.height() * 6+3; | 939 | int hei = fm.height() * 6+3; |
939 | //qDebug("KODayMatrix::sizeHint()********************* %d %d", wid , hei); | 940 | //qDebug("KODayMatrix::sizeHint()********************* %d %d", wid , hei); |
940 | return QSize ( wid, hei ); | 941 | return QSize ( wid, hei ); |
941 | 942 | ||
942 | } | 943 | } |