diff -r 6bb1b21d2484 -r 2f8f8080a020 phonesettings/cpphonesettingsplugins/cptelephonyutils/src/cpphonenotes.cpp --- a/phonesettings/cpphonesettingsplugins/cptelephonyutils/src/cpphonenotes.cpp Fri Apr 16 14:58:25 2010 +0300 +++ b/phonesettings/cpphonesettingsplugins/cptelephonyutils/src/cpphonenotes.cpp Mon May 03 12:31:11 2010 +0300 @@ -28,6 +28,10 @@ #include #include #include +#include +#include +#include +#include /*! CpPhoneNotes::instance. @@ -48,10 +52,12 @@ CpPhoneNotes::CpPhoneNotes(): QObject(NULL), m_notesQueue(NULL), - m_isNoteShowingOngoing(false) + m_isNoteShowingOngoing(false), + m_passwordDialog(NULL), + m_passwordValidator(NULL) { DPRINT << ": IN"; - + m_notesQueue = new QQueue(); m_cpSettingsWrapper = new CpSettingsWrapper; @@ -167,7 +173,7 @@ serviceListPopup->setContentWidget(serviceList.take()); HbAction *backAction = - new HbAction(hbTrId("Back"), serviceListPopup.data()); + new HbAction(hbTrId("txt_common_button_back"), serviceListPopup.data()); serviceListPopup->setPrimaryAction(backAction); serviceListPopup->exec(); @@ -175,85 +181,6 @@ } /*! - CpPhoneNotes::showBasicServiceCallDivertList. - */ -void CpPhoneNotes::showBasicServiceCallDivertList( - const QString &title, - const QList &divertStatuses, - int &selectionIndex, - CallDivertType divertType, - CallDivertType &divertDetailType) -{ - DPRINT << ": IN"; - - Q_ASSERT(title != ""); - Q_ASSERT(0 < divertStatuses.size()); - - HbDialog *serviceListPopup = new HbDialog(); - serviceListPopup->setDismissPolicy(HbDialog::NoDismiss); - serviceListPopup->setTimeout(HbPopup::NoTimeout); - - HbLabel *heading = new HbLabel(title, serviceListPopup); - heading->setAlignment(Qt::AlignLeft | Qt::AlignTop); - serviceListPopup->setHeadingWidget(heading); - - HbListView *serviceList = new HbListView(serviceListPopup); - QStandardItemModel *serviceListModel = new QStandardItemModel(serviceList); - for (int i = 0; i < divertStatuses.size(); i++) { - PSCallDivertingStatus *divertStatus = divertStatuses.at(i); - QString groupName = - basicServiceGroupName( - convertEtelMobileServiceCode(divertStatus->iServiceGroup) ); - QStandardItem *listItem = new QStandardItem(groupName); - serviceListModel->appendRow(listItem); - } - serviceList->setModel(serviceListModel); - serviceList->setSelectionMode(HbAbstractItemView::SingleSelection); - if (0 != serviceListModel->rowCount()) { - QModelIndex firstItem = serviceList->nextIndex(QModelIndex()); - serviceList->setCurrentIndex(firstItem, QItemSelectionModel::Select); - } - serviceListPopup->setContentWidget(serviceList); - - HbAction *backAction = new HbAction(hbTrId("Back"), serviceListPopup); - HbAction *numberQueryAction = new HbAction(hbTrId("Number"), serviceListPopup); - HbAction *detailsAction = new HbAction(hbTrId("Details"), serviceListPopup); - serviceListPopup->setSecondaryAction(backAction); - - switch (divertType) { - case NoCallDivert: - break; - case CallDivertWithNumber: - serviceListPopup->setPrimaryAction(numberQueryAction); - break; - case CallDivertWithNumberAndTimeout: - serviceListPopup->setPrimaryAction(detailsAction); - break; - default: - DPRINT << ", DEFAULT"; - Q_ASSERT(false); - break; - } - - HbAction *userAction = serviceListPopup->exec(); - if (userAction == numberQueryAction) { - divertDetailType = CallDivertWithNumber; - } else if (userAction == detailsAction) { - divertDetailType = CallDivertWithNumberAndTimeout; - } else if (userAction == backAction) { - divertDetailType = NoCallDivert; - } else { - DPRINT << ", WEIRD ACTION"; - Q_ASSERT(false); - } - - selectionIndex = serviceList->currentIndex().row(); - delete serviceListPopup; - - DPRINT << ": OUT"; -} - -/*! CpPhoneNotes::cancelNote. */ void CpPhoneNotes::cancelNote(int noteId) @@ -297,30 +224,6 @@ } /*! - CpPhoneNotes::activeNoteAboutToClose. - */ -void CpPhoneNotes::activeNoteAboutToClose() -{ - DPRINT << ": IN"; - - if (m_isNoteShowingOngoing) { - m_isNoteShowingOngoing = false; - QObject* note(NULL); - if (!m_notesQueue->isEmpty()) { - note = m_notesQueue->dequeue(); - } - if(note) { - launchNextNoteIfReady(); - note->disconnect(this); - DPRINT << ", delete note: " << reinterpret_cast(note); - note->deleteLater(); - } - } - - DPRINT << ": OUT"; -} - -/*! CpPhoneNotes::basicServiceGroupName. Resolves basic service group name by group identifier. */ @@ -392,15 +295,6 @@ } /*! - CpPhoneNotes::convertEtelMobileServiceCode. -*/ -BasicServiceGroups CpPhoneNotes::convertEtelMobileServiceCode(int serviceCode) const -{ - DPRINT << "serviceCode: " << serviceCode; - return Tools::convertEtelMobileServiceCode(serviceCode); -} - -/*! CpPhoneNotes::showGlobalErrorNote. */ void CpPhoneNotes::showGlobalErrorNote(int ¬eId, int errorcode) @@ -439,15 +333,15 @@ // TODO: Orbit layout support is insufficient currently and all text // is not shown. QString content = ""; - content.append(hbTrId("To number: ")); + content.append(hbTrId("txt_phone_info_number")); content.append(formatPhoneNumber(divertStatus.iNumber)); if (0 < divertStatus.iTimeout) { - content.append(hbTrId(" Delay time: ")); + content.append(hbTrId("txt_phone_setlabel_delay")); content.append(QString::number(divertStatus.iTimeout)); content.append(hbTrId(" seconds")); } divertInfo->setText(content); - HbAction *backAction = new HbAction(hbTrId("Back"), divertInfo); + HbAction *backAction = new HbAction(hbTrId("txt_common_button_back"), divertInfo); divertInfo->setPrimaryAction(backAction); divertInfo->exec(); delete divertInfo; @@ -456,6 +350,55 @@ } /*! + CpPhoneNotes::showPasswordQueryDialog. + */ +void CpPhoneNotes::showPasswordQueryDialog( + const QString &title, + const QValidator &validator, + int maxPasswordLength, + QString &password, + bool &ok) +{ + DPRINT << ": IN"; + + QScopedPointer passwordDialog(new HbInputDialog()); + + // configure editor so that only digits can be inputted + passwordDialog->setPromptText(title); + passwordDialog->setEchoMode(HbLineEdit::Password); + passwordDialog->setInputMethodHints(Qt::ImhDigitsOnly); + HbLineEdit *hbLineEdit = passwordDialog->lineEdit(); + hbLineEdit->setMaxLength(maxPasswordLength); + HbEditorInterface editorInterface(hbLineEdit); + editorInterface.setInputMode(HbInputModeNumeric); + editorInterface.setConstraints(HbEditorConstraintFixedInputMode); + editorInterface.setFilter(HbDigitsOnlyFilter::instance()); + + m_passwordDialog = passwordDialog.data(); + m_passwordValidator = &validator; + passwordDialog->primaryAction()->setEnabled(false); + connect( + hbLineEdit, SIGNAL(contentsChanged()), + this, SLOT(passwordTextChanged())); + + HbAction* action = passwordDialog->exec(); + if (action == passwordDialog->secondaryAction()) { + ok = false; + } else { + ok = true; + password = passwordDialog->value().toString(); + } + + m_passwordDialog = NULL; + m_passwordValidator = NULL; + disconnect( + hbLineEdit, SIGNAL(contentsChanged()), + this, SLOT(passwordTextChanged())); + + DPRINT << ": OUT"; +} + +/*! CpPhoneNotes::formatPhoneNumber. Formats phone number according to locale specific rules. */ @@ -511,6 +454,29 @@ DPRINT << ": OUT"; } +/*! + CpPhoneNotes::activeNoteAboutToClose. + */ +void CpPhoneNotes::activeNoteAboutToClose() +{ + DPRINT << ": IN"; + + if (m_isNoteShowingOngoing) { + m_isNoteShowingOngoing = false; + QObject* note(NULL); + if (!m_notesQueue->isEmpty()) { + note = m_notesQueue->dequeue(); + } + if(note) { + launchNextNoteIfReady(); + note->disconnect(this); + DPRINT << ", delete note: " << reinterpret_cast(note); + note->deleteLater(); + } + } + + DPRINT << ": OUT"; +} /*! CpPhoneNotes::handleProgressNoteCanceled(). @@ -524,4 +490,23 @@ DPRINT << ": OUT"; } +/*! + CpPhoneNotes::passwordTextChanged(). + */ +void CpPhoneNotes::passwordTextChanged() +{ + DPRINT << ": IN"; + Q_ASSERT(m_passwordDialog && m_passwordValidator); + + HbLineEdit *hbLineEdit = m_passwordDialog->lineEdit(); + int position = 0; + QString password = hbLineEdit->text(); + bool isPasswordValid = + (QValidator::Acceptable == m_passwordValidator->validate( + password, position)); + m_passwordDialog->primaryAction()->setEnabled(isPasswordValid); + + DPRINT << ": OUT"; +} + // End of File.