clock/clockui/clockcityselectionlist/src/clockcityselectionlist_p.cpp
changeset 51 0b38fc5b94c6
parent 45 b6db4fd4947b
child 55 2c54b51f39c4
equal deleted inserted replaced
46:ecd7b9840282 51:0b38fc5b94c6
   238 void ClockCitySelectionListPrivate::handleAddOwnCityAction()
   238 void ClockCitySelectionListPrivate::handleAddOwnCityAction()
   239 {
   239 {
   240 	if (mAddOwnCityDialog) {
   240 	if (mAddOwnCityDialog) {
   241 		delete mAddOwnCityDialog;
   241 		delete mAddOwnCityDialog;
   242 	}
   242 	}
   243 
   243 	
   244 	// Create the dialog.
   244 	HbMainWindow *window = hbInstance->allMainWindows().first();
   245 	mAddOwnCityDialog = new HbDialog;
   245 
       
   246 	connect(
       
   247 			window, SIGNAL(orientationChanged(Qt::Orientation)),
       
   248 			this, SLOT(loadSection(Qt::Orientation)));
       
   249 	
       
   250 	mAddCityDocloader = new HbDocumentLoader();
       
   251 	bool success = false;
       
   252 	mAddCityDocloader->load(":/xml/clockaddcitydialog.docml", &success);
       
   253 	if (!success) {
       
   254 		qFatal("Unable to load the document.");
       
   255 	}
       
   256 
       
   257 	// Get the dialog.
       
   258 	mAddOwnCityDialog = static_cast<HbDialog *> (mAddCityDocloader->findWidget("dialog"));
       
   259 	if (!mAddOwnCityDialog) {
       
   260 		qFatal("Unable to get the selection view.");
       
   261 	}
   246 	mAddOwnCityDialog->setTimeout(HbDialog::NoTimeout);
   262 	mAddOwnCityDialog->setTimeout(HbDialog::NoTimeout);
   247 	mAddOwnCityDialog->setDismissPolicy(HbDialog::NoDismiss);
   263 	mAddOwnCityDialog->setDismissPolicy(HbDialog::NoDismiss);
   248 	mAddOwnCityDialog->setAttribute(Qt::WA_DeleteOnClose, true);
   264 	mAddOwnCityDialog->setAttribute(Qt::WA_DeleteOnClose, true);
   249 
   265 	
   250 	// Set the heading text
   266 	// Find the elements from the docml.
   251 	HbLabel *titlelabel = new HbLabel(hbTrId("txt_clk_opt_add_own_city"));
   267 	mCityNameEdit = static_cast<HbLineEdit *> (mAddCityDocloader->findWidget("cityNameLineEdit"));
   252 	mAddOwnCityDialog->setHeadingWidget(titlelabel);
   268 	
   253 
   269 	mTimeZoneComboBox = static_cast<HbComboBox *> (mAddCityDocloader->findWidget("timezoneCombobox"));
   254 	QGraphicsGridLayout *layout = new QGraphicsGridLayout();
   270 	if (mTimeZoneComboBox) {
   255 
   271 		addTimeZoneField();
   256 	// Set city name label and line edit
   272 	}
   257 	HbLabel *cityNameLabel = new HbLabel(hbTrId("txt_clock_formlabel_city_name"));
   273 	
   258 	layout->addItem(cityNameLabel,0,0);
   274 	mCountryComboBox = static_cast<HbComboBox *> (mAddCityDocloader->findWidget("counrtyCombobox"));
   259 
       
   260 	addCityNameField();
       
   261 	layout->addItem(mCityNameEdit, 0, 1);
       
   262 
       
   263 	// Set time zone label and combobox
       
   264 	HbLabel *timeZoneLabel = new HbLabel(hbTrId("txt_clock_formlabel_timezone"));
       
   265 	layout->addItem(timeZoneLabel, 1,0);
       
   266 
       
   267 	addTimeZoneField();
       
   268 	layout->addItem(mTimeZoneComboBox, 1,1);
       
   269 
       
   270 	// Set the country label and combobox
       
   271 	HbLabel *countryLabel = new HbLabel(hbTrId("txt_clock_formlabel_country"));
       
   272 	layout->addItem(countryLabel, 2,0);
       
   273 
       
   274 	addCountryListField();
   275 	addCountryListField();
   275 	layout->addItem(mCountryComboBox, 2,1);
   276 	
   276 
   277 	mOkAction = static_cast<HbAction *> (mAddCityDocloader->findObject("okAction"));
   277 	QGraphicsWidget *widget = new QGraphicsWidget();
   278 	
   278 	widget->setLayout(layout);
       
   279 
       
   280 	// Add actions to the dialog
       
   281 	mOkAction = new HbAction(hbTrId("txt_common_button_ok"));
       
   282 	mCancelAction = new HbAction(hbTrId("txt_common_button_cancel"));
       
   283 
       
   284 	mAddOwnCityDialog->addAction(mOkAction);
       
   285 	mAddOwnCityDialog->addAction(mCancelAction);
       
   286 
       
   287 	mAddOwnCityDialog->setContentWidget(widget);
       
   288 	mAddOwnCityDialog->open(this, SLOT(selectedAction(HbAction*)));
   279 	mAddOwnCityDialog->open(this, SLOT(selectedAction(HbAction*)));
   289 }
   280 }
   290 
   281 
   291 /*!
   282 /*!
   292 	Hanldes Ok action of add own city dialog
   283 	Hanldes Ok action of add own city dialog
   354 {
   345 {
   355 	if (action==mOkAction) {
   346 	if (action==mOkAction) {
   356 		handleOkAction();
   347 		handleOkAction();
   357 	}
   348 	}
   358 }
   349 }
       
   350 
       
   351 /*!
       
   352 	Slot to handle the orientation change.
       
   353  */
       
   354 void ClockCitySelectionListPrivate::loadSection(Qt::Orientation orientation)
       
   355 {
       
   356 	bool loadSuccess;
       
   357 	if (mAddOwnCityDialog) {
       
   358 		if (Qt::Horizontal == orientation) {
       
   359 			mAddCityDocloader->load(":/xml/clockaddcitydialog.docml",
       
   360 					"landscape", &loadSuccess);
       
   361 		} else if (Qt::Vertical == orientation) {
       
   362 			mAddCityDocloader->load(":/xml/clockaddcitydialog.docml",
       
   363 					"portrait", &loadSuccess);
       
   364 		}
       
   365 	}
       
   366 }
       
   367 
   359 /*!
   368 /*!
   360 	Displays the city selection list.
   369 	Displays the city selection list.
   361  */
   370  */
   362 void ClockCitySelectionListPrivate::showCityList()
   371 void ClockCitySelectionListPrivate::showCityList()
   363 {
   372 {
   488 /*!
   497 /*!
   489 	Add timezone field to add own city popup.
   498 	Add timezone field to add own city popup.
   490  */
   499  */
   491 void ClockCitySelectionListPrivate::addTimeZoneField()
   500 void ClockCitySelectionListPrivate::addTimeZoneField()
   492 {
   501 {
   493 	mTimeZoneComboBox = new HbComboBox();
   502 //	mTimeZoneComboBox = new HbComboBox();
   494 
   503 
   495 	QStringList texts = getOffsetTexts();
   504 	QStringList texts = getOffsetTexts();
   496 	mTimeZoneComboBox->addItems(texts);
   505 	mTimeZoneComboBox->addItems(texts);
   497 
   506 
   498 	// Get the home city information.
   507 	// Get the home city information.
   509 /*!
   518 /*!
   510 	Add country list field to add own city popup.
   519 	Add country list field to add own city popup.
   511  */
   520  */
   512 void ClockCitySelectionListPrivate::addCountryListField()
   521 void ClockCitySelectionListPrivate::addCountryListField()
   513 {
   522 {
   514 	mCountryComboBox = new HbComboBox();
       
   515 
       
   516 	// Populate the country list based on the current TZ offset selected.
   523 	// Populate the country list based on the current TZ offset selected.
   517 	handleTimeZoneSelection(mCurrentTZOffsetIndex);
   524 	handleTimeZoneSelection(mCurrentTZOffsetIndex);
   518 }
   525 }
   519 
   526 
   520 // End of file	--Don't remove this.
   527 // End of file	--Don't remove this.