diff -r 2a11b5b00470 -r fd64c38c277d phonebookui/pbkcommonui/src/cntfetchcontactsview.cpp --- a/phonebookui/pbkcommonui/src/cntfetchcontactsview.cpp Fri May 14 15:42:23 2010 +0300 +++ b/phonebookui/pbkcommonui/src/cntfetchcontactsview.cpp Thu May 27 12:45:19 2010 +0300 @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include #include #include "cntfetchcontactsview.h" @@ -53,7 +53,7 @@ { mSearchPanel = new HbSearchPanel(); mSearchPanel->setVisible(false); - connect(mSearchPanel, SIGNAL(exitClicked()), this, SLOT(closeFind())); + mSearchPanel->setCancelEnabled(false); connect(mSearchPanel, SIGNAL(criteriaChanged(QString)), this, SLOT(setFilter(QString))); mLayout = new QGraphicsLinearLayout(Qt::Vertical); @@ -145,18 +145,6 @@ return mCurrentlySelected; } -void CntFetchContacts::closeFind() -{ - if (mSearchPanel) { - QContactDetailFilter filter; - filter.setDetailDefinitionName(QContactType::DefinitionName, QContactType::FieldType); - QString typeContact = QContactType::TypeContact; - filter.setValue(typeContact); - - mSearchPanel->deleteLater(); - } -} - void CntFetchContacts::setFilter(const QString &filterString) { QStringList searchList = filterString.split(QRegExp("\\s+"), QString::SkipEmptyParts); @@ -254,6 +242,12 @@ mCurrentlySelected.remove(contactId); } } + + // Check for the case where there is a cancel button only. If so, + // after selecting any contact, should dismiss the dialog immediately. + if (mButtonText.isEmpty() && mSelectionMode == HbAbstractItemView::SingleSelection) { + mPopup->close(); + } } void CntFetchContacts::doInitialize(HbAbstractItemView::SelectionMode aMode, @@ -264,38 +258,43 @@ mSearchPanel->setVisible(true); - mPopup = new HbDialog; - mListView = new HbListView(mPopup); - mListView->setModel(mCntModel); - mListView->setSelectionMode(mSelectionMode); - mListView->setFrictionEnabled(true); - mListView->setScrollingStyle(HbScrollArea::PanWithFollowOn); - mListView->verticalScrollBar()->setInteractive(true); - - HbListViewItem *prototype = mListView->listItemPrototype(); - prototype->setGraphicsSize(HbListViewItem::Thumbnail); - prototype->setStretchingStyle(HbListViewItem::StretchLandscape); - - mIndexFeedback = new HbIndexFeedback(mPopup); - mIndexFeedback->setIndexFeedbackPolicy(HbIndexFeedback::IndexFeedbackSingleCharacter); - mIndexFeedback->setItemView(mListView); - - // Note that the layout takes ownership of the item(s) it contains. - if (!mCntModel->rowCount()) { - mListView->setVisible(false); - if (!mEmptyListLabel) { - mEmptyListLabel = new HbTextItem(hbTrId("(no matching contacts)")); - mEmptyListLabel->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); - mEmptyListLabel->setFontSpec(HbFontSpec(HbFontSpec::Primary)); - mEmptyListLabel->setAlignment(Qt::AlignCenter); - mLayout->insertItem(0, mEmptyListLabel); - } - } - else { - mLayout->addItem(mListView); + if (!mPopup) { + mPopup = new HbDialog; } - mCntModel->showMyCard(false); + if (!mListView) { + mListView = new HbListView(mPopup); + mListView->setModel(mCntModel); + mListView->setSelectionMode(mSelectionMode); + mListView->setFrictionEnabled(true); + mListView->setScrollingStyle(HbScrollArea::PanWithFollowOn); + mListView->verticalScrollBar()->setInteractive(true); + + HbListViewItem *prototype = mListView->listItemPrototype(); + prototype->setGraphicsSize(HbListViewItem::Thumbnail); + prototype->setStretchingStyle(HbListViewItem::StretchLandscape); + + mIndexFeedback = new HbIndexFeedback(mPopup); + mIndexFeedback->setIndexFeedbackPolicy(HbIndexFeedback::IndexFeedbackSingleCharacter); + mIndexFeedback->setItemView(mListView); + + // Note that the layout takes ownership of the item(s) it contains. + if (!mCntModel->rowCount()) { + mListView->setVisible(false); + if (!mEmptyListLabel) { + mEmptyListLabel = new HbTextItem(hbTrId("txt_phob_info_no_matching_contacts")); + mEmptyListLabel->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); + mEmptyListLabel->setFontSpec(HbFontSpec(HbFontSpec::Primary)); + mEmptyListLabel->setAlignment(Qt::AlignCenter); + mLayout->insertItem(0, mEmptyListLabel); + } + } + else { + mLayout->addItem(mListView); + } + + mCntModel->showMyCard(false); + } } void CntFetchContacts::connectSignal() @@ -322,13 +321,15 @@ } mPopup->setHeadingWidget(mLabel); - if (!mButtonText.isEmpty()) { + if (!mButtonText.isEmpty() && !mPrimaryAction) { mPrimaryAction = new HbAction(hbTrId(mButtonText.toAscii())); mPopup->addAction(mPrimaryAction); } - mSecondaryAction = new HbAction(hbTrId("txt_common_button_cancel")); - mPopup->addAction(mSecondaryAction); + if (!mSecondaryAction) { + mSecondaryAction = new HbAction(hbTrId("txt_common_button_cancel")); + mPopup->addAction(mSecondaryAction); + } mPopup->open(this, SLOT(handleUserResponse(HbAction*))); }