From a2d65f2df1fadf40277bb0af011c87c63efbe935 Mon Sep 17 00:00:00 2001 From: Jason Harris Date: Sat, 21 Jan 2006 16:02:17 +0000 Subject: [PATCH] Partial fix of bug #119963 It is now possible to manually enter a year in a date edit box CCBUG: 119963 svn path=/branches/KDE/3.5/kdeedu/libkdeedu/; revision=500928 --- extdate/extdatetimeedit.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/extdate/extdatetimeedit.cpp b/extdate/extdatetimeedit.cpp index 3b89c10..2a9a467 100644 --- a/extdate/extdatetimeedit.cpp +++ b/extdate/extdatetimeedit.cpp @@ -1365,6 +1365,17 @@ void ExtDateEdit::addNumber( int sec, int num ) d->typing = TRUE; QString txt; if ( sec == d->yearSection ) { + if ( d->overwrite ) { + d->y = num; + d->overwrite = FALSE; + accepted = TRUE; + } else { + txt = QString::number( 10*d->y + num ); + if ( txt.length() > 5 ) txt = txt.mid(1); + d->y = txt.toInt(); + accepted = TRUE; + } +/* txt = QString::number( d->y ); if ( d->overwrite || txt.length() == 4 ) { accepted = TRUE; @@ -1392,6 +1403,7 @@ void ExtDateEdit::addNumber( int sec, int num ) overwrite = TRUE; } } +*/ } else if ( sec == d->monthSection ) { txt = QString::number( d->m ); if ( d->overwrite || txt.length() == 2 ) { @@ -1492,6 +1504,7 @@ void ExtDateEdit::fix() int currentYear = ExtDate::currentDate().year(); int year = d->y; +/* No longer valid for extended dates if ( year < 100 ) { int currentCentury = currentYear / 100; year += currentCentury * 100; @@ -1508,6 +1521,7 @@ void ExtDateEdit::fix() year += currentMillennium * 10; changed = TRUE; } +*/ if ( changed && outOfRange( year, d->m, d->d ) ) { if ( minValue().isValid() && date() < minValue() ) { d->d = minValue().day(); @@ -1539,6 +1553,7 @@ bool ExtDateEdit::event( QEvent *e ) { if( e->type() == QEvent::FocusOut ) { d->typing = FALSE; + d->overwrite = TRUE; // the following can't be done in fix() because fix() called // from all over the place and it will break the old behaviour if ( !ExtDate::isValid( d->y, d->m, d->d ) ) { -- 2.47.3