-rw-r--r-- | libkdepim/kdatepicker.cpp | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/libkdepim/kdatepicker.cpp b/libkdepim/kdatepicker.cpp index 7f352d6..25b4e81 100644 --- a/libkdepim/kdatepicker.cpp +++ b/libkdepim/kdatepicker.cpp @@ -352,138 +352,139 @@ KDatePicker::selectYearClicked() } delete popup; } void KDatePicker::setEnabled(bool enable) { QWidget *widgets[]= { yearForward, yearBackward, monthForward, monthBackward, selectMonth, selectYear, lineDate, table }; const int Size=sizeof(widgets)/sizeof(widgets[0]); int count; // ----- for(count=0; count<Size; ++count) { widgets[count]->setEnabled(enable); } } void KDatePicker::lineEnterPressed() { QDate temp; // ----- temp = lineDate->date(); //if(val->date(line->text(), temp)==QValidator::Acceptable) //{ emit(dateEntered(temp)); setDate(temp); // } else { // KNotifyClient::beep(); // } } QSize KDatePicker::sizeHint() const { QSize tableSize=table->sizeHint(); QWidget *buttons[]={ yearBackward, monthBackward, selectMonth, selectYear, monthForward, yearForward }; const int NoOfButtons=sizeof(buttons)/sizeof(buttons[0]); QSize sizes[NoOfButtons]; int cx=0, cy=0, count; // ----- store the size hints: for(count=0; count<NoOfButtons; ++count) { sizes[count]=buttons[count]->sizeHint(); if(buttons[count]==selectMonth) { cx+=maxMonthRect.width()+15; } else { cx+=sizes[count].width()+15; } cy=QMAX(sizes[count].height(), cy); } // ----- calculate width hint: cx=QMAX(cx, tableSize.width()); // line edit ignored if ( cx > QApplication::desktop()->width() -5 ) cx = QApplication::desktop()->width() -5; // ----- calculate height hint: cy+=tableSize.height()+lineDate->sizeHint().height(); return QSize(cx, cy); } void KDatePicker::setFontSize(int s) { QWidget *buttons[]= { // yearBackward, // monthBackward, selectMonth, selectYear, // monthForward, // yearForward }; const int NoOfButtons=sizeof(buttons)/sizeof(buttons[0]); int count; QFont font; QRect r; // ----- fontsize=s; for(count=0; count<NoOfButtons; ++count) { font=buttons[count]->font(); font.setPointSize(s); buttons[count]->setFont(font); } QFontMetrics metrics(selectMonth->fontMetrics()); for(int i=1; i <= 12; ++i) { // maxMonthRect is used by sizeHint() r=metrics.boundingRect(KGlobal::locale()->monthName(i, false)); maxMonthRect.setWidth(QMAX(r.width(), maxMonthRect.width())); maxMonthRect.setHeight(QMAX(r.height(), maxMonthRect.height())); } table->setFontSize(s); } void KDatePicker::virtual_hook( int id, void* data ) { /*BASE::virtual_hook( id, data );*/ } void KDatePicker::keyPressEvent ( QKeyEvent * e ) { switch ( e->key() ) { case Qt::Key_Right: monthForwardClicked(); break; case Qt::Key_Left: monthBackwardClicked(); break; case Qt::Key_Down: yearForwardClicked(); break; case Qt::Key_Up: yearBackwardClicked(); break; case Qt::Key_Return: case Qt::Key_Enter: + case Qt::Key_Space: tableClickedSlot(); break; case Qt::Key_Escape: e->ignore(); break; default: break; } } |