-rw-r--r-- | korganizer/datenavigatorcontainer.cpp | 7 | ||||
-rw-r--r-- | korganizer/kodaymatrix.cpp | 9 |
2 files changed, 14 insertions, 2 deletions
diff --git a/korganizer/datenavigatorcontainer.cpp b/korganizer/datenavigatorcontainer.cpp index 9506768..b147427 100644 --- a/korganizer/datenavigatorcontainer.cpp +++ b/korganizer/datenavigatorcontainer.cpp | |||
@@ -38,193 +38,198 @@ | |||
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 | } | 48 | } |
49 | 49 | ||
50 | DateNavigatorContainer::~DateNavigatorContainer() | 50 | DateNavigatorContainer::~DateNavigatorContainer() |
51 | { | 51 | { |
52 | } | 52 | } |
53 | 53 | ||
54 | void DateNavigatorContainer::connectNavigatorView( KDateNavigator *v ) | 54 | void DateNavigatorContainer::connectNavigatorView( KDateNavigator *v ) |
55 | { | 55 | { |
56 | connect( v, SIGNAL( datesSelected( const KCal::DateList & ) ), | 56 | connect( v, SIGNAL( datesSelected( const KCal::DateList & ) ), |
57 | SIGNAL( datesSelected( const KCal::DateList & ) ) ); | 57 | SIGNAL( datesSelected( const KCal::DateList & ) ) ); |
58 | #if 0 | 58 | #if 0 |
59 | connect( v, SIGNAL( incidenceDropped( Incidence *, const QDate & ) ), | 59 | connect( v, SIGNAL( incidenceDropped( Incidence *, const QDate & ) ), |
60 | SIGNAL( incidenceDropped( Incidence *, const QDate & ) ) ); | 60 | SIGNAL( incidenceDropped( Incidence *, const QDate & ) ) ); |
61 | connect( v, SIGNAL( incidenceDroppedMove( Incidence *, const QDate & ) ), | 61 | connect( v, SIGNAL( incidenceDroppedMove( Incidence *, const QDate & ) ), |
62 | SIGNAL( incidenceDroppedMove( Incidence *, const QDate & ) ) ); | 62 | SIGNAL( incidenceDroppedMove( Incidence *, const QDate & ) ) ); |
63 | #endif | 63 | #endif |
64 | connect( v, SIGNAL( weekClicked( const QDate & ) ), | 64 | connect( v, SIGNAL( weekClicked( const QDate & ) ), |
65 | SIGNAL( weekClicked( const QDate & ) ) ); | 65 | SIGNAL( weekClicked( const QDate & ) ) ); |
66 | 66 | ||
67 | connect( v, SIGNAL( goPrevious() ), SIGNAL( goPrevious() ) ); | 67 | connect( v, SIGNAL( goPrevious() ), SIGNAL( goPrevious() ) ); |
68 | connect( v, SIGNAL( goNext() ), SIGNAL( goNext() ) ); | 68 | connect( v, SIGNAL( goNext() ), SIGNAL( goNext() ) ); |
69 | 69 | ||
70 | connect( v, SIGNAL( goNextMonth() ), SIGNAL( goNextMonth() ) ); | 70 | connect( v, SIGNAL( goNextMonth() ), SIGNAL( goNextMonth() ) ); |
71 | connect( v, SIGNAL( goPrevMonth() ), SIGNAL( goPrevMonth() ) ); | 71 | connect( v, SIGNAL( goPrevMonth() ), SIGNAL( goPrevMonth() ) ); |
72 | connect( v, SIGNAL( goNextYear() ), SIGNAL( goNextYear() ) ); | 72 | connect( v, SIGNAL( goNextYear() ), SIGNAL( goNextYear() ) ); |
73 | connect( v, SIGNAL( goPrevYear() ), SIGNAL( goPrevYear() ) ); | 73 | connect( v, SIGNAL( goPrevYear() ), SIGNAL( goPrevYear() ) ); |
74 | 74 | ||
75 | connect( v, SIGNAL( monthSelected( int ) ), SIGNAL( monthSelected( int ) ) ); | 75 | connect( v, SIGNAL( monthSelected( int ) ), SIGNAL( monthSelected( int ) ) ); |
76 | } | 76 | } |
77 | 77 | ||
78 | void DateNavigatorContainer::setCalendar( Calendar *cal ) | 78 | void DateNavigatorContainer::setCalendar( Calendar *cal ) |
79 | { | 79 | { |
80 | mCalendar = cal; | 80 | mCalendar = cal; |
81 | mNavigatorView->setCalendar( cal ); | 81 | mNavigatorView->setCalendar( cal ); |
82 | KDateNavigator *n; | 82 | KDateNavigator *n; |
83 | for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { | 83 | for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { |
84 | n->setCalendar( cal ); | 84 | n->setCalendar( cal ); |
85 | } | 85 | } |
86 | } | 86 | } |
87 | 87 | ||
88 | void DateNavigatorContainer::updateDayMatrix() | 88 | void DateNavigatorContainer::updateDayMatrix() |
89 | { | 89 | { |
90 | mNavigatorView->updateDayMatrix(); | 90 | mNavigatorView->updateDayMatrix(); |
91 | KDateNavigator *n; | 91 | KDateNavigator *n; |
92 | for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { | 92 | for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { |
93 | n->updateDayMatrix(); | 93 | n->updateDayMatrix(); |
94 | } | 94 | } |
95 | } | 95 | } |
96 | 96 | ||
97 | void DateNavigatorContainer::updateToday() | 97 | void DateNavigatorContainer::updateToday() |
98 | { | 98 | { |
99 | qDebug("DateNavigatorContainer::updateToday() NOT IMPL "); | 99 | qDebug("DateNavigatorContainer::updateToday() NOT IMPL "); |
100 | #if 0 | 100 | #if 0 |
101 | mNavigatorView->updateToday(); | 101 | mNavigatorView->updateToday(); |
102 | KDateNavigator *n; | 102 | KDateNavigator *n; |
103 | for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { | 103 | for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { |
104 | n->updateToday(); | 104 | n->updateToday(); |
105 | } | 105 | } |
106 | #endif | 106 | #endif |
107 | } | 107 | } |
108 | 108 | ||
109 | void DateNavigatorContainer::updateView() | 109 | void DateNavigatorContainer::updateView() |
110 | { | 110 | { |
111 | mNavigatorView->updateView(); | 111 | mNavigatorView->updateView(); |
112 | KDateNavigator *n; | 112 | KDateNavigator *n; |
113 | for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { | 113 | for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { |
114 | n->updateView(); | 114 | n->updateView(); |
115 | } | 115 | } |
116 | } | 116 | } |
117 | 117 | ||
118 | void DateNavigatorContainer::updateConfig() | 118 | void DateNavigatorContainer::updateConfig() |
119 | { | 119 | { |
120 | mNavigatorView->updateConfig(); | 120 | mNavigatorView->updateConfig(); |
121 | KDateNavigator *n; | 121 | KDateNavigator *n; |
122 | for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { | 122 | for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { |
123 | n->updateConfig(); | 123 | n->updateConfig(); |
124 | } | 124 | } |
125 | } | 125 | } |
126 | 126 | ||
127 | void DateNavigatorContainer::selectDates( const DateList &dateList ) | 127 | void DateNavigatorContainer::selectDates( const DateList &dateList ) |
128 | { | 128 | { |
129 | mNavigatorView->selectDates( dateList ); | 129 | mNavigatorView->selectDates( dateList ); |
130 | setBaseDates(); | 130 | setBaseDates(); |
131 | if ( mExtraViews.count() ) { | 131 | if ( mExtraViews.count() ) { |
132 | KDateNavigator *view = mExtraViews.at( 0 ); | 132 | KDateNavigator *view = mExtraViews.at( 0 ); |
133 | view->dayMatrix()->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end())); | 133 | view->dayMatrix()->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end())); |
134 | view->dayMatrix()->repaint( false ); | 134 | view->dayMatrix()->repaint( false ); |
135 | if ( mExtraViews.count() > 1 ) { | ||
136 | KDateNavigator *view = mExtraViews.at( 1 ); | ||
137 | view->dayMatrix()->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end())); | ||
138 | view->dayMatrix()->repaint( false ); | ||
139 | } | ||
135 | } | 140 | } |
136 | } | 141 | } |
137 | 142 | ||
138 | void DateNavigatorContainer::setBaseDates() | 143 | void DateNavigatorContainer::setBaseDates() |
139 | { | 144 | { |
140 | KCal::DateList dateList = mNavigatorView->selectedDates(); | 145 | KCal::DateList dateList = mNavigatorView->selectedDates(); |
141 | if ( dateList.isEmpty() ) { | 146 | if ( dateList.isEmpty() ) { |
142 | kdError() << "DateNavigatorContainer::selectDates() empty list." << endl; | 147 | kdError() << "DateNavigatorContainer::selectDates() empty list." << endl; |
143 | } | 148 | } |
144 | QDate baseDate = dateList.first(); | 149 | QDate baseDate = dateList.first(); |
145 | KDateNavigator *n; | 150 | KDateNavigator *n; |
146 | bool doRepaint = false; // skip first repaint | 151 | bool doRepaint = false; // skip first repaint |
147 | for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { | 152 | for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { |
148 | baseDate = baseDate.addDays( baseDate.daysInMonth () - baseDate.day() +1 ); | 153 | baseDate = baseDate.addDays( baseDate.daysInMonth () - baseDate.day() +1 ); |
149 | n->setBaseDate( baseDate, doRepaint ); | 154 | n->setBaseDate( baseDate, doRepaint ); |
150 | doRepaint = true; | 155 | doRepaint = true; |
151 | } | 156 | } |
152 | } | 157 | } |
153 | 158 | ||
154 | void DateNavigatorContainer::resizeEvent( QResizeEvent * e ) | 159 | void DateNavigatorContainer::resizeEvent( QResizeEvent * e ) |
155 | { | 160 | { |
156 | #if 0 | 161 | #if 0 |
157 | kdDebug(5850) << "DateNavigatorContainer::resizeEvent()" << endl; | 162 | kdDebug(5850) << "DateNavigatorContainer::resizeEvent()" << endl; |
158 | kdDebug(5850) << " CURRENT SIZE: " << size() << endl; | 163 | kdDebug(5850) << " CURRENT SIZE: " << size() << endl; |
159 | kdDebug(5850) << " MINIMUM SIZEHINT: " << minimumSizeHint() << endl; | 164 | kdDebug(5850) << " MINIMUM SIZEHINT: " << minimumSizeHint() << endl; |
160 | kdDebug(5850) << " SIZEHINT: " << sizeHint() << endl; | 165 | kdDebug(5850) << " SIZEHINT: " << sizeHint() << endl; |
161 | kdDebug(5850) << " MINIMUM SIZE: " << minimumSize() << endl; | 166 | kdDebug(5850) << " MINIMUM SIZE: " << minimumSize() << endl; |
162 | #endif | 167 | #endif |
163 | //QSize minSize = mNavigatorView->sizeHintTwoButtons(); | 168 | //QSize minSize = mNavigatorView->sizeHintTwoButtons(); |
164 | QSize minSize = mNavigatorView->yourSizeHint(); | 169 | QSize minSize = mNavigatorView->yourSizeHint(); |
165 | 170 | ||
166 | // kdDebug(5850) << " NAVIGATORVIEW minimumSizeHint: " << minSize << endl; | 171 | // kdDebug(5850) << " NAVIGATORVIEW minimumSizeHint: " << minSize << endl; |
167 | 172 | ||
168 | int verticalCount = size().height() / minSize.height(); | 173 | int verticalCount = size().height() / minSize.height(); |
169 | int horizontalCount = size().width() / minSize.width(); | 174 | int horizontalCount = size().width() / minSize.width(); |
170 | //qDebug(" wattdatt %d new %d %d ", size().width() ,e->size().width() , minSize.width() ); | 175 | //qDebug(" wattdatt %d new %d %d ", size().width() ,e->size().width() , minSize.width() ); |
171 | //qDebug("COUNT %d %d %d %d ", verticalCount, horizontalCount , mVerticalCount, mHorizontalCount ); | 176 | //qDebug("COUNT %d %d %d %d ", verticalCount, horizontalCount , mVerticalCount, mHorizontalCount ); |
172 | bool fontchange = false; | 177 | bool fontchange = false; |
173 | QFont fo; | 178 | QFont fo; |
174 | if ( horizontalCount != mHorizontalCount || | 179 | if ( horizontalCount != mHorizontalCount || |
175 | verticalCount != mVerticalCount ) { | 180 | verticalCount != mVerticalCount ) { |
176 | uint count = horizontalCount * verticalCount; | 181 | uint count = horizontalCount * verticalCount; |
177 | if ( count == 0 ) { | 182 | if ( count == 0 ) { |
178 | bool ok; | 183 | bool ok; |
179 | fo = mNavigatorView->yourFontHint( size() , &ok); | 184 | fo = mNavigatorView->yourFontHint( size() , &ok); |
180 | //mNavigatorView->resize( size() ); | 185 | //mNavigatorView->resize( size() ); |
181 | //if ( ! ok ) | 186 | //if ( ! ok ) |
182 | // return; | 187 | // return; |
183 | minSize = mNavigatorView->sizeHintTwoButtons(); | 188 | minSize = mNavigatorView->sizeHintTwoButtons(); |
184 | verticalCount = size().height() / minSize.height(); | 189 | verticalCount = size().height() / minSize.height(); |
185 | horizontalCount = size().width() / minSize.width(); | 190 | horizontalCount = size().width() / minSize.width(); |
186 | if ( horizontalCount == 0 ) | 191 | if ( horizontalCount == 0 ) |
187 | horizontalCount = 1; | 192 | horizontalCount = 1; |
188 | if ( verticalCount == 0 ) | 193 | if ( verticalCount == 0 ) |
189 | verticalCount = 1; | 194 | verticalCount = 1; |
190 | fontchange = true; | 195 | fontchange = true; |
191 | count = horizontalCount * verticalCount; | 196 | count = horizontalCount * verticalCount; |
192 | } else { | 197 | } else { |
193 | if ( mNavigatorView->fontChanged() ) { | 198 | if ( mNavigatorView->fontChanged() ) { |
194 | fontchange = true; | 199 | fontchange = true; |
195 | fo = KOPrefs::instance()->mDateNavigatorFont; | 200 | fo = KOPrefs::instance()->mDateNavigatorFont; |
196 | mNavigatorView->changeFont( fo ); | 201 | mNavigatorView->changeFont( fo ); |
197 | mNavigatorView->unsetFontChanged(); | 202 | mNavigatorView->unsetFontChanged(); |
198 | } | 203 | } |
199 | } | 204 | } |
200 | 205 | ||
201 | while ( count > ( mExtraViews.count() + 1 ) ) { | 206 | while ( count > ( mExtraViews.count() + 1 ) ) { |
202 | KDateNavigator *n = new KDateNavigator( this ); | 207 | KDateNavigator *n = new KDateNavigator( this ); |
203 | n->setMonthSignalOffset ( mExtraViews.count()+1 ); | 208 | n->setMonthSignalOffset ( mExtraViews.count()+1 ); |
204 | mExtraViews.append( n ); | 209 | mExtraViews.append( n ); |
205 | n->setCalendar( mCalendar ); | 210 | n->setCalendar( mCalendar ); |
206 | setBaseDates(); | 211 | setBaseDates(); |
207 | connectNavigatorView( n ); | 212 | connectNavigatorView( n ); |
208 | n->show(); | 213 | n->show(); |
209 | } | 214 | } |
210 | int iii = 0; | 215 | int iii = 0; |
211 | while ( iii < ( mExtraViews.count() ) ) { | 216 | while ( iii < ( mExtraViews.count() ) ) { |
212 | if ( iii < count-1 ) | 217 | if ( iii < count-1 ) |
213 | mExtraViews.at( iii )->show(); | 218 | mExtraViews.at( iii )->show(); |
214 | else | 219 | else |
215 | mExtraViews.at( iii )->hide(); | 220 | mExtraViews.at( iii )->hide(); |
216 | ++iii; | 221 | ++iii; |
217 | } | 222 | } |
218 | if ( fontchange ) { | 223 | if ( fontchange ) { |
219 | //mNavigatorView->changeFont( fo ); | 224 | //mNavigatorView->changeFont( fo ); |
220 | uint i; | 225 | uint i; |
221 | for( i = 0; i < mExtraViews.count(); ++i ) { | 226 | for( i = 0; i < mExtraViews.count(); ++i ) { |
222 | KDateNavigator *view = mExtraViews.at( i ); | 227 | KDateNavigator *view = mExtraViews.at( i ); |
223 | view->changeFont( fo ); | 228 | view->changeFont( fo ); |
224 | } | 229 | } |
225 | } | 230 | } |
226 | mHorizontalCount = horizontalCount; | 231 | mHorizontalCount = horizontalCount; |
227 | mVerticalCount = verticalCount; | 232 | mVerticalCount = verticalCount; |
228 | } | 233 | } |
229 | int height = size().height() / verticalCount; | 234 | int height = size().height() / verticalCount; |
230 | int width = size().width() / horizontalCount; | 235 | int width = size().width() / horizontalCount; |
diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp index a776cb6..d7a4112 100644 --- a/korganizer/kodaymatrix.cpp +++ b/korganizer/kodaymatrix.cpp | |||
@@ -197,192 +197,193 @@ QString KODayMatrix::getWhatsThisText( QPoint p ) | |||
197 | mToolTipText += " (" + event->location() + ")"; | 197 | mToolTipText += " (" + event->location() + ")"; |
198 | #if QT_VERSION >= 0x030000 | 198 | #if QT_VERSION >= 0x030000 |
199 | mToolTipText.replace( '<' , "<" ); | 199 | mToolTipText.replace( '<' , "<" ); |
200 | mToolTipText.replace( '>' , ">" ); | 200 | mToolTipText.replace( '>' , ">" ); |
201 | #else | 201 | #else |
202 | if ( mToolTipText.find ('<') >= 0 ) { | 202 | if ( mToolTipText.find ('<') >= 0 ) { |
203 | mToolTipText.replace( QRegExp("<") , "<" ); | 203 | mToolTipText.replace( QRegExp("<") , "<" ); |
204 | } | 204 | } |
205 | if ( mToolTipText.find ('>') >= 0 ) { | 205 | if ( mToolTipText.find ('>') >= 0 ) { |
206 | mToolTipText.replace( QRegExp(">") , ">" ); | 206 | mToolTipText.replace( QRegExp(">") , ">" ); |
207 | } | 207 | } |
208 | #endif | 208 | #endif |
209 | //qDebug("TTT: %s ", mToolTipText.latin1()); | 209 | //qDebug("TTT: %s ", mToolTipText.latin1()); |
210 | mToolTip.append( mToolTipText ); | 210 | mToolTip.append( mToolTipText ); |
211 | } | 211 | } |
212 | mToolTip.sort(); | 212 | mToolTip.sort(); |
213 | return "<b>"+KGlobal::locale()->formatDate(days[tmp]) + "</b><br>" + mToolTip.join("<br>"); | 213 | return "<b>"+KGlobal::locale()->formatDate(days[tmp]) + "</b><br>" + mToolTip.join("<br>"); |
214 | } | 214 | } |
215 | void KODayMatrix::setCalendar( Calendar *cal ) | 215 | void KODayMatrix::setCalendar( Calendar *cal ) |
216 | { | 216 | { |
217 | mCalendar = cal; | 217 | mCalendar = cal; |
218 | 218 | ||
219 | setAcceptDrops( mCalendar ); | 219 | setAcceptDrops( mCalendar ); |
220 | 220 | ||
221 | updateEvents(); | 221 | updateEvents(); |
222 | } | 222 | } |
223 | 223 | ||
224 | QColor KODayMatrix::getShadedColor(QColor color) | 224 | QColor KODayMatrix::getShadedColor(QColor color) |
225 | { | 225 | { |
226 | QColor shaded; | 226 | QColor shaded; |
227 | int h=0; | 227 | int h=0; |
228 | int s=0; | 228 | int s=0; |
229 | int v=0; | 229 | int v=0; |
230 | color.hsv(&h,&s,&v); | 230 | color.hsv(&h,&s,&v); |
231 | s = s/4; | 231 | s = s/4; |
232 | v = 192+v/4; | 232 | v = 192+v/4; |
233 | shaded.setHsv(h,s,v); | 233 | shaded.setHsv(h,s,v); |
234 | 234 | ||
235 | return shaded; | 235 | return shaded; |
236 | } | 236 | } |
237 | 237 | ||
238 | KODayMatrix::~KODayMatrix() | 238 | KODayMatrix::~KODayMatrix() |
239 | { | 239 | { |
240 | // delete mKODaymatrixWhatsThis; | 240 | // delete mKODaymatrixWhatsThis; |
241 | delete [] days; | 241 | delete [] days; |
242 | delete [] daylbls; | 242 | delete [] daylbls; |
243 | delete [] events; | 243 | delete [] events; |
244 | delete mToolTip; | 244 | delete mToolTip; |
245 | } | 245 | } |
246 | 246 | ||
247 | /* | 247 | /* |
248 | void KODayMatrix::setStartDate(QDate start) | 248 | void KODayMatrix::setStartDate(QDate start) |
249 | { | 249 | { |
250 | updateView(start); | 250 | updateView(start); |
251 | } | 251 | } |
252 | */ | 252 | */ |
253 | 253 | ||
254 | void KODayMatrix::addSelectedDaysTo(DateList& selDays) | 254 | void KODayMatrix::addSelectedDaysTo(DateList& selDays) |
255 | { | 255 | { |
256 | 256 | ||
257 | if (mSelStart == NOSELECTION) { | 257 | if (mSelStart == NOSELECTION) { |
258 | return; | 258 | return; |
259 | } | 259 | } |
260 | 260 | ||
261 | //cope with selection being out of matrix limits at top (< 0) | 261 | //cope with selection being out of matrix limits at top (< 0) |
262 | int i0 = mSelStart; | 262 | int i0 = mSelStart; |
263 | if (i0 < 0) { | 263 | if (i0 < 0) { |
264 | for (int i = i0; i < 0; i++) { | 264 | for (int i = i0; i < 0; i++) { |
265 | selDays.append(days[0].addDays(i)); | 265 | selDays.append(days[0].addDays(i)); |
266 | } | 266 | } |
267 | i0 = 0; | 267 | i0 = 0; |
268 | } | 268 | } |
269 | 269 | ||
270 | //cope with selection being out of matrix limits at bottom (> NUMDAYS-1) | 270 | //cope with selection being out of matrix limits at bottom (> NUMDAYS-1) |
271 | if (mSelEnd > NUMDAYS-1) { | 271 | if (mSelEnd > NUMDAYS-1) { |
272 | for (int i = i0; i <= NUMDAYS-1; i++) { | 272 | for (int i = i0; i <= NUMDAYS-1; i++) { |
273 | selDays.append(days[i]); | 273 | selDays.append(days[i]); |
274 | } | 274 | } |
275 | for (int i = NUMDAYS; i < mSelEnd; i++) { | 275 | for (int i = NUMDAYS; i < mSelEnd; i++) { |
276 | selDays.append(days[0].addDays(i)); | 276 | selDays.append(days[0].addDays(i)); |
277 | } | 277 | } |
278 | 278 | ||
279 | // apply normal routine to selection being entirely within matrix limits | 279 | // apply normal routine to selection being entirely within matrix limits |
280 | } else { | 280 | } else { |
281 | for (int i = i0; i <= mSelEnd; i++) { | 281 | for (int i = i0; i <= mSelEnd; i++) { |
282 | selDays.append(days[i]); | 282 | selDays.append(days[i]); |
283 | } | 283 | } |
284 | } | 284 | } |
285 | } | 285 | } |
286 | 286 | ||
287 | void KODayMatrix::setSelectedDaysFrom(const QDate& start, const QDate& end) | 287 | void KODayMatrix::setSelectedDaysFrom(const QDate& start, const QDate& end) |
288 | { | 288 | { |
289 | mSelStart = startdate.daysTo(start); | 289 | mSelStart = startdate.daysTo(start); |
290 | if ( mSelStart < 0 ) | 290 | if ( mSelStart < 0 ) |
291 | mSelStart = 0; | 291 | mSelStart = 0; |
292 | mSelEnd = startdate.daysTo(end); | 292 | mSelEnd = startdate.daysTo(end); |
293 | //qDebug("SELECTION %d %d ", mSelStart ,mSelEnd ); | ||
293 | if ( mSelEnd < 0 ) | 294 | if ( mSelEnd < 0 ) |
294 | clearSelection(); | 295 | clearSelection(); |
295 | } | 296 | } |
296 | void KODayMatrix::clearSelection() | 297 | void KODayMatrix::clearSelection() |
297 | { | 298 | { |
298 | mSelEnd = mSelStart = NOSELECTION; | 299 | mSelEnd = mSelStart = NOSELECTION; |
299 | } | 300 | } |
300 | 301 | ||
301 | 302 | ||
302 | void KODayMatrix::recalculateToday() | 303 | void KODayMatrix::recalculateToday() |
303 | { | 304 | { |
304 | today = -1; | 305 | today = -1; |
305 | for (int i=0; i<NUMDAYS; i++) { | 306 | for (int i=0; i<NUMDAYS; i++) { |
306 | events[i] = 0; | 307 | events[i] = 0; |
307 | days[i] = startdate.addDays(i); | 308 | days[i] = startdate.addDays(i); |
308 | daylbls[i] = QString::number( KOGlobals::self()->calendarSystem()->day( days[i] )); | 309 | daylbls[i] = QString::number( KOGlobals::self()->calendarSystem()->day( days[i] )); |
309 | 310 | ||
310 | // if today is in the currently displayed month, hilight today | 311 | // if today is in the currently displayed month, hilight today |
311 | if (days[i].year() == QDate::currentDate().year() && | 312 | if (days[i].year() == QDate::currentDate().year() && |
312 | days[i].month() == QDate::currentDate().month() && | 313 | days[i].month() == QDate::currentDate().month() && |
313 | days[i].day() == QDate::currentDate().day()) { | 314 | days[i].day() == QDate::currentDate().day()) { |
314 | today = i; | 315 | today = i; |
315 | } | 316 | } |
316 | } | 317 | } |
317 | // qDebug(QString("Today is visible at %1.").arg(today)); | 318 | // qDebug(QString("Today is visible at %1.").arg(today)); |
318 | } | 319 | } |
319 | 320 | ||
320 | void KODayMatrix::updateView() | 321 | void KODayMatrix::updateView() |
321 | { | 322 | { |
322 | updateView(startdate); | 323 | updateView(startdate); |
323 | } | 324 | } |
324 | void KODayMatrix::repaintViewTimed() | 325 | void KODayMatrix::repaintViewTimed() |
325 | { | 326 | { |
326 | mRepaintTimer->stop(); | 327 | mRepaintTimer->stop(); |
327 | repaint(false); | 328 | repaint(false); |
328 | } | 329 | } |
329 | void KODayMatrix::updateViewTimed() | 330 | void KODayMatrix::updateViewTimed() |
330 | { | 331 | { |
331 | mUpdateTimer->stop(); | 332 | mUpdateTimer->stop(); |
332 | if ( !mCalendar ) { | 333 | if ( !mCalendar ) { |
333 | qDebug("NOT CAL "); | 334 | qDebug("NOT CAL "); |
334 | return; | 335 | return; |
335 | } | 336 | } |
336 | //qDebug("KODayMatrix::updateViewTimed "); | 337 | //qDebug("KODayMatrix::updateViewTimed "); |
337 | for(int i = 0; i < NUMDAYS; i++) { | 338 | for(int i = 0; i < NUMDAYS; i++) { |
338 | // if events are set for the day then remember to draw it bold | 339 | // if events are set for the day then remember to draw it bold |
339 | QPtrList<Event> eventlist = mCalendar->events(days[i]); | 340 | QPtrList<Event> eventlist = mCalendar->events(days[i]); |
340 | Event *event; | 341 | Event *event; |
341 | int numEvents = eventlist.count(); | 342 | int numEvents = eventlist.count(); |
342 | QString holiStr = ""; | 343 | QString holiStr = ""; |
343 | bDays.clearBit(i); | 344 | bDays.clearBit(i); |
344 | for(event=eventlist.first();event != 0;event=eventlist.next()) { | 345 | for(event=eventlist.first();event != 0;event=eventlist.next()) { |
345 | ushort recurType = event->recurrence()->doesRecur(); | 346 | ushort recurType = event->recurrence()->doesRecur(); |
346 | if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) || | 347 | if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) || |
347 | (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) { | 348 | (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) { |
348 | numEvents--; | 349 | numEvents--; |
349 | } | 350 | } |
350 | if ( event->categories().contains( i18n("Holiday") ) || event->categories().contains( "Holiday" )) { | 351 | if ( event->categories().contains( i18n("Holiday") ) || event->categories().contains( "Holiday" )) { |
351 | if ( !holiStr.isEmpty() ) | 352 | if ( !holiStr.isEmpty() ) |
352 | holiStr += "\n"; | 353 | holiStr += "\n"; |
353 | holiStr += event->summary(); | 354 | holiStr += event->summary(); |
354 | if ( !event->location().isEmpty() ) | 355 | if ( !event->location().isEmpty() ) |
355 | holiStr += " (" + event->location() + ")"; | 356 | holiStr += " (" + event->location() + ")"; |
356 | } | 357 | } |
357 | if ( event->categories().contains( i18n("Birthday") ) || event->categories().contains( "Birthday" )) { | 358 | if ( event->categories().contains( i18n("Birthday") ) || event->categories().contains( "Birthday" )) { |
358 | if ( !holiStr.isEmpty() ) | 359 | if ( !holiStr.isEmpty() ) |
359 | holiStr += "\n"; | 360 | holiStr += "\n"; |
360 | holiStr += i18n("Birthday") + ": "+event->summary(); | 361 | holiStr += i18n("Birthday") + ": "+event->summary(); |
361 | if ( !event->location().isEmpty() ) | 362 | if ( !event->location().isEmpty() ) |
362 | holiStr += " (" + event->location() + ")"; | 363 | holiStr += " (" + event->location() + ")"; |
363 | bDays.setBit(i); | 364 | bDays.setBit(i); |
364 | } | 365 | } |
365 | } | 366 | } |
366 | events[i] = numEvents; | 367 | events[i] = numEvents; |
367 | //if it is a holy day then draw it red. Sundays are consider holidays, too | 368 | //if it is a holy day then draw it red. Sundays are consider holidays, too |
368 | if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) || | 369 | if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) || |
369 | !holiStr.isEmpty()) { | 370 | !holiStr.isEmpty()) { |
370 | mHolidays[i] = holiStr; | 371 | mHolidays[i] = holiStr; |
371 | } else { | 372 | } else { |
372 | mHolidays[i] = QString::null; | 373 | mHolidays[i] = QString::null; |
373 | } | 374 | } |
374 | } | 375 | } |
375 | if ( ! mPendingUpdateBeforeRepaint ) | 376 | if ( ! mPendingUpdateBeforeRepaint ) |
376 | repaint(false); | 377 | repaint(false); |
377 | } | 378 | } |
378 | void KODayMatrix::updateView(QDate actdate) | 379 | void KODayMatrix::updateView(QDate actdate) |
379 | { | 380 | { |
380 | 381 | ||
381 | if ( ! actdate.isValid() ) { | 382 | if ( ! actdate.isValid() ) { |
382 | //qDebug("date not valid "); | 383 | //qDebug("date not valid "); |
383 | return; | 384 | return; |
384 | } | 385 | } |
385 | mDayChanged = false; | 386 | mDayChanged = false; |
386 | //flag to indicate if the starting day of the matrix has changed by this call | 387 | //flag to indicate if the starting day of the matrix has changed by this call |
387 | //mDayChanged = false; | 388 | //mDayChanged = false; |
388 | // if a new startdate is to be set then apply Cornelius's calculation | 389 | // if a new startdate is to be set then apply Cornelius's calculation |
@@ -598,193 +599,199 @@ void KODayMatrix::dropEvent(QDropEvent *e) | |||
598 | { | 599 | { |
599 | #ifndef KORG_NODND | 600 | #ifndef KORG_NODND |
600 | // kdDebug() << "KODayMatrix::dropEvent(e) begin" << endl; | 601 | // kdDebug() << "KODayMatrix::dropEvent(e) begin" << endl; |
601 | 602 | ||
602 | if (!mCalendar || !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { | 603 | if (!mCalendar || !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { |
603 | e->ignore(); | 604 | e->ignore(); |
604 | return; | 605 | return; |
605 | } | 606 | } |
606 | 607 | ||
607 | DndFactory factory( mCalendar ); | 608 | DndFactory factory( mCalendar ); |
608 | Event *event = factory.createDrop(e); | 609 | Event *event = factory.createDrop(e); |
609 | 610 | ||
610 | if (event) { | 611 | if (event) { |
611 | e->acceptAction(); | 612 | e->acceptAction(); |
612 | 613 | ||
613 | Event *existingEvent = mCalendar->event(event->uid()); | 614 | Event *existingEvent = mCalendar->event(event->uid()); |
614 | 615 | ||
615 | if(existingEvent) { | 616 | if(existingEvent) { |
616 | // uniquify event | 617 | // uniquify event |
617 | event->recreate(); | 618 | event->recreate(); |
618 | /* | 619 | /* |
619 | KMessageBox::sorry(this, | 620 | KMessageBox::sorry(this, |
620 | i18n("Event already exists in this calendar."), | 621 | i18n("Event already exists in this calendar."), |
621 | i18n("Drop Event")); | 622 | i18n("Drop Event")); |
622 | delete event; | 623 | delete event; |
623 | return; | 624 | return; |
624 | */ | 625 | */ |
625 | } | 626 | } |
626 | // kdDebug() << "Drop new Event" << endl; | 627 | // kdDebug() << "Drop new Event" << endl; |
627 | // Adjust date | 628 | // Adjust date |
628 | QDateTime start = event->dtStart(); | 629 | QDateTime start = event->dtStart(); |
629 | QDateTime end = event->dtEnd(); | 630 | QDateTime end = event->dtEnd(); |
630 | int duration = start.daysTo(end); | 631 | int duration = start.daysTo(end); |
631 | int idx = getDayIndexFrom(e->pos().x(), e->pos().y()); | 632 | int idx = getDayIndexFrom(e->pos().x(), e->pos().y()); |
632 | 633 | ||
633 | start.setDate(days[idx]); | 634 | start.setDate(days[idx]); |
634 | end.setDate(days[idx].addDays(duration)); | 635 | end.setDate(days[idx].addDays(duration)); |
635 | 636 | ||
636 | event->setDtStart(start); | 637 | event->setDtStart(start); |
637 | event->setDtEnd(end); | 638 | event->setDtEnd(end); |
638 | mCalendar->addEvent(event); | 639 | mCalendar->addEvent(event); |
639 | 640 | ||
640 | emit eventDropped(event); | 641 | emit eventDropped(event); |
641 | } else { | 642 | } else { |
642 | // kdDebug() << "KODayMatrix::dropEvent(): Event from drop not decodable" << endl; | 643 | // kdDebug() << "KODayMatrix::dropEvent(): Event from drop not decodable" << endl; |
643 | e->ignore(); | 644 | e->ignore(); |
644 | } | 645 | } |
645 | #endif | 646 | #endif |
646 | } | 647 | } |
647 | 648 | ||
648 | // ---------------------------------------------------------------------------- | 649 | // ---------------------------------------------------------------------------- |
649 | // P A I N T E V E N T H A N D L I N G | 650 | // P A I N T E V E N T H A N D L I N G |
650 | // ---------------------------------------------------------------------------- | 651 | // ---------------------------------------------------------------------------- |
651 | 652 | ||
652 | void KODayMatrix::paintEvent(QPaintEvent * pevent) | 653 | void KODayMatrix::paintEvent(QPaintEvent * pevent) |
653 | { | 654 | { |
654 | QRect sz = frameRect(); | 655 | QRect sz = frameRect(); |
655 | if ( sz.width() <= 0 || sz.height() <= 0 ) | 656 | if ( sz.width() <= 0 || sz.height() <= 0 ) |
656 | return; | 657 | return; |
657 | if ( mPendingUpdateBeforeRepaint ) { | 658 | if ( mPendingUpdateBeforeRepaint ) { |
658 | updateViewTimed(); | 659 | updateViewTimed(); |
659 | mPendingUpdateBeforeRepaint = false; | 660 | mPendingUpdateBeforeRepaint = false; |
660 | } | 661 | } |
661 | if ( myPix.width() != sz.width() || myPix.height()!=sz.height() ) { | 662 | if ( myPix.width() != sz.width() || myPix.height()!=sz.height() ) { |
662 | myPix.resize(sz.size() ); | 663 | myPix.resize(sz.size() ); |
663 | } | 664 | } |
664 | QPainter p(&myPix); | 665 | QPainter p(&myPix); |
665 | p.setFont(font()); | 666 | p.setFont(font()); |
666 | 667 | ||
667 | 668 | ||
668 | int dheight = daysize.height(); | 669 | int dheight = daysize.height(); |
669 | int dwidth = daysize.width(); | 670 | int dwidth = daysize.width(); |
670 | int row,col; | 671 | int row,col; |
671 | int selw, selh; | 672 | int selw, selh; |
672 | int xyOff = frameWidth(); | 673 | int xyOff = frameWidth(); |
673 | int colModulo = sz.width() % 7; | 674 | int colModulo = sz.width() % 7; |
674 | int rowModulo = sz.height() % 6; | 675 | int rowModulo = sz.height() % 6; |
675 | //qDebug("col %d row %d ",colModulo,rowModulo ); | 676 | //qDebug("col %d row %d ",colModulo,rowModulo ); |
676 | 677 | ||
677 | bool isRTL = KOGlobals::self()->reverseLayout(); | 678 | bool isRTL = KOGlobals::self()->reverseLayout(); |
678 | 679 | ||
679 | // draw background and topleft frame | 680 | // draw background and topleft frame |
680 | p.fillRect(pevent->rect(), mDefaultBackColor); | 681 | p.fillRect(pevent->rect(), mDefaultBackColor); |
681 | p.setPen(mDefaultTextColor); | 682 | p.setPen(mDefaultTextColor); |
682 | p.drawRect(0, 0, sz.width()+1, sz.height()+1); | 683 | p.drawRect(0, 0, sz.width()+1, sz.height()+1); |
683 | int mSelStartT = mSelStart; | 684 | int mSelStartT = mSelStart; |
684 | int mSelEndT = mSelEnd; | 685 | int mSelEndT = mSelEnd; |
685 | if ( mSelEndT >= NUMDAYS ) | 686 | if ( mSelEndT >= NUMDAYS ) |
686 | mSelEndT = NUMDAYS-1; | 687 | mSelEndT = NUMDAYS-1; |
687 | // draw selected days with highlighted background color | 688 | // draw selected days with highlighted background color |
688 | if (mSelStart != NOSELECTION) { | 689 | if (mSelStart != NOSELECTION) { |
689 | bool skip = false; | 690 | bool skip = false; |
690 | if ( ! mouseDown ) { | 691 | if ( ! mouseDown ) { |
691 | int mo = days[20].month(); | 692 | int mo = days[20].month(); |
692 | //qDebug("-- %d %d ", mSelStartT, mSelEndT); | 693 | //qDebug("-- %d %d ", mSelStartT, mSelEndT); |
693 | //qDebug("%d %d %d - d %d", mo, days[mSelStartT].month() , days[mSelEndT].month(), days[mSelEndT].day() ); | 694 | //qDebug("%d %d %d - d %d", mo, days[mSelStartT].month() , days[mSelEndT].month(), days[mSelEndT].day() ); |
694 | if ( days[mSelStartT].month() > mo || days[mSelEndT].month() < mo ) { | 695 | int startMo = days[mSelStartT].month(); |
696 | int endMo = days[mSelEndT].month(); | ||
697 | if ( startMo == 12 && mo == 1 && endMo == 1 ) | ||
698 | startMo = 1; | ||
699 | if ( endMo == 1 && mo == 12 ) | ||
700 | endMo = 12; | ||
701 | if ( (startMo > mo || endMo < mo) ) { | ||
695 | skip = true; | 702 | skip = true; |
696 | } else { | 703 | } else { |
697 | if ( days[mSelStartT].month() != mo ) { | 704 | if ( days[mSelStartT].month() != mo ) { |
698 | int add = days[mSelStartT].daysInMonth ()-days[mSelStartT].day(); | 705 | int add = days[mSelStartT].daysInMonth ()-days[mSelStartT].day(); |
699 | mSelStartT += add +1; | 706 | mSelStartT += add +1; |
700 | } | 707 | } |
701 | if ( days[mSelEndT].month() != mo ) { | 708 | if ( days[mSelEndT].month() != mo ) { |
702 | int sub = days[mSelEndT].day(); | 709 | int sub = days[mSelEndT].day(); |
703 | mSelEndT -= sub ; | 710 | mSelEndT -= sub ; |
704 | } | 711 | } |
705 | } | 712 | } |
706 | } | 713 | } |
707 | if ( ! skip ) { | 714 | if ( ! skip ) { |
708 | row = mSelStartT/7; | 715 | row = mSelStartT/7; |
709 | col = mSelStartT -row*7; | 716 | col = mSelStartT -row*7; |
710 | QColor selcol = KOPrefs::instance()->mHighlightColor; | 717 | QColor selcol = KOPrefs::instance()->mHighlightColor; |
711 | int addCol = 0; | 718 | int addCol = 0; |
712 | int addRow = 0; | 719 | int addRow = 0; |
713 | int addRow2 = 0; | 720 | int addRow2 = 0; |
714 | int addCol2 = 0; | 721 | int addCol2 = 0; |
715 | if (row == mSelEndT/7) { | 722 | if (row == mSelEndT/7) { |
716 | if ( rowModulo ) { | 723 | if ( rowModulo ) { |
717 | if ( row >= 6 - rowModulo ) | 724 | if ( row >= 6 - rowModulo ) |
718 | addRow = row - 5 + rowModulo; | 725 | addRow = row - 5 + rowModulo; |
719 | } | 726 | } |
720 | if ( colModulo ) { | 727 | if ( colModulo ) { |
721 | int colt1 = mSelEndT%7; | 728 | int colt1 = mSelEndT%7; |
722 | //qDebug("colt1 %d ", colt1 ); | 729 | //qDebug("colt1 %d ", colt1 ); |
723 | if ( colt1 >= 7 - colModulo ) | 730 | if ( colt1 >= 7 - colModulo ) |
724 | addCol = colt1 - 7 + colModulo+1; | 731 | addCol = colt1 - 7 + colModulo+1; |
725 | int colt = mSelStartT%7; | 732 | int colt = mSelStartT%7; |
726 | if ( colt >= 7 - colModulo ) | 733 | if ( colt >= 7 - colModulo ) |
727 | addCol2 = colt - 7 + colModulo; | 734 | addCol2 = colt - 7 + colModulo; |
728 | addCol -= addCol2; | 735 | addCol -= addCol2; |
729 | //qDebug("COL %d %d %d %d ",col , colt1 ,addCol ,addCol2 ); | 736 | //qDebug("COL %d %d %d %d ",col , colt1 ,addCol ,addCol2 ); |
730 | } | 737 | } |
731 | // Single row selection | 738 | // Single row selection |
732 | if ( row == 0) | 739 | if ( row == 0) |
733 | addRow = 1; | 740 | addRow = 1; |
734 | p.fillRect(isRTL ? (7 - (mSelEndT-mSelStartT+1) - col)*dwidth : col*dwidth+1+addCol2, | 741 | p.fillRect(isRTL ? (7 - (mSelEndT-mSelStartT+1) - col)*dwidth : col*dwidth+1+addCol2, |
735 | row*dheight+addRow, (mSelEndT-mSelStartT+1)*dwidth+addCol, dheight+1, selcol); | 742 | row*dheight+addRow, (mSelEndT-mSelStartT+1)*dwidth+addCol, dheight+1, selcol); |
736 | } else { | 743 | } else { |
737 | // draw first row to the right | 744 | // draw first row to the right |
738 | if ( colModulo ) { | 745 | if ( colModulo ) { |
739 | if ( col >= 7 - colModulo ) | 746 | if ( col >= 7 - colModulo ) |
740 | addCol2 = col - 7 + colModulo; | 747 | addCol2 = col - 7 + colModulo; |
741 | } | 748 | } |
742 | if ( rowModulo ) { | 749 | if ( rowModulo ) { |
743 | if ( row >= 6 - rowModulo ) | 750 | if ( row >= 6 - rowModulo ) |
744 | addRow = row - 5 + rowModulo; | 751 | addRow = row - 5 + rowModulo; |
745 | } | 752 | } |
746 | if ( row == 0) | 753 | if ( row == 0) |
747 | addRow = 1; | 754 | addRow = 1; |
748 | p.fillRect(isRTL ? 0 : col*dwidth+1+addCol2, row*dheight+addRow, (7-col)*dwidth+colModulo, | 755 | p.fillRect(isRTL ? 0 : col*dwidth+1+addCol2, row*dheight+addRow, (7-col)*dwidth+colModulo, |
749 | dheight+1, selcol); | 756 | dheight+1, selcol); |
750 | // draw full block till last line | 757 | // draw full block till last line |
751 | selh = mSelEndT/7-row; | 758 | selh = mSelEndT/7-row; |
752 | addRow = 0; | 759 | addRow = 0; |
753 | if ( rowModulo ) { | 760 | if ( rowModulo ) { |
754 | if ( mSelEndT/7 >= 6 - rowModulo ) | 761 | if ( mSelEndT/7 >= 6 - rowModulo ) |
755 | addRow = mSelEndT/7 - 5 + rowModulo; | 762 | addRow = mSelEndT/7 - 5 + rowModulo; |
756 | } | 763 | } |
757 | if (selh > 1) { | 764 | if (selh > 1) { |
758 | p.fillRect(1, (row+1)*dheight, 7*dwidth+colModulo, (selh-1)*dheight+addRow,selcol); | 765 | p.fillRect(1, (row+1)*dheight, 7*dwidth+colModulo, (selh-1)*dheight+addRow,selcol); |
759 | } | 766 | } |
760 | // draw last block from left to mSelEndT | 767 | // draw last block from left to mSelEndT |
761 | selw = mSelEndT-7*(mSelEndT/7)+1; | 768 | selw = mSelEndT-7*(mSelEndT/7)+1; |
762 | //qDebug("esl %d ",selw ); | 769 | //qDebug("esl %d ",selw ); |
763 | int add = 0; | 770 | int add = 0; |
764 | if ( colModulo ) { | 771 | if ( colModulo ) { |
765 | add = 7 - colModulo; | 772 | add = 7 - colModulo; |
766 | if ( selw > add ) | 773 | if ( selw > add ) |
767 | add = selw - add; | 774 | add = selw - add; |
768 | else | 775 | else |
769 | add = 0; | 776 | add = 0; |
770 | } | 777 | } |
771 | //qDebug("add %d ", add); | 778 | //qDebug("add %d ", add); |
772 | p.fillRect(isRTL ? (7-selw)*dwidth : 1, (row+selh)*dheight+addRow, | 779 | p.fillRect(isRTL ? (7-selw)*dwidth : 1, (row+selh)*dheight+addRow, |
773 | selw*dwidth+add, dheight+1, selcol); | 780 | selw*dwidth+add, dheight+1, selcol); |
774 | } | 781 | } |
775 | } | 782 | } |
776 | } | 783 | } |
777 | 784 | ||
778 | // iterate over all days in the matrix and draw the day label in appropriate colors | 785 | // iterate over all days in the matrix and draw the day label in appropriate colors |
779 | QColor actcol = mDefaultTextColorShaded; | 786 | QColor actcol = mDefaultTextColorShaded; |
780 | p.setPen(actcol); | 787 | p.setPen(actcol); |
781 | QPen tmppen; | 788 | QPen tmppen; |
782 | for(int i = 0; i < NUMDAYS; i++) { | 789 | for(int i = 0; i < NUMDAYS; i++) { |
783 | row = i/7; | 790 | row = i/7; |
784 | col = isRTL ? 6-(i-row*7) : i-row*7; | 791 | col = isRTL ? 6-(i-row*7) : i-row*7; |
785 | 792 | ||
786 | // if it is the first day of a month switch color from normal to shaded and vice versa | 793 | // if it is the first day of a month switch color from normal to shaded and vice versa |
787 | if ( KOGlobals::self()->calendarSystem()->day( days[i] ) == 1) { | 794 | if ( KOGlobals::self()->calendarSystem()->day( days[i] ) == 1) { |
788 | if (actcol == mDefaultTextColorShaded) { | 795 | if (actcol == mDefaultTextColorShaded) { |
789 | actcol = mDefaultTextColor; | 796 | actcol = mDefaultTextColor; |
790 | } else { | 797 | } else { |