diff -r 579cc610882e -r ef813d54df51 clock/clockui/clockcityselectionlist/src/clockcityselectionlist_p.cpp --- a/clock/clockui/clockcityselectionlist/src/clockcityselectionlist_p.cpp Tue Jul 06 14:14:56 2010 +0300 +++ b/clock/clockui/clockcityselectionlist/src/clockcityselectionlist_p.cpp Wed Aug 18 09:47:38 2010 +0300 @@ -1,4 +1,4 @@ -/* + /* * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available @@ -19,6 +19,8 @@ // System includes #include #include +#include +#include #include #include #include @@ -34,6 +36,7 @@ #include #include #include +#include // User includes #include "clockcityselectionlist_p.h" @@ -43,6 +46,11 @@ #include "timezoneclient.h" #include "clockdatatypes.h" +#include "OstTraceDefinitions.h" +#ifdef OST_TRACE_COMPILER_IN_USE +#include "clockcityselectionlist_pTraces.h" +#endif + /*! \class ClockCitySelectionListPrivate @@ -62,6 +70,7 @@ mLoader(0), mOwnsClient(false) { + OstTraceFunctionEntry0( CLOCKCITYSELECTIONLISTPRIVATE_CLOCKCITYSELECTIONLISTPRIVATE_ENTRY ); // First get the q-pointer. q_ptr = static_cast (parent); @@ -70,6 +79,7 @@ mClient = TimezoneClient::getInstance(); mOwnsClient = true; } + OstTraceFunctionExit0( CLOCKCITYSELECTIONLISTPRIVATE_CLOCKCITYSELECTIONLISTPRIVATE_EXIT ); } /*! @@ -77,6 +87,7 @@ */ ClockCitySelectionListPrivate::~ClockCitySelectionListPrivate() { + OstTraceFunctionEntry0( DUP1_CLOCKCITYSELECTIONLISTPRIVATE_CLOCKCITYSELECTIONLISTPRIVATE_ENTRY ); if (mOwnsClient) { mClient->deleteInstance(); } @@ -94,7 +105,11 @@ if(mCountryList.count()) { mCountryList.clear(); } + if (mVirtualKeyboard) { + delete mVirtualKeyboard; + } + OstTraceFunctionExit0( DUP1_CLOCKCITYSELECTIONLISTPRIVATE_CLOCKCITYSELECTIONLISTPRIVATE_EXIT ); } /*! @@ -102,6 +117,7 @@ */ void ClockCitySelectionListPrivate::populateListModel() { + OstTraceFunctionEntry0( CLOCKCITYSELECTIONLISTPRIVATE_POPULATELISTMODEL_ENTRY ); // First get the data from the timezone client. QList &infoList = mClient->getLocations(); @@ -139,6 +155,7 @@ // Cleanup. infoList.clear(); + OstTraceFunctionExit0( CLOCKCITYSELECTIONLISTPRIVATE_POPULATELISTMODEL_EXIT ); } /*! @@ -149,6 +166,7 @@ void ClockCitySelectionListPrivate::handleItemActivated( const QModelIndex &index) { + OstTraceFunctionEntry0( CLOCKCITYSELECTIONLISTPRIVATE_HANDLEITEMACTIVATED_ENTRY ); LocationInfo selectedInfo; selectedInfo.timezoneId = index.data(Qt::UserRole + 101).value(); selectedInfo.cityGroupId = index.data(Qt::UserRole + 102).value(); @@ -163,6 +181,7 @@ // Close the list. closeCityList(); + OstTraceFunctionExit0( CLOCKCITYSELECTIONLISTPRIVATE_HANDLEITEMACTIVATED_EXIT ); } /*! @@ -170,6 +189,7 @@ */ void ClockCitySelectionListPrivate::handleBackAction() { + OstTraceFunctionEntry0( CLOCKCITYSELECTIONLISTPRIVATE_HANDLEBACKACTION_ENTRY ); LocationInfo info; info.timezoneId = -1; @@ -187,6 +207,7 @@ // Close the list. closeCityList(); + OstTraceFunctionExit0( CLOCKCITYSELECTIONLISTPRIVATE_HANDLEBACKACTION_EXIT ); } /*! @@ -194,6 +215,7 @@ */ void ClockCitySelectionListPrivate::closeCityList() { + OstTraceFunctionEntry0( CLOCKCITYSELECTIONLISTPRIVATE_CLOSECITYLIST_ENTRY ); // We are done, lets remove the view off the main window. HbMainWindow *window = hbInstance->allMainWindows().at(0); window->removeView(mView); @@ -207,6 +229,7 @@ if (mListModel) { delete mListModel; } + OstTraceFunctionExit0( CLOCKCITYSELECTIONLISTPRIVATE_CLOSECITYLIST_EXIT ); } /*! @@ -217,6 +240,7 @@ void ClockCitySelectionListPrivate::updateSearchCriteria( const QString &criteria) { + OstTraceFunctionEntry0( CLOCKCITYSELECTIONLISTPRIVATE_UPDATESEARCHCRITERIA_ENTRY ); int originalMask = mListView->enabledAnimations(); mListView->setEnabledAnimations(HbAbstractItemView::TouchDown); @@ -230,6 +254,7 @@ mProxyModel->setFilterRegExp(searchExp); mProxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive); + OstTraceFunctionExit0( CLOCKCITYSELECTIONLISTPRIVATE_UPDATESEARCHCRITERIA_EXIT ); } /*! @@ -237,55 +262,48 @@ */ void ClockCitySelectionListPrivate::handleAddOwnCityAction() { + OstTraceFunctionEntry0( CLOCKCITYSELECTIONLISTPRIVATE_HANDLEADDOWNCITYACTION_ENTRY ); if (mAddOwnCityDialog) { delete mAddOwnCityDialog; } + + HbMainWindow *window = hbInstance->allMainWindows().first(); - // Create the dialog. - mAddOwnCityDialog = new HbDialog; + connect( + window, SIGNAL(orientationChanged(Qt::Orientation)), + this, SLOT(loadSection(Qt::Orientation))); + + mAddCityDocloader = new HbDocumentLoader(); + bool success = false; + mAddCityDocloader->load(":/xml/clockaddcitydialog.docml", &success); + if (!success) { + qFatal("Unable to load the document."); + } + + // Get the dialog. + mAddOwnCityDialog = static_cast (mAddCityDocloader->findWidget("dialog")); + if (!mAddOwnCityDialog) { + qFatal("Unable to get the selection view."); + } mAddOwnCityDialog->setTimeout(HbDialog::NoTimeout); mAddOwnCityDialog->setDismissPolicy(HbDialog::NoDismiss); mAddOwnCityDialog->setAttribute(Qt::WA_DeleteOnClose, true); - - // Set the heading text - HbLabel *titlelabel = new HbLabel(hbTrId("txt_clk_opt_add_own_city")); - mAddOwnCityDialog->setHeadingWidget(titlelabel); - - QGraphicsGridLayout *layout = new QGraphicsGridLayout(); - - // Set city name label and line edit - HbLabel *cityNameLabel = new HbLabel(hbTrId("txt_clock_formlabel_city_name")); - layout->addItem(cityNameLabel,0,0); - - addCityNameField(); - layout->addItem(mCityNameEdit, 0, 1); - - // Set time zone label and combobox - HbLabel *timeZoneLabel = new HbLabel(hbTrId("txt_clock_formlabel_timezone")); - layout->addItem(timeZoneLabel, 1,0); - - addTimeZoneField(); - layout->addItem(mTimeZoneComboBox, 1,1); - - // Set the country label and combobox - HbLabel *countryLabel = new HbLabel(hbTrId("txt_clock_formlabel_country")); - layout->addItem(countryLabel, 2,0); - + + // Find the elements from the docml. + mCityNameEdit = static_cast (mAddCityDocloader->findWidget("cityNameLineEdit")); + + mTimeZoneComboBox = static_cast (mAddCityDocloader->findWidget("timezoneCombobox")); + if (mTimeZoneComboBox) { + addTimeZoneField(); + } + + mCountryComboBox = static_cast (mAddCityDocloader->findWidget("counrtyCombobox")); addCountryListField(); - layout->addItem(mCountryComboBox, 2,1); - - QGraphicsWidget *widget = new QGraphicsWidget(); - widget->setLayout(layout); - - // Add actions to the dialog - mOkAction = new HbAction(hbTrId("txt_common_button_ok")); - mCancelAction = new HbAction(hbTrId("txt_common_button_cancel")); - - mAddOwnCityDialog->addAction(mOkAction); - mAddOwnCityDialog->addAction(mCancelAction); - - mAddOwnCityDialog->setContentWidget(widget); + + mOkAction = static_cast (mAddCityDocloader->findObject("okAction")); + mAddOwnCityDialog->open(this, SLOT(selectedAction(HbAction*))); + OstTraceFunctionExit0( CLOCKCITYSELECTIONLISTPRIVATE_HANDLEADDOWNCITYACTION_EXIT ); } /*! @@ -293,6 +311,7 @@ */ void ClockCitySelectionListPrivate::handleOkAction() { + OstTraceFunctionEntry0( CLOCKCITYSELECTIONLISTPRIVATE_HANDLEOKACTION_ENTRY ); QString cityName = mCityNameEdit->text(); // Add the city if city name is not empty @@ -320,6 +339,7 @@ populateListModel(); } } + OstTraceFunctionExit0( CLOCKCITYSELECTIONLISTPRIVATE_HANDLEOKACTION_EXIT ); } /*! @@ -328,6 +348,7 @@ */ void ClockCitySelectionListPrivate::handleTimeZoneSelection(int index) { + OstTraceFunctionEntry0( CLOCKCITYSELECTIONLISTPRIVATE_HANDLETIMEZONESELECTION_ENTRY ); // Get the selected time zone offset. int selectedTimeZoneOffset = mTimeZoneOffsetList.at(index); @@ -345,6 +366,7 @@ qSort(countries); mCountryComboBox->setItems(countries); } + OstTraceFunctionExit0( CLOCKCITYSELECTIONLISTPRIVATE_HANDLETIMEZONESELECTION_EXIT ); } /*! @@ -352,15 +374,92 @@ */ void ClockCitySelectionListPrivate::selectedAction(HbAction *action) { + OstTraceFunctionEntry0( CLOCKCITYSELECTIONLISTPRIVATE_SELECTEDACTION_ENTRY ); if (action==mOkAction) { handleOkAction(); } + OstTraceFunctionExit0( CLOCKCITYSELECTIONLISTPRIVATE_SELECTEDACTION_EXIT ); } + +/*! + Slot to handle the orientation change. + */ +void ClockCitySelectionListPrivate::loadSection(Qt::Orientation orientation) +{ + OstTraceFunctionEntry0( CLOCKCITYSELECTIONLISTPRIVATE_LOADSECTION_ENTRY ); + bool loadSuccess; + if (mAddOwnCityDialog) { + if (Qt::Horizontal == orientation) { + mAddCityDocloader->load(":/xml/clockaddcitydialog.docml", + "landscape", &loadSuccess); + } else if (Qt::Vertical == orientation) { + mAddCityDocloader->load(":/xml/clockaddcitydialog.docml", + "portrait", &loadSuccess); + } + } + OstTraceFunctionExit0( CLOCKCITYSELECTIONLISTPRIVATE_LOADSECTION_EXIT ); +} + +/*! + Slot to handle close action of search panel. + This slot cancels the search and dismisses the vkb. + */ +void ClockCitySelectionListPrivate::cancelSearch() +{ + OstTraceFunctionEntry0( CLOCKCITYSELECTIONLISTPRIVATE_CANCELSEARCH_ENTRY ); + // Clear the search criteria. + mSearchBox->setCriteria(QString("")); + + // Hide the virtual keyborad. + QInputContext *ic = qApp->inputContext(); + if (ic) { + QEvent *event = new QEvent(QEvent::CloseSoftwareInputPanel); + ic->filterEvent(event); + delete event; + } + + // Set focus to the first city in the list. + mListView->scrollTo(mProxyModel->index(0, 0)); + OstTraceFunctionExit0( CLOCKCITYSELECTIONLISTPRIVATE_CANCELSEARCH_EXIT ); +} + +/*! + Focuses the line edit when the city selection list is opened. + */ +void ClockCitySelectionListPrivate::focusLineEdit() +{ + OstTraceFunctionEntry0( CLOCKCITYSELECTIONLISTPRIVATE_FOCUSLINEEDIT_ENTRY ); + if (mSearchBox) { + // mView->scene()->setFocusItem(mSearchBox); + HbLineEdit *searchBoxEditor = 0; + searchBoxEditor = static_cast( + mSearchBox->primitive("lineedit")); + + if (searchBoxEditor) { + searchBoxEditor->setInputMethodHints(Qt::ImhNoPredictiveText); +/* HbMainWindow *window = hbInstance->allMainWindows().at(0); + window->scene()->setFocusItem(searchBoxEditor);*/ + + // searchBoxEditor->setCursorPosition(0); + searchBoxEditor->setFocus(); + } + + QInputContext *ic = qApp->inputContext(); + if (ic) { + QEvent *event = new QEvent(QEvent::RequestSoftwareInputPanel); + ic->filterEvent(event); + delete event; + } + } + OstTraceFunctionExit0( CLOCKCITYSELECTIONLISTPRIVATE_FOCUSLINEEDIT_EXIT ); +} + /*! Displays the city selection list. */ void ClockCitySelectionListPrivate::showCityList() { + OstTraceFunctionEntry0( CLOCKCITYSELECTIONLISTPRIVATE_SHOWCITYLIST_ENTRY ); // Construct the document loader. bool success = false; mLoader = new HbDocumentLoader; @@ -374,7 +473,9 @@ if (!mView) { qFatal("Unable to get the selection view."); } - + // Set the shrinking vkb host to prevent pushing of the list. + mVirtualKeyboard = new HbShrinkingVkbHost(mView); + // Get the list view. mListView = static_cast (mLoader->findWidget(CITYLISTVIEW)); if (!mListView) { @@ -392,7 +493,9 @@ connect( mSearchBox, SIGNAL(criteriaChanged(QString)), this, SLOT(updateSearchCriteria(QString))); - + connect(mSearchBox, SIGNAL(exitClicked()), + this, SLOT(cancelSearch())); + // Construct the source model. if (!mListModel) { mListModel = new QStandardItemModel(0, 1, this); @@ -433,7 +536,11 @@ window->addView(mView); window->setCurrentView(mView); + + // Focus the search box. + focusLineEdit(); + OstTraceFunctionExit0( CLOCKCITYSELECTIONLISTPRIVATE_SHOWCITYLIST_EXIT ); } /*! @@ -441,6 +548,7 @@ */ QStringList ClockCitySelectionListPrivate::getOffsetTexts() { + OstTraceFunctionEntry0( CLOCKCITYSELECTIONLISTPRIVATE_GETOFFSETTEXTS_ENTRY ); int offsetCount(mTimeZoneOffsetList.count()); // Get all the time zone offsets @@ -473,6 +581,7 @@ offsetTextList.append(offsetText); offsetText.clear(); } + OstTraceFunctionExit0( CLOCKCITYSELECTIONLISTPRIVATE_GETOFFSETTEXTS_EXIT ); return offsetTextList; } @@ -481,8 +590,10 @@ */ void ClockCitySelectionListPrivate::addCityNameField() { + OstTraceFunctionEntry0( CLOCKCITYSELECTIONLISTPRIVATE_ADDCITYNAMEFIELD_ENTRY ); mCityNameEdit = new HbLineEdit(); mCityNameEdit->setFocus(Qt::MouseFocusReason); + OstTraceFunctionExit0( CLOCKCITYSELECTIONLISTPRIVATE_ADDCITYNAMEFIELD_EXIT ); } /*! @@ -490,7 +601,8 @@ */ void ClockCitySelectionListPrivate::addTimeZoneField() { - mTimeZoneComboBox = new HbComboBox(); +OstTraceFunctionEntry0( CLOCKCITYSELECTIONLISTPRIVATE_ADDTIMEZONEFIELD_ENTRY ); +// mTimeZoneComboBox = new HbComboBox(); QStringList texts = getOffsetTexts(); mTimeZoneComboBox->addItems(texts); @@ -504,6 +616,7 @@ connect( mTimeZoneComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(handleTimeZoneSelection(int))); + OstTraceFunctionExit0( CLOCKCITYSELECTIONLISTPRIVATE_ADDTIMEZONEFIELD_EXIT ); } /*! @@ -511,10 +624,10 @@ */ void ClockCitySelectionListPrivate::addCountryListField() { - mCountryComboBox = new HbComboBox(); - + OstTraceFunctionEntry0( CLOCKCITYSELECTIONLISTPRIVATE_ADDCOUNTRYLISTFIELD_ENTRY ); // Populate the country list based on the current TZ offset selected. handleTimeZoneSelection(mCurrentTZOffsetIndex); + OstTraceFunctionExit0( CLOCKCITYSELECTIONLISTPRIVATE_ADDCOUNTRYLISTFIELD_EXIT ); } // End of file --Don't remove this.