clock/clockui/clockviews/src/clockworldview.cpp
changeset 55 2c54b51f39c4
parent 45 b6db4fd4947b
child 57 bb2d3e476f29
equal deleted inserted replaced
51:0b38fc5b94c6 55:2c54b51f39c4
   129 	mCityListView = qobject_cast<HbListView *> (
   129 	mCityListView = qobject_cast<HbListView *> (
   130 			mDocLoader->findWidget(CLOCK_WORLD_CITYLIST));
   130 			mDocLoader->findWidget(CLOCK_WORLD_CITYLIST));
   131 	HbStyleLoader::registerFilePath(":/style/hblistviewitem.css");
   131 	HbStyleLoader::registerFilePath(":/style/hblistviewitem.css");
   132 	HbStyleLoader::registerFilePath(":/style/hblistviewitem.widgetml");
   132 	HbStyleLoader::registerFilePath(":/style/hblistviewitem.widgetml");
   133 	HbStyleLoader::registerFilePath(":/style/hblistviewitem_color.css");
   133 	HbStyleLoader::registerFilePath(":/style/hblistviewitem_color.css");
   134 	mCityListView->setLayoutName("citylist-portrait");
   134 	mCityListView->setLayoutName("citylist");
   135 	mCityListView->setModel(mCityListModel);
   135 	mCityListView->setModel(mCityListModel);
   136 	
   136 	
   137 	// Get the toolbar/menu actions.
   137 	// Get the toolbar/menu actions.
   138 	mAddCityAction = static_cast<HbAction *> (
   138 	mAddCityAction = static_cast<HbAction *> (
   139 			mDocLoader->findObject("addCityAction"));
   139 			mDocLoader->findObject("addCityAction"));
   231 
   231 
   232 		QMap<QString, QVariant> itemList;
   232 		QMap<QString, QVariant> itemList;
   233 		QString value;
   233 		QString value;
   234 		QDateTime dateTime = QDateTime::currentDateTime();
   234 		QDateTime dateTime = QDateTime::currentDateTime();
   235 
   235 
   236 		// Show the date. If date is current date then show 'today'.
   236 		// Show the date.
   237 		QString dateInfo = dateTime.toString(
   237 		QString dateInfo = dateTime.toString(
   238 				mSettingsUtility->dateFormatString());
   238 				mSettingsUtility->dateFormatString());
   239 		itemList.insert(value.setNum(ClockHomeCityItem::Date), dateInfo);
   239 		itemList.insert(value.setNum(ClockHomeCityItem::Date), dateInfo);
   240 
   240 
   241 		// Show the city and country name.
   241 		// Show the city and country name.
   258 		}
   258 		}
   259 		itemList.insert(value.setNum(
   259 		itemList.insert(value.setNum(
   260 				ClockHomeCityItem::DayNightIndicator), dayNightIconPath);
   260 				ClockHomeCityItem::DayNightIndicator), dayNightIconPath);
   261 
   261 
   262 		// Show dst icon when needed.
   262 		// Show dst icon when needed.
       
   263 		QString dstIconPath = " ";
   263 		if (homeCity.dstOn) {
   264 		if (homeCity.dstOn) {
   264 			QString dstIconPath = "qtg_mono_day_light_saving_time";
   265 			dstIconPath = "qtg_mono_day_light_saving_time";
   265 			itemList.insert(value.setNum(ClockHomeCityItem::Dst), dstIconPath);
   266 		}
   266 		}
   267 		itemList.insert(value.setNum(ClockHomeCityItem::Dst), dstIconPath);
       
   268 		
   267 		mHomeCityWidget->setHomeCityItemData(itemList);
   269 		mHomeCityWidget->setHomeCityItemData(itemList);
   268 	}
   270 	}
   269 }
   271 }
   270 
   272 
   271 /*!
   273 /*!
   616 			offsetDifference += offsetString;
   618 			offsetDifference += offsetString;
   617 		}
   619 		}
   618 	}
   620 	}
   619 	else if ( hours ){
   621 	else if ( hours ){
   620 		if(hours == 1 ) {
   622 		if(hours == 1 ) {
   621 			displayFormat = hbTrId("txt_clock_dblist_val_1_hr");
   623 			displayFormat = hbTrId("txt_clock_dblist_daily_val_ln_hr");
   622 			offsetString = displayFormat.arg(hours);
   624 			offsetString = displayFormat.arg(hours);
   623 			offsetDifference += offsetString;
   625 			offsetDifference += offsetString;
   624 		}
   626 		}
   625 		else {
   627 		else {
   626 			displayFormat = hbTrId("txt_clock_dblist_val_1_hrs");
   628 			displayFormat = hbTrId("txt_clock_dblist_val_1_hrs");
   627 			offsetString = displayFormat.arg(hours);
   629 			offsetString = displayFormat.arg(hours);
   628 			offsetDifference += offsetString;
   630 			offsetDifference += offsetString;
   629 		}
   631 		}
   630 	}
   632 	}
   631 	else if (minutes){
   633 	else if (minutes){
   632 		displayFormat = hbTrId("txt_clock_dblist_val_1_mins");
   634 		displayFormat = hbTrId("txt_clock_dblist_daily_val_ln_mins");
   633 		offsetString = displayFormat.arg(minutes);
   635 		offsetString = displayFormat.arg(minutes);
   634 		offsetDifference += offsetString;
   636 		offsetDifference += offsetString;
   635 	} else {
   637 	} else {
   636 		displayFormat = hbTrId("txt_clock_dblist_val_1_hrs");
   638 		displayFormat = hbTrId("txt_clock_dblist_val_1_hrs");
   637 		offsetString = displayFormat.arg(0);
   639 		offsetString = displayFormat.arg(0);
   658 	QDateTime dateTime = QDateTime::currentDateTime();
   660 	QDateTime dateTime = QDateTime::currentDateTime();
   659 	dateTime = dateTime.toUTC();
   661 	dateTime = dateTime.toUTC();
   660 	dateTime = dateTime.addSecs(locationInfo.zoneOffset * 60);
   662 	dateTime = dateTime.addSecs(locationInfo.zoneOffset * 60);
   661 
   663 
   662 	// Display day/night indicators.
   664 	// Display day/night indicators.
   663 	// TODO: change the icon name for night when available.
       
   664 	QString dayNightIconPath = "";
   665 	QString dayNightIconPath = "";
   665 	if (isDay(dateTime)) {
   666 	if (isDay(dateTime)) {
   666 		dayNightIconPath = "qtg_large_clock";
   667 		dayNightIconPath = "qtg_large_clock";
   667 	} else {
   668 	} else {
   668 		dayNightIconPath = "qtg_large_clock_night";
   669 		dayNightIconPath = "qtg_large_clock_night";
   669 	}
   670 	}
   670 	decorationString.append(HbIcon(dayNightIconPath));
   671 	decorationString.append(HbIcon(dayNightIconPath));
   671 
   672 
   672 	// Show dst icon when needed.
   673 	// Show dst icon when needed.
       
   674 	QString dstIconPath = "";
   673 	if (locationInfo.dstOn) {
   675 	if (locationInfo.dstOn) {
   674 		QString dstIconPath = "qtg_mono_day_light_saving_time";
   676 		dstIconPath = "qtg_mono_day_light_saving_time";
   675 		decorationString.append(HbIcon(dstIconPath));
   677 	}
   676 	}
   678 	decorationString.append(HbIcon(dstIconPath));
       
   679 	
   677 	return decorationString;
   680 	return decorationString;
   678 	
   681 	
   679 }
   682 }
   680 
   683 
   681 /*!
   684 /*!
   685 {
   688 {
   686 	int cityInfoCount = mCityInfoList.count();
   689 	int cityInfoCount = mCityInfoList.count();
   687 
   690 
   688 	if (cityInfoCount) {
   691 	if (cityInfoCount) {
   689 		bool deletion = false;
   692 		bool deletion = false;
       
   693 		bool valueUpdated = false;
   690 		int index;
   694 		int index;
   691 		LocationInfo currentCity = mTimezoneClient->getCurrentZoneInfoL();
   695 		LocationInfo currentCity = mTimezoneClient->getCurrentZoneInfoL();
       
   696 		// Remove the new home city if it is already added to the list.
   692 		for (index = 0; index < cityInfoCount; index++) {
   697 		for (index = 0; index < cityInfoCount; index++) {
   693 			if (currentCity.timezoneId == mCityInfoList.at(index).timezoneId
   698 			if (currentCity.timezoneId == mCityInfoList.at(index).timezoneId
   694 					&& (currentCity.cityName ==
   699 					&& (currentCity.cityName ==
   695 							mCityInfoList.at(index).cityName)
   700 							mCityInfoList.at(index).cityName)
   696 					&& (currentCity.countryName ==
   701 					&& (currentCity.countryName ==
   718 				mAddCityAction->setEnabled(true);
   723 				mAddCityAction->setEnabled(true);
   719 				mAddCityMenuAction->setVisible(true);
   724 				mAddCityMenuAction->setVisible(true);
   720 			}
   725 			}
   721 			
   726 			
   722 		}
   727 		}
       
   728 		
       
   729 		for (int index = 0; index < cityInfoCount; ++index) {
       
   730 			int tzid = mCityInfoList[index].timezoneId;
       
   731 			bool dst = mTimezoneClient->isDSTOnL(tzid);
       
   732 			if (dst != mCityInfoList[index].dstOn) {
       
   733 				mCityInfoList[index].dstOn = dst;
       
   734 				valueUpdated = true;
       
   735 			}
       
   736 
       
   737 		}
       
   738 		
       
   739 		if (valueUpdated) {
       
   740 			// Update the data file.
       
   741 			mTimezoneClient->saveLocations(mCityInfoList);
       
   742         }
   723 	}
   743 	}
   724 }
   744 }
   725 
   745 
   726 // End of file-- Don't delete.
   746 // End of file-- Don't delete.