summaryrefslogtreecommitdiffabout
path: root/microkde
Unidiff
Diffstat (limited to 'microkde') (more/less context) (show whitespace changes)
-rw-r--r--microkde/kdatetbl.cpp28
1 files changed, 8 insertions, 20 deletions
diff --git a/microkde/kdatetbl.cpp b/microkde/kdatetbl.cpp
index 4271b55..353f78d 100644
--- a/microkde/kdatetbl.cpp
+++ b/microkde/kdatetbl.cpp
@@ -219,88 +219,76 @@ KDateTable::keyPressEvent( QKeyEvent *e )
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; 264 return;
273 } 265 }
274 266
275 if ( pos == temp ) 267 pos += add;
276 return; 268 setDate(date.addDays( add ));
277
278 setDate(QDate(date.year(), date.month(), pos-firstday+dayoff));
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());
282
283 271
284} 272}
285 273
286void 274void
287KDateTable::viewportResizeEvent(QResizeEvent * e) 275KDateTable::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
295void 283void
296KDateTable::setFontSize(int size) 284KDateTable::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);