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(); |
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 { |