src/hbwidgets/widgets/hbdatetimepicker_p.cpp
changeset 28 b7da29130b0e
parent 23 e6ad4ef83b23
equal deleted inserted replaced
23:e6ad4ef83b23 28:b7da29130b0e
   184                         return false; // error in format
   184                         return false; // error in format
   185                     }
   185                     }
   186                     newDisplay |= AmPmSection;
   186                     newDisplay |= AmPmSection;
   187                     if (i + 1 < format.size()
   187                     if (i + 1 < format.size()
   188                         && format.at(i+1) == (cap ? QLatin1Char('P') : QLatin1Char('p'))) {
   188                         && format.at(i+1) == (cap ? QLatin1Char('P') : QLatin1Char('p'))) {
   189                             ++i;
   189                         ++i;
   190                     }
   190                     }
   191                     index = i + 1;
   191                     index = i + 1;
   192                 }
   192                 }
   193                 break;
   193                 break;
   194             case 'y':
   194             case 'y':
   195                 {
   195                 {
   196                     const int repeat = countRepeat(format, i, 4);
   196                     const int repeat = countRepeat(format, i, 4);
   197                     if (repeat >= 2) {
   197                     if (repeat >= 2) {
   198                         const SectionNode sn = { repeat == 4 ? YearSection : YearSection2Digits,
   198                         const SectionNode sn = { repeat == 4 ? YearSection : YearSection2Digits,
   199                             i - add, repeat == 4 ? 4 : 2 };
   199                                                  i - add, repeat == 4 ? 4 : 2 };
   200                         newSectionNodes.append(sn);
   200                         newSectionNodes.append(sn);
   201                         appendSeparator(&newSeparators, format, index, i - index, lastQuote);
   201                         appendSeparator(&newSeparators, format, index, i - index, lastQuote);
   202                         i += sn.count - 1;
   202                         i += sn.count - 1;
   203                         index = i + 1;
   203                         index = i + 1;
   204                         if(newDisplay & sn.type) {
   204                         if(newDisplay & sn.type) {
   276     }
   276     }
   277     if (sectionIndex == mSectionNodes.size() - 1) {
   277     if (sectionIndex == mSectionNodes.size() - 1) {
   278         return mDisplayFormat.size() - sectionPos(sectionIndex) - mSeparators.last().size();
   278         return mDisplayFormat.size() - sectionPos(sectionIndex) - mSeparators.last().size();
   279     } else {
   279     } else {
   280         return sectionPos(sectionIndex + 1) - sectionPos(sectionIndex)
   280         return sectionPos(sectionIndex + 1) - sectionPos(sectionIndex)
   281             - mSeparators.at(sectionIndex + 1).size();
   281                 - mSeparators.at(sectionIndex + 1).size();
   282     }
   282     }
   283 }
   283 }
   284 
   284 
   285 int HbDateTimeParser::sectionPos(int sectionIndex) const
   285 int HbDateTimeParser::sectionPos(int sectionIndex) const
   286 {
   286 {
   302 }
   302 }
   303 /////////////////////////////////////////////////
   303 /////////////////////////////////////////////////
   304 
   304 
   305 
   305 
   306 HbDateTimePickerPrivate::HbDateTimePickerPrivate()
   306 HbDateTimePickerPrivate::HbDateTimePickerPrivate()
   307 :HbWidgetPrivate()
   307     :HbWidgetPrivate()
   308     ,mDayPicker(0)
   308     ,mDayPicker(0)
   309     ,mMonthPicker(0)
   309     ,mMonthPicker(0)
   310     ,mYearPicker(0)
   310     ,mYearPicker(0)
   311     ,mHourPicker(0)
   311     ,mHourPicker(0)
   312     ,mMinutePicker(0)
   312     ,mMinutePicker(0)
   327     ,mSecondOffset(-1)
   327     ,mSecondOffset(-1)
   328     ,mDateTime(QDateTime::currentDateTime())
   328     ,mDateTime(QDateTime::currentDateTime())
   329     ,mDateTimeMode(QVariant::Date) //default is date mode
   329     ,mDateTimeMode(QVariant::Date) //default is date mode
   330     ,mLayout(0)         
   330     ,mLayout(0)         
   331     //,mFormat() //set the format again in init()
   331     //,mFormat() //set the format again in init()
       
   332     ,mFormatEventType(-1)
   332     //,mDisplaySecions() //is blank by default
   333     //,mDisplaySecions() //is blank by default
   333     ,mParser()
   334     ,mParser()
   334     ,mYearFormat()
   335     ,mYearFormat()
   335     ,mMonthFormat()
   336     ,mMonthFormat()
   336     ,mDayFormat()
   337     ,mDayFormat()
   337     ,mHourFormat()
   338     ,mHourFormat()
   338     ,mMinuteFormat()
   339     ,mMinuteFormat()
   339     ,mSecondFormat() 
   340     ,mSecondFormat() 
   340     ,mIs24HourFormat(false)
   341     ,mIs24HourFormat(false)
   341     ,mIsTwoDigitYearFormat(false)
   342     ,mIsTwoDigitYearFormat(false)
       
   343     ,mContent(0)
       
   344     ,mIntervals()
   342     ,mBackground(0)
   345     ,mBackground(0)
   343     ,mFrame(0)
   346     ,mFrame(0)
   344     ,mContent(0)
       
   345     ,mIntervals()
       
   346     ,mHighlight(0)
   347     ,mHighlight(0)
   347 {
   348 {
   348     mMinimumDate = HBDATETIMEPICKER_DATETIME_MIN;
   349     mMinimumDate = HBDATETIMEPICKER_DATETIME_MIN;
   349     mMaximumDate = HBDATETIMEPICKER_DATETIME_MAX;
   350     mMaximumDate = HBDATETIMEPICKER_DATETIME_MAX;
   350     mDateTime = mMinimumDate;
   351     mDateTime = mMinimumDate;
   370     mContent->setLayout(mLayout);
   371     mContent->setLayout(mLayout);
   371     HbStyle::setItemName(mContent,"content");
   372     HbStyle::setItemName(mContent,"content");
   372 
   373 
   373     mDateTimeMode = dateTimeMode;
   374     mDateTimeMode = dateTimeMode;
   374     mIntervals[QDateTimeEdit::MinuteSection]=1;
   375     mIntervals[QDateTimeEdit::MinuteSection]=1;
   375 
   376     mFormatEventType = QEvent::registerEventType(QEvent::User+1);
   376     //read the format from locale
   377     //read the format from locale
   377     QString newFormat = localeDateTimeFormat(dateTimeMode);
   378     QString newFormat = localeDateTimeFormat(dateTimeMode);
   378 
   379     if(isFormatValid(newFormat)){
   379     //parse the format and set the sections in order
   380         mFormat = newFormat;
   380     if(isFormatValid(newFormat)) {
   381         postFormatEvent();
   381         mFormat=newFormat;
   382     }
   382         processDisplaySections();
   383     
   383     }
       
   384 
       
   385     //create primitives
   384     //create primitives
   386     createPrimitives();
   385     createPrimitives();
   387 
       
   388     //recreate and rearrange depending on the format
       
   389     rearrangeTumbleViews();
       
   390 }
   386 }
   391 
   387 
   392 /*!
   388 /*!
   393   \internal
   389   \internal
   394 
   390 
   417    this will reset the display sections and re add them in order
   413    this will reset the display sections and re add them in order
   418    mentioned in the display format passed. this also sets the mIs24HourFormat var.
   414    mentioned in the display format passed. this also sets the mIs24HourFormat var.
   419 */
   415 */
   420 void HbDateTimePickerPrivate::processDisplaySections()
   416 void HbDateTimePickerPrivate::processDisplaySections()
   421 {
   417 {
   422         for(int i=0;i<mParser.mSectionNodes.count();++i) {
   418     for(int i=0;i<mParser.mSectionNodes.count();++i) {
   423             switch(mParser.mSectionNodes[i].type) {
   419         switch(mParser.mSectionNodes[i].type) {
   424                 case HbDateTimeParser::DaySection:
   420         case HbDateTimeParser::DaySection:
   425                 case HbDateTimeParser::DayOfWeekSection:
   421         case HbDateTimeParser::DayOfWeekSection:
   426                     mDayFormat = QString(mParser.mSectionNodes[i].count,'d');
   422             mDayFormat = QString(mParser.mSectionNodes[i].count,'d');
   427                     break;
   423             break;
   428 
   424 
   429                 case HbDateTimeParser::MonthSection:
   425         case HbDateTimeParser::MonthSection:
   430                     mMonthFormat = QString(mParser.mSectionNodes[i].count,'M');
   426             mMonthFormat = QString(mParser.mSectionNodes[i].count,'M');
   431                     break;
   427             break;
   432 
   428 
   433                 case HbDateTimeParser::YearSection:
   429         case HbDateTimeParser::YearSection:
   434                     mIsTwoDigitYearFormat = false;
   430             mIsTwoDigitYearFormat = false;
   435                     mYearFormat = QString(mParser.mSectionNodes[i].count,'y');
   431             mYearFormat = QString(mParser.mSectionNodes[i].count,'y');
   436                     break;
   432             break;
   437 
   433 
   438                 case HbDateTimeParser::YearSection2Digits:
   434         case HbDateTimeParser::YearSection2Digits:
   439                     mIsTwoDigitYearFormat = true;
   435             mIsTwoDigitYearFormat = true;
   440                     mYearFormat = QString(mParser.mSectionNodes[i].count,'y');
   436             mYearFormat = QString(mParser.mSectionNodes[i].count,'y');
   441                     break;
   437             break;
   442 
   438 
   443                 case HbDateTimeParser::SecondSection:
   439         case HbDateTimeParser::SecondSection:
   444                     mSecondFormat = QString(mParser.mSectionNodes[i].count,'s');
   440             mSecondFormat = QString(mParser.mSectionNodes[i].count,'s');
   445                     break;
   441             break;
   446 
   442 
   447                 case HbDateTimeParser::MinuteSection:
   443         case HbDateTimeParser::MinuteSection:
   448                     mMinuteFormat = QString(mParser.mSectionNodes[i].count,'m');
   444             mMinuteFormat = QString(mParser.mSectionNodes[i].count,'m');
   449                     break;
   445             break;
   450 
   446 
   451                 case HbDateTimeParser::Hour12Section:
   447         case HbDateTimeParser::Hour12Section:
   452                     mIs24HourFormat = false;
   448             mIs24HourFormat = false;
   453                     mHourFormat = QString(mParser.mSectionNodes[i].count,'h');
   449             mHourFormat = QString(mParser.mSectionNodes[i].count,'h');
   454                     break;
   450             break;
   455 
   451 
   456                 case HbDateTimeParser::Hour24Section:
   452         case HbDateTimeParser::Hour24Section:
   457                     mIs24HourFormat = true;
   453             mIs24HourFormat = true;
   458                     mHourFormat = QString(mParser.mSectionNodes[i].count,'h');
   454             mHourFormat = QString(mParser.mSectionNodes[i].count,'h');
   459                     break;
   455             break;
   460 
   456 
   461                 default:
   457         default:
   462                     break;
   458             break;
   463                     /*case HbDateTimeParser::DayOfWeekSection: not supported */
   459             /*case HbDateTimeParser::DayOfWeekSection: not supported */
   464             }
   460         }
   465         }
   461     }
   466 }
   462 }
   467 
   463 
   468 /*
   464 /*
   469    this is called whenever the setDisplayFormat changes.
   465    this is called whenever the setDisplayFormat changes.
   470    function deletes all tumbleviews which currently exist and
   466    function deletes all tumbleviews which currently exist and
   473 void HbDateTimePickerPrivate::rearrangeTumbleViews()
   469 void HbDateTimePickerPrivate::rearrangeTumbleViews()
   474 {                  
   470 {                  
   475     Q_Q(HbDateTimePicker);
   471     Q_Q(HbDateTimePicker);
   476 
   472 
   477     if(!(mParser.mDisplaySections & (HbDateTimeParser::YearSection|
   473     if(!(mParser.mDisplaySections & (HbDateTimeParser::YearSection|
   478                      HbDateTimeParser::YearSection2Digits))) {
   474                                      HbDateTimeParser::YearSection2Digits))) {
   479       deleteAndNull(mYearPicker);
   475         deleteAndNull(mYearPicker);
   480       mYearModel = 0;
   476         mYearModel = 0;
   481     }
   477     }
   482     if(!(mParser.mDisplaySections & HbDateTimeParser::MonthSection)) {
   478     if(!(mParser.mDisplaySections & HbDateTimeParser::MonthSection)) {
   483       deleteAndNull(mMonthPicker);
   479         deleteAndNull(mMonthPicker);
   484       mMonthModel = 0;
   480         mMonthModel = 0;
   485     }
   481     }
   486     if(!(mParser.mDisplaySections & HbDateTimeParser::DaySection)) {
   482     if(!(mParser.mDisplaySections & HbDateTimeParser::DaySection)) {
   487       deleteAndNull(mDayPicker);
   483         deleteAndNull(mDayPicker);
   488       mDayModel = 0;
   484         mDayModel = 0;
   489     }
   485     }
   490     if(!(mParser.mDisplaySections & (HbDateTimeParser::Hour12Section|
   486     if(!(mParser.mDisplaySections & (HbDateTimeParser::Hour12Section|
   491                      HbDateTimeParser::Hour24Section))) {
   487                                      HbDateTimeParser::Hour24Section))) {
   492       deleteAndNull(mHourPicker);
   488         deleteAndNull(mHourPicker);
   493       mHourModel = 0;
   489         mHourModel = 0;
   494     }
   490     }
   495     if(!(mParser.mDisplaySections & HbDateTimeParser::MinuteSection)) {
   491     if(!(mParser.mDisplaySections & HbDateTimeParser::MinuteSection)) {
   496       deleteAndNull(mMinutePicker);
   492         deleteAndNull(mMinutePicker);
   497       mMinuteModel = 0;
   493         mMinuteModel = 0;
   498     }
   494     }
   499     if(!(mParser.mDisplaySections & HbDateTimeParser::SecondSection)) {
   495     if(!(mParser.mDisplaySections & HbDateTimeParser::SecondSection)) {
   500       deleteAndNull(mSecondPicker);
   496         deleteAndNull(mSecondPicker);
   501       mSecondModel = 0;
   497         mSecondModel = 0;
   502     }
   498     }
   503     if(!(mParser.mDisplaySections & HbDateTimeParser::AmPmSection)) {
   499     if(!(mParser.mDisplaySections & HbDateTimeParser::AmPmSection)) {
   504       deleteAndNull(mAmPmPicker);
   500         deleteAndNull(mAmPmPicker);
   505       mAmPmModel = 0;
   501         mAmPmModel = 0;
   506     }
   502     }
   507 
   503 
   508     mYearOffset = -1;
   504     mYearOffset = -1;
   509     mMonthOffset = -1;
   505     mMonthOffset = -1;
   510     mDayOffset = -1;
   506     mDayOffset = -1;
   511     mHourOffset = -1;
   507     mHourOffset = -1;
   512     mMinuteOffset = -1;
   508     mMinuteOffset = -1;
   513     mSecondOffset = -1;
   509     mSecondOffset = -1;
   514 
   510 
   515     while(mLayout->count()) {
   511     while(mLayout->count()) {
   516       mLayout->removeAt(0);
   512         mLayout->removeAt(0);
   517     }
   513     }
   518 
   514 
   519     QPointer<VIEWER> lastAdded;
   515     QPointer<VIEWER> lastAdded;
   520 
   516 
   521     for(int i=0;i<mParser.mSectionNodes.count();i++) {
   517     for(int i=0;i<mParser.mSectionNodes.count();i++) {
   522         switch(mParser.mSectionNodes[i].type) {
   518         switch(mParser.mSectionNodes[i].type) {
   523             case HbDateTimeParser::AmPmSection:
   519         case HbDateTimeParser::AmPmSection:
   524                 if(!mAmPmPicker) {
   520             if(!mAmPmPicker) {
   525                     mAmPmPicker = new VIEWER(q);
   521                 mAmPmPicker = new VIEWER(q);
   526                     mAmPmModel = static_cast<QStringListModel*>(mAmPmPicker->model());
   522                 mAmPmModel = static_cast<QStringListModel*>(mAmPmPicker->model());
   527                 }
   523             }
   528                 mLayout->addItem(mAmPmPicker);
   524             mLayout->addItem(mAmPmPicker);
   529                 lastAdded = mAmPmPicker;
   525             lastAdded = mAmPmPicker;
   530                 break;
   526             break;
   531 
   527 
   532             case HbDateTimeParser::DaySection:
   528             case HbDateTimeParser::DaySection:
   533             case HbDateTimeParser::DayOfWeekSection:
   529             case HbDateTimeParser::DayOfWeekSection:
   534                 if(!mDayPicker) {
   530             if(!mDayPicker) {
   535                     mDayPicker = new VIEWER(q);
   531                 mDayPicker = new VIEWER(q);
   536                     mDayModel = static_cast<QStringListModel*>(mDayPicker->model());
   532                 mDayModel = static_cast<QStringListModel*>(mDayPicker->model());
   537                     mDayPicker->setLoopingEnabled(true);
   533                 mDayPicker->setLoopingEnabled(true);
   538                 }
   534             }
   539                 mLayout->addItem(mDayPicker);
   535             mLayout->addItem(mDayPicker);
   540                 lastAdded = mDayPicker;
   536             lastAdded = mDayPicker;
   541                 break;
   537             break;
   542 
   538 
   543             case HbDateTimeParser::MonthSection:
   539             case HbDateTimeParser::MonthSection:
   544                 if(!mMonthPicker) {
   540             if(!mMonthPicker) {
   545                     mMonthPicker = new VIEWER(q);
   541                 mMonthPicker = new VIEWER(q);
   546                     mMonthModel = static_cast<QStringListModel*>(mMonthPicker->model());
   542                 mMonthModel = static_cast<QStringListModel*>(mMonthPicker->model());
   547                     mMonthPicker->setLoopingEnabled(true);
   543                 mMonthPicker->setLoopingEnabled(true);
   548                 }
   544             }
   549                 mLayout->addItem(mMonthPicker);
   545             mLayout->addItem(mMonthPicker);
   550                 lastAdded = mMonthPicker;
   546             lastAdded = mMonthPicker;
   551                 break;
   547             break;
   552 
   548 
   553             case HbDateTimeParser::YearSection:
   549             case HbDateTimeParser::YearSection:
   554             case HbDateTimeParser::YearSection2Digits:
   550             case HbDateTimeParser::YearSection2Digits:
   555                 if(!mYearPicker) {
   551             if(!mYearPicker) {
   556                     mYearPicker = new VIEWER(q);
   552                 mYearPicker = new VIEWER(q);
   557                     mYearModel = static_cast<QStringListModel*>(mYearPicker->model());
   553                 mYearModel = static_cast<QStringListModel*>(mYearPicker->model());
   558                     mYearPicker->setLoopingEnabled(true);
   554                 mYearPicker->setLoopingEnabled(true);
   559                 }
   555             }
   560                 mLayout->addItem(mYearPicker);
   556             mLayout->addItem(mYearPicker);
   561                 lastAdded = mYearPicker;
   557             lastAdded = mYearPicker;
   562                 break;
   558             break;
   563 
   559 
   564             case HbDateTimeParser::SecondSection:
   560             case HbDateTimeParser::SecondSection:
   565                 if(!mSecondPicker) {
   561             if(!mSecondPicker) {
   566                     mSecondPicker = new VIEWER(q);
   562                 mSecondPicker = new VIEWER(q);
   567                     mSecondModel = static_cast<QStringListModel*>(mSecondPicker->model());
   563                 mSecondModel = static_cast<QStringListModel*>(mSecondPicker->model());
   568                     mSecondPicker->setLoopingEnabled(true);
   564                 mSecondPicker->setLoopingEnabled(true);
   569                 }
   565             }
   570                 mLayout->addItem(mSecondPicker);
   566             mLayout->addItem(mSecondPicker);
   571                 lastAdded = mSecondPicker;
   567             lastAdded = mSecondPicker;
   572                 break;
   568             break;
   573 
   569 
   574             case HbDateTimeParser::MinuteSection:
   570             case HbDateTimeParser::MinuteSection:
   575                 if(!mMinutePicker) {
   571             if(!mMinutePicker) {
   576                     mMinutePicker = new VIEWER(q);
   572                 mMinutePicker = new VIEWER(q);
   577                     mMinuteModel = static_cast<QStringListModel*>(mMinutePicker->model());
   573                 mMinuteModel = static_cast<QStringListModel*>(mMinutePicker->model());
   578                     mMinutePicker->setLoopingEnabled(true);
   574                 mMinutePicker->setLoopingEnabled(true);
   579                 }
   575             }
   580                 mLayout->addItem(mMinutePicker);
   576             mLayout->addItem(mMinutePicker);
   581                 lastAdded = mMinutePicker;
   577             lastAdded = mMinutePicker;
   582                 break;
   578             break;
   583 
   579 
   584             case HbDateTimeParser::Hour12Section:
   580             case HbDateTimeParser::Hour12Section:
   585             case HbDateTimeParser::Hour24Section:
   581             case HbDateTimeParser::Hour24Section:
   586                 if(!mHourPicker) {
   582             if(!mHourPicker) {
   587                     mHourPicker = new VIEWER(q);
   583                 mHourPicker = new VIEWER(q);
   588                     mHourModel = static_cast<QStringListModel*>(mHourPicker->model());
   584                 mHourModel = static_cast<QStringListModel*>(mHourPicker->model());
   589                     mHourPicker->setLoopingEnabled(true);
   585                 mHourPicker->setLoopingEnabled(true);
   590                 }
   586             }
   591                 mLayout->addItem(mHourPicker);
   587             mLayout->addItem(mHourPicker);
   592                 lastAdded = mHourPicker;
   588             lastAdded = mHourPicker;
   593                 break;
   589             break;
   594 
   590 
   595             default:
   591             default:
   596                 break;
   592             break;
   597         }
   593         }
   598         
   594         
   599         if(lastAdded){
   595         if(lastAdded){
   600             lastAdded->primitive("highlight")->hide();
   596             lastAdded->primitive("highlight")->hide();
   601             lastAdded->primitive("separator")->show();
   597             lastAdded->primitive("separator")->show();
   771 
   767 
   772 }
   768 }
   773 
   769 
   774 
   770 
   775 void HbDateTimePickerPrivate::setDateTimeRange(const QDateTime &startdt,
   771 void HbDateTimePickerPrivate::setDateTimeRange(const QDateTime &startdt,
   776         const QDateTime &enddt)
   772                                                const QDateTime &enddt)
   777 {
   773 {
   778     Q_Q(HbDateTimePicker);
   774     Q_Q(HbDateTimePicker);
   779     QDateTime start(startdt);
   775     QDateTime start(startdt);
   780     QDateTime end(enddt);
   776     QDateTime end(enddt);
   781     if(start.isValid() && end.isValid()) {
   777     if(start.isValid() && end.isValid()) {
   890             }
   886             }
   891             else{
   887             else{
   892                 index = newDateTime.time().minute()-mMinuteOffset;
   888                 index = newDateTime.time().minute()-mMinuteOffset;
   893             }
   889             }
   894 #ifdef HBDATETIMEPICKER_DEBUG
   890 #ifdef HBDATETIMEPICKER_DEBUG
   895     qDebug() << "setMinuteRange:selecting= " << index;
   891             qDebug() << "setMinuteRange:selecting= " << index;
   896 #endif
   892 #endif
   897             mMinutePicker->setSelected(index);
   893             mMinutePicker->setSelected(index);
   898         }
   894         }
   899 
   895 
   900         if(mSecondPicker) {
   896         if(mSecondPicker) {
   950 #endif
   946 #endif
   951 
   947 
   952 
   948 
   953 
   949 
   954     resizeModel(mYearModel, mYearOffset, 
   950     resizeModel(mYearModel, mYearOffset, 
   955         mYearOffset+mYearModel->rowCount()-1, start, 
   951                 mYearOffset+mYearModel->rowCount()-1, start,
   956         end, &HbDateTimePickerPrivate::localeYear);
   952                 end, &HbDateTimePickerPrivate::localeYear);
   957 
   953 
   958     mYearOffset = start;
   954     mYearOffset = start;
   959 
   955 
   960     mYearPicker->setSelected(newIndex);
   956     mYearPicker->setSelected(newIndex);
   961 }
   957 }
   977     }
   973     }
   978     if(newIndex > (end-start)) {
   974     if(newIndex > (end-start)) {
   979         newIndex = end-start;
   975         newIndex = end-start;
   980     }
   976     }
   981     resizeModel(mMonthModel,
   977     resizeModel(mMonthModel,
   982             mMonthOffset,mMonthOffset+mMonthModel->rowCount()-1,
   978                 mMonthOffset,mMonthOffset+mMonthModel->rowCount()-1,
   983             start,end,
   979                 start,end,
   984             &HbDateTimePickerPrivate::localeMonth);
   980                 &HbDateTimePickerPrivate::localeMonth);
   985     mMonthOffset = start;
   981     mMonthOffset = start;
   986 
   982 
   987     mMonthPicker->setSelected(newIndex);
   983     mMonthPicker->setSelected(newIndex);
   988 
   984 
   989     //check if current month is valid
   985     //check if current month is valid
  1014     if(newIndex > (end-start)) {
  1010     if(newIndex > (end-start)) {
  1015         newIndex = end-start;
  1011         newIndex = end-start;
  1016     }
  1012     }
  1017 
  1013 
  1018     resizeModel(mDayModel,
  1014     resizeModel(mDayModel,
  1019             mDayOffset,mDayOffset+mDayModel->rowCount()-1,
  1015                 mDayOffset,mDayOffset+mDayModel->rowCount()-1,
  1020             start,end,
  1016                 start,end,
  1021             &HbDateTimePickerPrivate::localeDay);
  1017                 &HbDateTimePickerPrivate::localeDay);
  1022     mDayOffset = start;
  1018     mDayOffset = start;
  1023 
  1019 
  1024     mDayPicker->setSelected(newIndex);
  1020     mDayPicker->setSelected(newIndex);
  1025 
  1021 
  1026 
  1022 
  1052     if(newIndex > (end-start)) {
  1048     if(newIndex > (end-start)) {
  1053         newIndex = end-start;
  1049         newIndex = end-start;
  1054     }
  1050     }
  1055 
  1051 
  1056     resizeModel(mHourModel,
  1052     resizeModel(mHourModel,
  1057             mHourOffset,mHourOffset+mHourModel->rowCount()-1,
  1053                 mHourOffset,mHourOffset+mHourModel->rowCount()-1,
  1058             start,end,
  1054                 start,end,
  1059             &HbDateTimePickerPrivate::localeHour);
  1055                 &HbDateTimePickerPrivate::localeHour);
  1060     mHourOffset = start;
  1056     mHourOffset = start;
  1061 
  1057 
  1062     mHourPicker->setSelected(newIndex);
  1058     mHourPicker->setSelected(newIndex);
  1063 
  1059 
  1064     //check if hour is valid
  1060     //check if hour is valid
  1089     if(newIndex > (end-start)) {
  1085     if(newIndex > (end-start)) {
  1090         newIndex = end-start;
  1086         newIndex = end-start;
  1091     }
  1087     }
  1092 
  1088 
  1093     resizeModel(mMinuteModel, 
  1089     resizeModel(mMinuteModel, 
  1094         mMinuteOffset,mMinuteModel->index(mMinuteModel->rowCount() - 1).data().toInt(),
  1090                 mMinuteOffset,mMinuteModel->index(mMinuteModel->rowCount() - 1).data().toInt(),
  1095         start,end,
  1091                 start,end,
  1096         &HbDateTimePickerPrivate::localeMinute, 
  1092                 &HbDateTimePickerPrivate::localeMinute,
  1097         mIntervals[QDateTimeEdit::MinuteSection]);
  1093                 mIntervals[QDateTimeEdit::MinuteSection]);
  1098     mMinuteOffset = start;
  1094     mMinuteOffset = start;
  1099 
  1095 
  1100     //Select the nearest value when the range is set.
  1096     //Select the nearest value when the range is set.
  1101     int index = 0;
  1097     int index = 0;
  1102 
  1098 
  1103     for(int i=start;i<newIndex;i+=mIntervals[QDateTimeEdit::MinuteSection]) {
  1099     for(int i=start;i<newIndex;i+=mIntervals[QDateTimeEdit::MinuteSection]) {
  1104       index++;
  1100         index++;
  1105     }
  1101     }
  1106 #ifdef HBDATETIMEPICKER_DEBUG
  1102 #ifdef HBDATETIMEPICKER_DEBUG
  1107     qDebug() << "initMinute:selecting= " << index;
  1103     qDebug() << "initMinute:selecting= " << index;
  1108 #endif
  1104 #endif
  1109     mMinutePicker->setSelected(index);
  1105     mMinutePicker->setSelected(index);
  1137     if(newIndex > (end-start)) {
  1133     if(newIndex > (end-start)) {
  1138         newIndex = end-start;
  1134         newIndex = end-start;
  1139     }
  1135     }
  1140 
  1136 
  1141     resizeModel(mSecondModel,
  1137     resizeModel(mSecondModel,
  1142             mSecondOffset,mSecondOffset+mSecondModel->rowCount()-1,
  1138                 mSecondOffset,mSecondOffset+mSecondModel->rowCount()-1,
  1143             start,end,
  1139                 start,end,
  1144             &HbDateTimePickerPrivate::localeSecond);
  1140                 &HbDateTimePickerPrivate::localeSecond);
  1145     mSecondOffset = start;
  1141     mSecondOffset = start;
  1146 
  1142 
  1147     mSecondPicker->setSelected(newIndex);
  1143     mSecondPicker->setSelected(newIndex);
  1148 
  1144 
  1149     //check if second is valid
  1145     //check if second is valid
  1228    data need the appropriate locale and format converted data. which is passed
  1224    data need the appropriate locale and format converted data. which is passed
  1229    as a function pointer instead of creating seven different QStringListModel derived
  1225    as a function pointer instead of creating seven different QStringListModel derived
  1230    model classes with one interface/virtual function specialization.
  1226    model classes with one interface/virtual function specialization.
  1231 */
  1227 */
  1232 void HbDateTimePickerPrivate::resizeModel(QStringListModel *model,
  1228 void HbDateTimePickerPrivate::resizeModel(QStringListModel *model,
  1233             int oldStart, int oldEnd,
  1229                                           int oldStart, int oldEnd,
  1234             int newStart, int newEnd,
  1230                                           int newStart, int newEnd,
  1235             QString (HbDateTimePickerPrivate::*localeFunc)(int), int interval)
  1231                                           QString (HbDateTimePickerPrivate::*localeFunc)(int), int interval)
  1236 {
  1232 {
  1237     class ConnectionRemover {
  1233     class ConnectionRemover {
  1238     public:
  1234     public:
  1239         ConnectionRemover(HbDateTimePickerPrivate *priv){
  1235         ConnectionRemover(HbDateTimePickerPrivate *priv){
  1240             this->priv = priv;
  1236             this->priv = priv;
  1245         }
  1241         }
  1246         HbDateTimePickerPrivate *priv;
  1242         HbDateTimePickerPrivate *priv;
  1247     }Obj(this);
  1243     }Obj(this);
  1248 
  1244 
  1249 #ifdef HBDATETIMEPICKER_DEBUG
  1245 #ifdef HBDATETIMEPICKER_DEBUG
  1250             qDebug() << "resizeModel: oldStart=" << oldStart
  1246     qDebug() << "resizeModel: oldStart=" << oldStart
  1251                      << " oldEnd=" << oldEnd << " newStart=" 
  1247             << " oldEnd=" << oldEnd << " newStart="
  1252                      << newStart << " newEnd=" << newEnd
  1248             << newStart << " newEnd=" << newEnd
  1253                      << " interval=" << interval;
  1249             << " interval=" << interval;
  1254 #endif
  1250 #endif
  1255         bool b1=false,b2=false;
  1251     bool b1=false,b2=false;
  1256             int oldinterval=model->rowCount()>1 ? (model->index(1,0).data().toInt(&b1)-model->index(0,0).data().toInt(&b2)):0; 
  1252     int oldinterval=model->rowCount()>1 ? (model->index(1,0).data().toInt(&b1)-model->index(0,0).data().toInt(&b2)):0;
  1257 #ifdef HBDATETIMEPICKER_DEBUG
  1253 #ifdef HBDATETIMEPICKER_DEBUG
  1258             qDebug() << "resizeModel:sameoldInterval=" << oldinterval;
  1254     qDebug() << "resizeModel:sameoldInterval=" << oldinterval;
  1259 #endif
  1255 #endif
  1260             if(b1 && b2 && (oldinterval == interval) && (newStart == oldStart)) {
  1256     if(b1 && b2 && (oldinterval == interval) && (newStart == oldStart)) {
  1261                 if(newEnd>oldEnd) {
       
  1262                     int rowCount=model->rowCount();
       
  1263 #ifdef HBDATETIMEPICKER_DEBUG
       
  1264                     qDebug() << "resizeModel:sameinserting(" << rowCount << "," <<(newEnd-oldEnd)/interval << ")";
       
  1265 #endif
       
  1266                     model->insertRows(rowCount,(newEnd-oldEnd)/interval);
       
  1267                     for(int i=0;i<((newEnd-oldEnd)/interval);++i) {
       
  1268                         QModelIndex index=model->index(i+rowCount,0);
       
  1269                         if(index.isValid()) {
       
  1270                             model->setData(index,(this->*localeFunc)(((i+1)*interval)+oldEnd));
       
  1271 #ifdef HBDATETIMEPICKER_DEBUG
       
  1272                             qDebug() << "resizeModel:samesetData(" << ((i+1)*interval)+oldEnd << "," << (this->*localeFunc)((i+1)*interval+oldEnd) << ")";
       
  1273 #endif
       
  1274                         }
       
  1275                     }
       
  1276                 }
       
  1277                 if(oldEnd>newEnd) {
       
  1278                     //if the start offset is preset more items can fit at end
       
  1279                     int stay=((newEnd-newStart)/interval)+1;
       
  1280                     int count=model->rowCount()-stay;
       
  1281 #ifdef HBDATETIMEPICKER_DEBUG
       
  1282                     qDebug() << "resizeModel:removing(" <<model->rowCount()-count << "," << count << ")"
       
  1283                              << " data=" << model->index((model->rowCount()-count),0).data().toString();
       
  1284 #endif
       
  1285                     model->removeRows((model->rowCount()-count),count);
       
  1286                 }
       
  1287                 return;//optimizing inserts when interval is set
       
  1288             } else {
       
  1289             if(b1 && b2) {      
       
  1290             model->removeRows(0,model->rowCount());
       
  1291                     oldStart = oldEnd = 0;
       
  1292             }
       
  1293             }
       
  1294 
       
  1295         if((model->rowCount() == 0) && (newEnd-newStart>=0)) {
       
  1296 #ifdef HBDATETIMEPICKER_DEBUG
       
  1297             qDebug() << "resizeModel:default addition inserting(0," << (newEnd-newStart+1)/interval << ")";
       
  1298 #endif
       
  1299 
       
  1300             model->insertRows(0,((newEnd-newStart)/interval)+1);
       
  1301             for(int i=0;i<=((newEnd-newStart)/interval);++i) {
       
  1302                 QString text=(this->*localeFunc)((i*interval)+newStart);
       
  1303 #ifdef HB_TEXT_MEASUREMENT_UTILITY
       
  1304                 if ( localeFunc == &HbDateTimePickerPrivate::localeMonth &&
       
  1305                         HbFeatureManager::instance()->featureStatus( HbFeatureManager::TextMeasurement ) ) {
       
  1306                     text.append(QChar(LOC_TEST_START));
       
  1307                     text.append("qtl_datetimepicker_popup_month_sec");
       
  1308                     text.append(QChar(LOC_TEST_END));
       
  1309                 }
       
  1310 #endif
       
  1311                 QModelIndex index=model->index(i,0);
       
  1312                 if(index.isValid()) {
       
  1313                     model->setData(index,text);
       
  1314 #ifdef HBDATETIMEPICKER_DEBUG
       
  1315                     qDebug() << "resizeModel:setData(" << i << "," << text << ")";
       
  1316 #endif
       
  1317                 }
       
  1318             }
       
  1319             return;
       
  1320         }
       
  1321 
       
  1322         if(newStart<oldStart) {
       
  1323 #ifdef HBDATETIMEPICKER_DEBUG
       
  1324             qDebug() << "resizeModel:inserting(0," << (oldStart-newStart)/interval << ")";
       
  1325 #endif
       
  1326             model->insertRows(0,(oldStart-newStart)/interval);
       
  1327             for(int i=0;i<((oldStart-newStart)/interval);++i) {
       
  1328                 QModelIndex index=model->index(i,0);
       
  1329                 if(index.isValid()) {
       
  1330                     model->setData(index,(this->*localeFunc)((i*interval)+newStart));
       
  1331 #ifdef HBDATETIMEPICKER_DEBUG
       
  1332                     qDebug() << "resizeModel:setData(" << i << "," << (this->*localeFunc)((i*interval)+newStart) << ")";
       
  1333 #endif
       
  1334                 }
       
  1335             }
       
  1336         }
       
  1337 
       
  1338         if(newEnd>oldEnd) {
  1257         if(newEnd>oldEnd) {
  1339             int rowCount=model->rowCount();
  1258             int rowCount=model->rowCount();
  1340 #ifdef HBDATETIMEPICKER_DEBUG
  1259 #ifdef HBDATETIMEPICKER_DEBUG
  1341             qDebug() << "resizeModel:inserting(" << rowCount << "," <<(newEnd-oldEnd)/interval << ")";
  1260             qDebug() << "resizeModel:sameinserting(" << rowCount << "," <<(newEnd-oldEnd)/interval << ")";
  1342 #endif
  1261 #endif
  1343             model->insertRows(rowCount,(newEnd-oldEnd)/interval);
  1262             model->insertRows(rowCount,(newEnd-oldEnd)/interval);
  1344             for(int i=0;i<((newEnd-oldEnd)/interval);++i) {
  1263             for(int i=0;i<((newEnd-oldEnd)/interval);++i) {
  1345                 QModelIndex index=model->index(i+rowCount,0);
  1264                 QModelIndex index=model->index(i+rowCount,0);
  1346                 if(index.isValid()) {
  1265                 if(index.isValid()) {
  1347                     model->setData(index,(this->*localeFunc)(((i+1)*interval)+oldEnd));
  1266                     model->setData(index,(this->*localeFunc)(((i+1)*interval)+oldEnd));
  1348 #ifdef HBDATETIMEPICKER_DEBUG
  1267 #ifdef HBDATETIMEPICKER_DEBUG
  1349                     qDebug() << "resizeModel:setData(" << i << "," << (this->*localeFunc)((i+1)*interval+oldEnd) << ")";
  1268                     qDebug() << "resizeModel:samesetData(" << ((i+1)*interval)+oldEnd << "," << (this->*localeFunc)((i+1)*interval+oldEnd) << ")";
  1350 #endif
  1269 #endif
  1351                 }
  1270                 }
  1352             }
  1271             }
  1353         }
  1272         }
  1354         if(newStart>oldStart) {
       
  1355 #ifdef HBDATETIMEPICKER_DEBUG
       
  1356             qDebug() << "resizeModel:removing(0," << (newStart-oldStart)/interval << ")"
       
  1357                              << " data=" << model->index((newStart-oldStart)/interval,0).data().toString();
       
  1358 #endif
       
  1359             model->removeRows(0,(newStart-oldStart)/interval);
       
  1360         }
       
  1361 
       
  1362         if(oldEnd>newEnd) {
  1273         if(oldEnd>newEnd) {
  1363 //#ifdef HBDATETIMEPICKER_DEBUG
  1274             //if the start offset is preset more items can fit at end
  1364 //            qDebug() << "resizeModel:removing(" <<model->rowCount()-((oldEnd-newEnd)/interval)<<"," << (oldEnd-newEnd)/interval << ")";
  1275             int stay=((newEnd-newStart)/interval)+1;
  1365 //#endif
  1276             int count=model->rowCount()-stay;
  1366 //            model->removeRows((model->rowCount()-((oldEnd-newEnd)/interval)),(oldEnd-newEnd)/interval);
  1277 #ifdef HBDATETIMEPICKER_DEBUG
  1367                     //if the start offset is preset more items can fit at end
  1278             qDebug() << "resizeModel:removing(" <<model->rowCount()-count << "," << count << ")"
  1368                     int stay=((newEnd-newStart)/interval)+1;
  1279                     << " data=" << model->index((model->rowCount()-count),0).data().toString();
  1369                     int count=model->rowCount()-stay;
  1280 #endif
  1370 #ifdef HBDATETIMEPICKER_DEBUG
  1281             model->removeRows((model->rowCount()-count),count);
  1371                     qDebug() << "resizeModel:removing(" <<model->rowCount()-count << "," << count << ")"
  1282         }
  1372                              << " data=" << model->index((model->rowCount()-count),0).data().toString();
  1283         return;//optimizing inserts when interval is set
  1373 #endif
  1284     } else {
  1374                     model->removeRows((model->rowCount()-count),count);
  1285         if(b1 && b2) {
  1375         }
  1286             model->removeRows(0,model->rowCount());
       
  1287             oldStart = oldEnd = 0;
       
  1288         }
       
  1289     }
       
  1290 
       
  1291     if((model->rowCount() == 0) && (newEnd-newStart>=0)) {
       
  1292 #ifdef HBDATETIMEPICKER_DEBUG
       
  1293         qDebug() << "resizeModel:default addition inserting(0," << (newEnd-newStart+1)/interval << ")";
       
  1294 #endif
       
  1295 
       
  1296         model->insertRows(0,((newEnd-newStart)/interval)+1);
       
  1297         for(int i=0;i<=((newEnd-newStart)/interval);++i) {
       
  1298             QString text=(this->*localeFunc)((i*interval)+newStart);
       
  1299 #ifdef HB_TEXT_MEASUREMENT_UTILITY
       
  1300             if ( localeFunc == &HbDateTimePickerPrivate::localeMonth &&
       
  1301                  HbFeatureManager::instance()->featureStatus( HbFeatureManager::TextMeasurement ) ) {
       
  1302                 text.append(QChar(LOC_TEST_START));
       
  1303                 text.append("qtl_datetimepicker_popup_month_sec");
       
  1304                 text.append(QChar(LOC_TEST_END));
       
  1305             }
       
  1306 #endif
       
  1307             QModelIndex index=model->index(i,0);
       
  1308             if(index.isValid()) {
       
  1309                 model->setData(index,text);
       
  1310 #ifdef HBDATETIMEPICKER_DEBUG
       
  1311                 qDebug() << "resizeModel:setData(" << i << "," << text << ")";
       
  1312 #endif
       
  1313             }
       
  1314         }
       
  1315         return;
       
  1316     }
       
  1317 
       
  1318     if(newStart<oldStart) {
       
  1319 #ifdef HBDATETIMEPICKER_DEBUG
       
  1320         qDebug() << "resizeModel:inserting(0," << (oldStart-newStart)/interval << ")";
       
  1321 #endif
       
  1322         model->insertRows(0,(oldStart-newStart)/interval);
       
  1323         for(int i=0;i<((oldStart-newStart)/interval);++i) {
       
  1324             QModelIndex index=model->index(i,0);
       
  1325             if(index.isValid()) {
       
  1326                 model->setData(index,(this->*localeFunc)((i*interval)+newStart));
       
  1327 #ifdef HBDATETIMEPICKER_DEBUG
       
  1328                 qDebug() << "resizeModel:setData(" << i << "," << (this->*localeFunc)((i*interval)+newStart) << ")";
       
  1329 #endif
       
  1330             }
       
  1331         }
       
  1332     }
       
  1333 
       
  1334     if(newEnd>oldEnd) {
       
  1335         int rowCount=model->rowCount();
       
  1336 #ifdef HBDATETIMEPICKER_DEBUG
       
  1337         qDebug() << "resizeModel:inserting(" << rowCount << "," <<(newEnd-oldEnd)/interval << ")";
       
  1338 #endif
       
  1339         model->insertRows(rowCount,(newEnd-oldEnd)/interval);
       
  1340         for(int i=0;i<((newEnd-oldEnd)/interval);++i) {
       
  1341             QModelIndex index=model->index(i+rowCount,0);
       
  1342             if(index.isValid()) {
       
  1343                 model->setData(index,(this->*localeFunc)(((i+1)*interval)+oldEnd));
       
  1344 #ifdef HBDATETIMEPICKER_DEBUG
       
  1345                 qDebug() << "resizeModel:setData(" << i << "," << (this->*localeFunc)((i+1)*interval+oldEnd) << ")";
       
  1346 #endif
       
  1347             }
       
  1348         }
       
  1349     }
       
  1350     if(newStart>oldStart) {
       
  1351 #ifdef HBDATETIMEPICKER_DEBUG
       
  1352         qDebug() << "resizeModel:removing(0," << (newStart-oldStart)/interval << ")"
       
  1353                 << " data=" << model->index((newStart-oldStart)/interval,0).data().toString();
       
  1354 #endif
       
  1355         model->removeRows(0,(newStart-oldStart)/interval);
       
  1356     }
       
  1357 
       
  1358     if(oldEnd>newEnd) {
       
  1359         //#ifdef HBDATETIMEPICKER_DEBUG
       
  1360         //            qDebug() << "resizeModel:removing(" <<model->rowCount()-((oldEnd-newEnd)/interval)<<"," << (oldEnd-newEnd)/interval << ")";
       
  1361         //#endif
       
  1362         //            model->removeRows((model->rowCount()-((oldEnd-newEnd)/interval)),(oldEnd-newEnd)/interval);
       
  1363         //if the start offset is preset more items can fit at end
       
  1364         int stay=((newEnd-newStart)/interval)+1;
       
  1365         int count=model->rowCount()-stay;
       
  1366 #ifdef HBDATETIMEPICKER_DEBUG
       
  1367         qDebug() << "resizeModel:removing(" <<model->rowCount()-count << "," << count << ")"
       
  1368                 << " data=" << model->index((model->rowCount()-count),0).data().toString();
       
  1369 #endif
       
  1370         model->removeRows((model->rowCount()-count),count);
       
  1371     }
  1376 }  
  1372 }  
  1377 
  1373 
  1378 
  1374 
  1379 void HbDateTimePickerPrivate::createPrimitives()
  1375 void HbDateTimePickerPrivate::createPrimitives()
  1380 {
  1376 {    
  1381     Q_Q(HbDateTimePicker);
  1377     Q_Q(HbDateTimePicker);
  1382     if(!mBackground) {
  1378     if (!mBackground) {
  1383         mBackground = HbStylePrivate::createPrimitive(HbStylePrivate::P_DateTimePicker_background,q);
  1379         mBackground = q->style()->createPrimitive(HbStyle::PT_FrameItem,"background",q);
  1384         HbStyle::setItemName(mBackground,"background");
       
  1385     }
  1380     }
  1386     if(!mFrame) {
  1381     if(!mFrame) {
  1387         mFrame = HbStylePrivate::createPrimitive(HbStylePrivate::P_DateTimePicker_frame,q);
  1382         mFrame = q->style()->createPrimitive(HbStyle::PT_FrameItem,"frame",q);
  1388         HbStyle::setItemName(mFrame,"frame");
  1383     }
  1389     }
  1384 
  1390 
  1385     if(!mHighlight) {
  1391     if(!mHighlight){
  1386         mHighlight = q->style()->createPrimitive(HbStyle::PT_FrameItem,"highlight",q);
  1392         mHighlight = HbStylePrivate::createPrimitive(HbStylePrivate::P_TumbleView_highlight,q);
       
  1393         HbStyle::setItemName(mHighlight,"highlight");
       
  1394     }
  1387     }
  1395 }
  1388 }
  1396 
  1389 
  1397 void HbDateTimePickerPrivate::_q_dayChanged(int index)
  1390 void HbDateTimePickerPrivate::_q_dayChanged(int index)
  1398 {
  1391 {
  1470             end = mDateTime.date().daysInMonth();
  1463             end = mDateTime.date().daysInMonth();
  1471         }
  1464         }
  1472 
  1465 
  1473         //set if dayrange changed
  1466         //set if dayrange changed
  1474         if((start != mDayOffset)
  1467         if((start != mDayOffset)
  1475                 ||(end !=mDayOffset+mDayModel->rowCount()-1)) {
  1468             ||(end !=mDayOffset+mDayModel->rowCount()-1)) {
  1476             setDayRange(start,end);
  1469             setDayRange(start,end);
  1477         }
  1470         }
  1478     }
  1471     }
  1479 
  1472 
  1480     emitDateChange();
  1473     emitDateChange();
  1527             end = 12;
  1520             end = 12;
  1528         }
  1521         }
  1529 
  1522 
  1530         //set if range changed
  1523         //set if range changed
  1531         if((start != mMonthOffset)
  1524         if((start != mMonthOffset)
  1532                 || (end != mMonthModel->rowCount()-1)) {
  1525             || (end != mMonthModel->rowCount()-1)) {
  1533             setMonthRange(start,end);
  1526             setMonthRange(start,end);
  1534         }
  1527         }
  1535 
  1528 
  1536     }
  1529     }
  1537     
  1530     
  1550             end = mDateTime.date().daysInMonth();
  1543             end = mDateTime.date().daysInMonth();
  1551         }
  1544         }
  1552 
  1545 
  1553         //set if dayrange changed
  1546         //set if dayrange changed
  1554         if((start != mDayOffset)
  1547         if((start != mDayOffset)
  1555                 ||(end !=mDayOffset+mDayModel->rowCount()-1)) {
  1548             ||(end !=mDayOffset+mDayModel->rowCount()-1)) {
  1556             setDayRange(start,end);
  1549             setDayRange(start,end);
  1557         }
  1550         }
  1558     }
  1551     }
  1559 
  1552 
  1560     emitDateChange();
  1553     emitDateChange();
  1598             end = 59;
  1591             end = 59;
  1599         }
  1592         }
  1600 
  1593 
  1601         //set if range changed
  1594         //set if range changed
  1602         if((start != mMinuteOffset)
  1595         if((start != mMinuteOffset)
  1603                 || (end != start+mMinuteModel->rowCount()-1)) {
  1596             || (end != start+mMinuteModel->rowCount()-1)) {
  1604             setMinuteRange(start,end);
  1597             setMinuteRange(start,end);
  1605         }
  1598         }
  1606 
  1599 
  1607     }
  1600     }
  1608     
  1601     
  1621             end = 59;
  1614             end = 59;
  1622         }
  1615         }
  1623 
  1616 
  1624         //set if seconds range changed
  1617         //set if seconds range changed
  1625         if((start != mSecondOffset)
  1618         if((start != mSecondOffset)
  1626                 ||(end !=mSecondOffset+mSecondModel->rowCount()-1)) {
  1619             ||(end !=mSecondOffset+mSecondModel->rowCount()-1)) {
  1627             setSecondRange(start,end);
  1620             setSecondRange(start,end);
  1628         }
  1621         }
  1629     }
  1622     }
  1630 
  1623 
  1631     //check if am or pm and scroll to respective time
  1624     //check if am or pm and scroll to respective time
  1681             end = 59;
  1674             end = 59;
  1682         }
  1675         }
  1683 
  1676 
  1684         //set if seconds range changed
  1677         //set if seconds range changed
  1685         if((start != mSecondOffset)
  1678         if((start != mSecondOffset)
  1686                 ||(end !=mSecondOffset+mSecondModel->rowCount()-1)) {
  1679             ||(end !=mSecondOffset+mSecondModel->rowCount()-1)) {
  1687             setSecondRange(start,end);
  1680             setSecondRange(start,end);
  1688         }
  1681         }
  1689     }
  1682     }
  1690 
  1683 
  1691     emitTimeChange();
  1684     emitTimeChange();
  1747                 mAmPmPicker->setSelected(0);//invalid so scrollback
  1740                 mAmPmPicker->setSelected(0);//invalid so scrollback
  1748             }
  1741             }
  1749         } 
  1742         } 
  1750     }
  1743     }
  1751 }
  1744 }
       
  1745 void HbDateTimePickerPrivate::processFormatEvent()
       
  1746 {
       
  1747     QDateTime tempDate=mDateTime;
       
  1748     processDisplaySections();
       
  1749     //recreate and rearrange depending on the format
       
  1750     rearrangeTumbleViews();
       
  1751     setDateTime(tempDate);
       
  1752     emitDateTimeChange();
       
  1753 }
       
  1754 void HbDateTimePickerPrivate::postFormatEvent()
       
  1755 {
       
  1756     Q_Q(HbDateTimePicker);
       
  1757     
       
  1758     QCoreApplication::removePostedEvents(q,QEvent::Type(mFormatEventType));
       
  1759 
       
  1760     QCoreApplication::postEvent(q,new QEvent(QEvent::Type(mFormatEventType)));
       
  1761 }