-rw-r--r-- | libkdepim/kdateedit.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/libkdepim/kdateedit.cpp b/libkdepim/kdateedit.cpp index c4c0081..2c78ea3 100644 --- a/libkdepim/kdateedit.cpp +++ b/libkdepim/kdateedit.cpp @@ -381,100 +381,101 @@ void KDateEdit::setSelect( int from, int to ) void KDateEdit::toggleDatePicker() { if( mDateFrame->isVisible() ) { mDateFrame->hide(); } else { QPoint tmpPoint = mapToGlobal(mDateButton->geometry().bottomRight()); QSize datepickersize = mDatePicker->sizeHint(); if ( tmpPoint.x() < 7+datepickersize.width() ) tmpPoint.setX( 7+datepickersize.width() ); int h = QApplication::desktop()->height(); if ( tmpPoint.y() + datepickersize.height() > h ) tmpPoint.setY( h - datepickersize.height() ); mDateFrame->setGeometry(tmpPoint.x()-datepickersize.width()-7, tmpPoint.y(), datepickersize.width()+2*mDateFrame->lineWidth(), datepickersize.height()+2*mDateFrame->lineWidth()); QDate date = readDate(); if(date.isValid()) { mDatePicker->setDate(date); } else { mDatePicker->setDate(QDate::currentDate()); } mDateFrame->show(); } } void KDateEdit::lineEnterPressed() { QDate date = readDate(); if(date.isValid()) { // Update the edit. This is needed if the user has entered a // word rather than the actual date. setDate(date); emit(dateChanged(date)); emit returnPressed(); } else { if ( withoutDp ) { KNotifyClient::beep(); } else { if ( !mDateEdit->text().isEmpty() ) { mTextChanged = false; QString text = i18n( "You entered an invalid date!\n Will use current date instead." ); - if ( KMessageBox::warningContinueCancel( 0, text ) == KMessageBox::Continue ) { - setDate( QDate::currentDate() ); - emit dateChanged( QDate::currentDate() ); - } + if ( isVisible() ) + if ( KMessageBox::warningContinueCancel( 0, text ) == KMessageBox::Continue ) { + setDate( QDate::currentDate() ); + emit dateChanged( QDate::currentDate() ); + } } } } } bool KDateEdit::inputIsValid() { return readDate().isValid(); } QDate KDateEdit::readDate() const { QString text = mDateEdit->text(); QDate date; if (mKeywordMap.contains(text.lower())) { date = QDate::currentDate().addDays(mKeywordMap[text.lower()]); } else { date = KGlobal::locale()->readDate(text); } return date; } bool KDateEdit::eventFilter(QObject *, QEvent *e) { // We only process the focus out event if the text has changed // since we got focus if ((e->type() == QEvent::FocusOut) && mTextChanged) { lineEnterPressed(); mTextChanged = false; } // switch dateFormShort by double klick with mouse else if (e->type() == QEvent::MouseButtonDblClick) { toggleDateFormat(); } else if (e->type() == QEvent::FocusIn) { maxDay = readDate().day(); } return false; } |