clock/clockui/clockcityselectionlist/src/clockcityselectionlist_p.cpp
changeset 55 2c54b51f39c4
parent 51 0b38fc5b94c6
child 57 bb2d3e476f29
equal deleted inserted replaced
51:0b38fc5b94c6 55:2c54b51f39c4
    17 */
    17 */
    18 
    18 
    19 // System includes
    19 // System includes
    20 #include <QStandardItemModel>
    20 #include <QStandardItemModel>
    21 #include <QModelIndex>
    21 #include <QModelIndex>
       
    22 #include <QGraphicsScene>
       
    23 #include <QTimer>
    22 #include <HbDocumentLoader>
    24 #include <HbDocumentLoader>
    23 #include <HbView>
    25 #include <HbView>
    24 #include <HbListView>
    26 #include <HbListView>
    25 #include <HbListViewItem>
    27 #include <HbListViewItem>
    26 #include <HbMainWindow>
    28 #include <HbMainWindow>
    32 #include <HbDialog>
    34 #include <HbDialog>
    33 #include <HbLabel>
    35 #include <HbLabel>
    34 #include <HbComboBox>
    36 #include <HbComboBox>
    35 #include <HbExtendedLocale>
    37 #include <HbExtendedLocale>
    36 #include <HbAbstractItemView>
    38 #include <HbAbstractItemView>
       
    39 #include <HbShrinkingVkbHost>
    37 
    40 
    38 // User includes
    41 // User includes
    39 #include "clockcityselectionlist_p.h"
    42 #include "clockcityselectionlist_p.h"
    40 #include "clockcityselectionlist.h"
    43 #include "clockcityselectionlist.h"
    41 #include "clockcitylistproxymodel.h"
    44 #include "clockcitylistproxymodel.h"
    92 		mTimeZoneOffsetList.clear();
    95 		mTimeZoneOffsetList.clear();
    93 	}
    96 	}
    94 	if(mCountryList.count()) {
    97 	if(mCountryList.count()) {
    95 		mCountryList.clear();
    98 		mCountryList.clear();
    96 	}
    99 	}
       
   100 	if (mVirtualKeyboard) {
       
   101 	    delete mVirtualKeyboard;
       
   102     }
    97 
   103 
    98 }
   104 }
    99 
   105 
   100 /*!
   106 /*!
   101 	Populates the list model by getting the data from timezone client.
   107 	Populates the list model by getting the data from timezone client.
   364 		}
   370 		}
   365 	}
   371 	}
   366 }
   372 }
   367 
   373 
   368 /*!
   374 /*!
       
   375 	Slot to handle close action of search panel.
       
   376 	This slot cancels the search and dismisses the vkb.
       
   377  */
       
   378 void ClockCitySelectionListPrivate::cancelSearch()
       
   379 {
       
   380 	// Clear the search criteria.
       
   381 	mSearchBox->setCriteria(QString(""));
       
   382 	
       
   383 	// Hide the virtual keyborad.	
       
   384 	QInputContext *ic = qApp->inputContext();
       
   385 	if (ic) {
       
   386 		QEvent *event = new QEvent(QEvent::CloseSoftwareInputPanel);
       
   387 		ic->filterEvent(event);
       
   388 		delete event;
       
   389 	}
       
   390 	
       
   391 	// Set focus to the first city in the list.
       
   392 	mListView->scrollTo(mProxyModel->index(0, 0));
       
   393 }
       
   394 
       
   395 /*!
       
   396     Focuses the line edit when the city selection list is opened.
       
   397  */
       
   398 void ClockCitySelectionListPrivate::focusLineEdit()
       
   399 {
       
   400 	if (mSearchBox) {
       
   401 		// mView->scene()->setFocusItem(mSearchBox);
       
   402 		HbLineEdit *searchBoxEditor = 0;
       
   403 		searchBoxEditor = static_cast<HbLineEdit*>(
       
   404 				mSearchBox->primitive("lineedit"));
       
   405 
       
   406 		if (searchBoxEditor) {
       
   407 			searchBoxEditor->setInputMethodHints(Qt::ImhNoPredictiveText);
       
   408 /*			HbMainWindow *window = hbInstance->allMainWindows().at(0);
       
   409 			window->scene()->setFocusItem(searchBoxEditor);*/
       
   410 
       
   411 			// searchBoxEditor->setCursorPosition(0);
       
   412 			searchBoxEditor->setFocus();
       
   413 		}
       
   414 		
       
   415 		QInputContext *ic = qApp->inputContext();
       
   416 		if (ic) {
       
   417 			QEvent *event = new QEvent(QEvent::RequestSoftwareInputPanel);
       
   418 			ic->filterEvent(event);
       
   419 			delete event;
       
   420 		}
       
   421 	}
       
   422 }
       
   423 
       
   424 /*!
   369 	Displays the city selection list.
   425 	Displays the city selection list.
   370  */
   426  */
   371 void ClockCitySelectionListPrivate::showCityList()
   427 void ClockCitySelectionListPrivate::showCityList()
   372 {
   428 {
   373 	// Construct the document loader.
   429 	// Construct the document loader.
   381 	// Get the selection view.
   437 	// Get the selection view.
   382 	mView = static_cast<HbView *> (mLoader->findWidget(CITYSELECTIONLISTVIEW));
   438 	mView = static_cast<HbView *> (mLoader->findWidget(CITYSELECTIONLISTVIEW));
   383 	if (!mView) {
   439 	if (!mView) {
   384 		qFatal("Unable to get the selection view.");
   440 		qFatal("Unable to get the selection view.");
   385 	}
   441 	}
   386 
   442 	// Set the shrinking vkb host to prevent pushing of the list.
       
   443 	mVirtualKeyboard = new HbShrinkingVkbHost(mView);
       
   444 	
   387 	// Get the list view.
   445 	// Get the list view.
   388 	mListView = static_cast<HbListView *> (mLoader->findWidget(CITYLISTVIEW));
   446 	mListView = static_cast<HbListView *> (mLoader->findWidget(CITYLISTVIEW));
   389 	if (!mListView) {
   447 	if (!mListView) {
   390 		qFatal("Unable to get the list view.");
   448 		qFatal("Unable to get the list view.");
   391 	}
   449 	}
   399 	mSearchBox->setSearchOptionsEnabled(false);
   457 	mSearchBox->setSearchOptionsEnabled(false);
   400 
   458 
   401 	connect(
   459 	connect(
   402 			mSearchBox, SIGNAL(criteriaChanged(QString)),
   460 			mSearchBox, SIGNAL(criteriaChanged(QString)),
   403 			this, SLOT(updateSearchCriteria(QString)));
   461 			this, SLOT(updateSearchCriteria(QString)));
   404 
   462 	connect(mSearchBox, SIGNAL(exitClicked()),
       
   463 	        this, SLOT(cancelSearch()));
       
   464 	
   405 	// Construct the source model.
   465 	// Construct the source model.
   406 	if (!mListModel) {
   466 	if (!mListModel) {
   407 		mListModel = new QStandardItemModel(0, 1, this);
   467 		mListModel = new QStandardItemModel(0, 1, this);
   408 	}
   468 	}
   409 	// Construct the proxy model.
   469 	// Construct the proxy model.
   440 			mBackAction, SIGNAL(triggered()),
   500 			mBackAction, SIGNAL(triggered()),
   441 			this, SLOT(handleBackAction()));
   501 			this, SLOT(handleBackAction()));
   442 
   502 
   443 	window->addView(mView);
   503 	window->addView(mView);
   444 	window->setCurrentView(mView);
   504 	window->setCurrentView(mView);
       
   505 	
       
   506 	// Focus the search box.
       
   507 	focusLineEdit();
   445 
   508 
   446 }
   509 }
   447 
   510 
   448 /*!
   511 /*!
   449 	Get all the time zone offset texts.
   512 	Get all the time zone offset texts.