author | zautrix <zautrix> | 2005-10-27 23:22:36 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-10-27 23:22:36 (UTC) |
commit | cbda16d4966c7483d20d1b6b5a64c8af367ea732 (patch) (unidiff) | |
tree | 47099fd5b318c47eb1d8fff3d8a3eef6e34f6f23 /microkde | |
parent | d6d384e50cfd511866958e58cdd3adeb35ed1c4e (diff) | |
download | kdepimpi-cbda16d4966c7483d20d1b6b5a64c8af367ea732.zip kdepimpi-cbda16d4966c7483d20d1b6b5a64c8af367ea732.tar.gz kdepimpi-cbda16d4966c7483d20d1b6b5a64c8af367ea732.tar.bz2 |
us fix
-rw-r--r-- | microkde/kdatetbl.cpp | 32 |
1 files changed, 10 insertions, 22 deletions
diff --git a/microkde/kdatetbl.cpp b/microkde/kdatetbl.cpp index 4271b55..353f78d 100644 --- a/microkde/kdatetbl.cpp +++ b/microkde/kdatetbl.cpp | |||
@@ -179,169 +179,157 @@ KDateTable::paintCell(QPainter *painter, int row, int col) | |||
179 | painter->setBrush(darkRed); | 179 | painter->setBrush(darkRed); |
180 | pen=white; | 180 | pen=white; |
181 | } else { | 181 | } else { |
182 | painter->setBrush(darkGray); | 182 | painter->setBrush(darkGray); |
183 | pen=white; | 183 | pen=white; |
184 | } | 184 | } |
185 | } else { | 185 | } else { |
186 | if(mMarkCurrent && firstday+QDate::currentDate().day()-1==pos) | 186 | if(mMarkCurrent && firstday+QDate::currentDate().day()-1==pos) |
187 | { | 187 | { |
188 | painter->setPen(green); | 188 | painter->setPen(green); |
189 | painter->setBrush(darkGreen); | 189 | painter->setBrush(darkGreen); |
190 | pen=white; | 190 | pen=white; |
191 | } else { | 191 | } else { |
192 | painter->setBrush(QColor(220,245,255)); | 192 | painter->setBrush(QColor(220,245,255)); |
193 | painter->setPen(QColor(220,245,255)); | 193 | painter->setPen(QColor(220,245,255)); |
194 | } | 194 | } |
195 | } | 195 | } |
196 | painter->drawRect(0, 0, w, h); | 196 | painter->drawRect(0, 0, w, h); |
197 | painter->setPen(pen); | 197 | painter->setPen(pen); |
198 | painter->drawText(0, 0, w, h, AlignCenter, text, -1, &rect); | 198 | painter->drawText(0, 0, w, h, AlignCenter, text, -1, &rect); |
199 | } | 199 | } |
200 | /* | 200 | /* |
201 | if(rect.width()>maxCell.width()) maxCell.setWidth(rect.width()); | 201 | if(rect.width()>maxCell.width()) maxCell.setWidth(rect.width()); |
202 | if(rect.height()>maxCell.height()) { | 202 | if(rect.height()>maxCell.height()) { |
203 | maxCell.setHeight(rect.height()); | 203 | maxCell.setHeight(rect.height()); |
204 | } | 204 | } |
205 | */ | 205 | */ |
206 | } | 206 | } |
207 | 207 | ||
208 | void | 208 | void |
209 | KDateTable::keyPressEvent( QKeyEvent *e ) | 209 | KDateTable::keyPressEvent( QKeyEvent *e ) |
210 | { | 210 | { |
211 | /* | 211 | /* |
212 | // not working properly | 212 | // not working properly |
213 | if ( e->key() == Qt::Key_Prior ) { | 213 | if ( e->key() == Qt::Key_Prior ) { |
214 | if ( date.month() == 1 ) { | 214 | if ( date.month() == 1 ) { |
215 | KNotifyClient::beep(); | 215 | KNotifyClient::beep(); |
216 | return; | 216 | return; |
217 | } | 217 | } |
218 | int day = date.day(); | 218 | int day = date.day(); |
219 | if ( day > 27 ) | 219 | if ( day > 27 ) |
220 | while ( !QDate::isValid( date.year(), date.month()-1, day ) ) | 220 | while ( !QDate::isValid( date.year(), date.month()-1, day ) ) |
221 | day--; | 221 | day--; |
222 | setDate(QDate(date.year(), date.month()-1, day)); | 222 | setDate(QDate(date.year(), date.month()-1, day)); |
223 | return; | 223 | return; |
224 | } | 224 | } |
225 | if ( e->key() == Qt::Key_Next ) { | 225 | if ( e->key() == Qt::Key_Next ) { |
226 | if ( date.month() == 12 ) { | 226 | if ( date.month() == 12 ) { |
227 | KNotifyClient::beep(); | 227 | KNotifyClient::beep(); |
228 | return; | 228 | return; |
229 | } | 229 | } |
230 | int day = date.day(); | 230 | int day = date.day(); |
231 | if ( day > 27 ) | 231 | if ( day > 27 ) |
232 | while ( !QDate::isValid( date.year(), date.month()+1, day ) ) | 232 | while ( !QDate::isValid( date.year(), date.month()+1, day ) ) |
233 | day--; | 233 | day--; |
234 | setDate(QDate(date.year(), date.month()+1, day)); | 234 | setDate(QDate(date.year(), date.month()+1, day)); |
235 | return; | 235 | return; |
236 | } | 236 | } |
237 | */ | 237 | */ |
238 | int dayoff = KGlobal::locale()->weekStartsMonday() ? 1 : 0; | 238 | int dayoff = KGlobal::locale()->weekStartsMonday() ? 1 : 0; |
239 | 239 | ||
240 | int temp=firstday+date.day()-dayoff; | 240 | int temp=firstday+date.day()-dayoff; |
241 | int pos = temp; | 241 | int pos = temp; |
242 | bool irgnore = true; | 242 | bool irgnore = true; |
243 | int add = 0; | ||
243 | if ( e->state() != Qt::ControlButton ) { | 244 | if ( e->state() != Qt::ControlButton ) { |
244 | if ( e->key() == Qt::Key_Up ) { | 245 | if ( e->key() == Qt::Key_Up ) { |
245 | pos -= 7; | 246 | add -= 7; |
246 | irgnore = false; | 247 | irgnore = false; |
247 | } | 248 | } |
248 | if ( e->key() == Qt::Key_Down ) { | 249 | if ( e->key() == Qt::Key_Down ) { |
249 | pos += 7; | 250 | add += 7; |
250 | irgnore = false; | 251 | irgnore = false; |
251 | } | 252 | } |
252 | if ( e->key() == Qt::Key_Left ) { | 253 | if ( e->key() == Qt::Key_Left ) { |
253 | pos--; | 254 | --add; |
254 | irgnore = false; | 255 | irgnore = false; |
255 | } | 256 | } |
256 | if ( e->key() == Qt::Key_Right ) { | 257 | if ( e->key() == Qt::Key_Right ) { |
257 | pos++; | 258 | ++add; |
258 | irgnore = false; | 259 | irgnore = false; |
259 | } | 260 | } |
260 | } | 261 | } |
261 | if ( irgnore ) | 262 | if ( irgnore ) { |
262 | e->ignore(); | 263 | e->ignore(); |
263 | |||
264 | if(pos+dayoff<=firstday) | ||
265 | { // this day is in the previous month | ||
266 | KNotifyClient::beep(); | ||
267 | return; | ||
268 | } | ||
269 | if(firstday+numdays<pos+dayoff) | ||
270 | { // this date is in the next month | ||
271 | KNotifyClient::beep(i18n( "Month not long enough" )); | ||
272 | return; | ||
273 | } | ||
274 | |||
275 | if ( pos == temp ) | ||
276 | return; | 264 | return; |
265 | } | ||
277 | 266 | ||
278 | setDate(QDate(date.year(), date.month(), pos-firstday+dayoff)); | 267 | pos += add; |
268 | setDate(date.addDays( add )); | ||
279 | updateCell(temp/7+1, temp%7); // Update the previously selected cell | 269 | updateCell(temp/7+1, temp%7); // Update the previously selected cell |
280 | updateCell(pos/7+1, pos%7); // Update the selected cell | 270 | updateCell(pos/7+1, pos%7); // Update the selected cell |
281 | assert(QDate(date.year(), date.month(), pos-firstday+dayoff).isValid()); | 271 | |
282 | |||
283 | |||
284 | } | 272 | } |
285 | 273 | ||
286 | void | 274 | void |
287 | KDateTable::viewportResizeEvent(QResizeEvent * e) | 275 | KDateTable::viewportResizeEvent(QResizeEvent * e) |
288 | { | 276 | { |
289 | QGridView::viewportResizeEvent(e); | 277 | QGridView::viewportResizeEvent(e); |
290 | 278 | ||
291 | setCellWidth(viewport()->width()/7); | 279 | setCellWidth(viewport()->width()/7); |
292 | setCellHeight(viewport()->height()/7); | 280 | setCellHeight(viewport()->height()/7); |
293 | } | 281 | } |
294 | 282 | ||
295 | void | 283 | void |
296 | KDateTable::setFontSize(int size) | 284 | KDateTable::setFontSize(int size) |
297 | { | 285 | { |
298 | int count; | 286 | int count; |
299 | QRect rect; | 287 | QRect rect; |
300 | // ----- store rectangles: | 288 | // ----- store rectangles: |
301 | fontsize=size; | 289 | fontsize=size; |
302 | QFont _font = font(); | 290 | QFont _font = font(); |
303 | _font.setPointSize(fontsize); | 291 | _font.setPointSize(fontsize); |
304 | setFont( _font ); | 292 | setFont( _font ); |
305 | _font.setBold( true ); | 293 | _font.setBold( true ); |
306 | QFontMetrics metrics(_font); | 294 | QFontMetrics metrics(_font); |
307 | 295 | ||
308 | // ----- find largest day name: | 296 | // ----- find largest day name: |
309 | maxCell.setWidth(0); | 297 | maxCell.setWidth(0); |
310 | maxCell.setHeight(0); | 298 | maxCell.setHeight(0); |
311 | for(count=0; count<7; ++count) | 299 | for(count=0; count<7; ++count) |
312 | { | 300 | { |
313 | rect=metrics.boundingRect(KGlobal::locale()->weekDayName(count+1, true)); | 301 | rect=metrics.boundingRect(KGlobal::locale()->weekDayName(count+1, true)); |
314 | maxCell.setWidth(QMAX(maxCell.width(), rect.width())); | 302 | maxCell.setWidth(QMAX(maxCell.width(), rect.width())); |
315 | maxCell.setHeight(QMAX(maxCell.height(), rect.height())); | 303 | maxCell.setHeight(QMAX(maxCell.height(), rect.height())); |
316 | } | 304 | } |
317 | // ----- compare with a real wide number and add some space: | 305 | // ----- compare with a real wide number and add some space: |
318 | rect=metrics.boundingRect(QString::fromLatin1("88")); | 306 | rect=metrics.boundingRect(QString::fromLatin1("88")); |
319 | maxCell.setWidth(QMAX(maxCell.width()+2, rect.width())); | 307 | maxCell.setWidth(QMAX(maxCell.width()+2, rect.width())); |
320 | #ifdef DESKTOP_VERSION | 308 | #ifdef DESKTOP_VERSION |
321 | maxCell.setHeight(QMAX(maxCell.height()+8, rect.height())); | 309 | maxCell.setHeight(QMAX(maxCell.height()+8, rect.height())); |
322 | #else | 310 | #else |
323 | maxCell.setHeight(QMAX(maxCell.height()+4, rect.height())); | 311 | maxCell.setHeight(QMAX(maxCell.height()+4, rect.height())); |
324 | #endif | 312 | #endif |
325 | if ( maxCell.width() * 1000 / maxCell.height() > 1900 ) { | 313 | if ( maxCell.width() * 1000 / maxCell.height() > 1900 ) { |
326 | maxCell.setHeight(maxCell.width() * 1000 / 1900 ); | 314 | maxCell.setHeight(maxCell.width() * 1000 / 1900 ); |
327 | //qDebug("setmax "); | 315 | //qDebug("setmax "); |
328 | } | 316 | } |
329 | } | 317 | } |
330 | 318 | ||
331 | void | 319 | void |
332 | KDateTable::contentsMousePressEvent(QMouseEvent *e) | 320 | KDateTable::contentsMousePressEvent(QMouseEvent *e) |
333 | { | 321 | { |
334 | if(e->type()!=QEvent::MouseButtonPress) | 322 | if(e->type()!=QEvent::MouseButtonPress) |
335 | { // the KDatePicker only reacts on mouse press events: | 323 | { // the KDatePicker only reacts on mouse press events: |
336 | return; | 324 | return; |
337 | } | 325 | } |
338 | if(!isEnabled()) | 326 | if(!isEnabled()) |
339 | { | 327 | { |
340 | KNotifyClient::beep(); | 328 | KNotifyClient::beep(); |
341 | return; | 329 | return; |
342 | } | 330 | } |
343 | 331 | ||
344 | int dayoff = KGlobal::locale()->weekStartsMonday() ? 1 : 0; | 332 | int dayoff = KGlobal::locale()->weekStartsMonday() ? 1 : 0; |
345 | // ----- | 333 | // ----- |
346 | int row, col, pos, temp; | 334 | int row, col, pos, temp; |
347 | QPoint mouseCoord; | 335 | QPoint mouseCoord; |