Logo Search packages:      
Sourcecode: qtodo version File versions  Download package

void QTodoDateEdit::addNumber ( int  sec,
int  num 
) [protected, virtual]

Implements QTodoDateTimeEditBase.

Definition at line 1671 of file qtodo_datetimeedit.cpp.

References outOfRange(), and valueChanged().

{
      if ( sec == -1 )
            return;
      killTimer( d->timerId );
      bool overwrite = FALSE;
      bool accepted = FALSE;
      d->typing = TRUE;
      QString txt;
      if ( sec == d->yearSection )
      {
            txt = QString::number( d->y );
            if ( d->overwrite || txt.length() == 4 )
            {
                  accepted = TRUE;
                  d->y = num;
            }
            else
            {
                  txt += QString::number( num );
                  if ( txt.length() == 4  )
                  {
                        int val = txt.toInt();
                        if ( val < 1792 )
                              d->y = 1792;
                        else if ( val > 8000 )
                              d->y = 8000;
                        else if ( outOfRange( val, d->m, d->d ) )
                              txt = QString::number( d->y );
                        else
                        {
                              accepted = TRUE;
                              d->y = val;
                        }
                  }
                  else
                  {
                        accepted = TRUE;
                        d->y = txt.toInt();
                  }
                  if ( d->adv && txt.length() == 4 )
                  {
                        d->ed->setFocusSection( d->ed->focusSection()+1 );
                        overwrite = TRUE;
                  }
            }
      }
      else if ( sec == d->monthSection )
      {
            txt = QString::number( d->m );
            if ( d->overwrite || txt.length() == 2 )
            {
                  accepted = TRUE;
                  d->m = num;
            }
            else
            {
                  txt += QString::number( num );
                  int temp = txt.toInt();
                  if ( temp > 12 )
                        temp = num;
                  if ( outOfRange( d->y, temp, d->d ) )
                        txt = QString::number( d->m );
                  else
                  {
                        accepted = TRUE;
                        d->m = temp;
                  }
                  if ( d->adv && txt.length() == 2 )
                  {
                        d->ed->setFocusSection( d->ed->focusSection()+1 );
                        overwrite = TRUE;
                  }
            }
      }
      else if ( sec == d->daySection )
      {
            txt = QString::number( d->d );
            if ( d->overwrite || txt.length() == 2 )
            {
                  accepted = TRUE;
                  d->d = num;
                  d->dayCache = d->d;
            }
            else
            {
                  txt += QString::number( num );
                  int temp = txt.toInt();
                  if ( temp > 31 )
                        temp = num;
                  if ( outOfRange( d->y, d->m, temp ) )
                        txt = QString::number( d->d );
                  else
                  {
                        accepted = TRUE;
                        d->d = temp;
                        d->dayCache = d->d;
                  }
                  if ( d->adv && txt.length() == 2 )
                  {
                        d->ed->setFocusSection( d->ed->focusSection()+1 );
                        overwrite = TRUE;
                  }
            }
      }
      if ( accepted )
      {
            d->changed = TRUE;
            emit valueChanged( date() );
      }
      d->overwrite = overwrite;
      d->timerId = startTimer( qApp->doubleClickInterval()*4 );
      d->ed->repaint( d->ed->rect(), FALSE );
}


Generated by  Doxygen 1.6.0   Back to index