phonesettings/cpphonesettingsplugins/cptelephonyutils/src/cpphonenotes.cpp
changeset 30 ebdbd102c78a
parent 27 2f8f8080a020
child 51 f39ed5e045e0
equal deleted inserted replaced
27:2f8f8080a020 30:ebdbd102c78a
    55      m_isNoteShowingOngoing(false),
    55      m_isNoteShowingOngoing(false),
    56      m_passwordDialog(NULL),
    56      m_passwordDialog(NULL),
    57      m_passwordValidator(NULL)
    57      m_passwordValidator(NULL)
    58     {
    58     {
    59     DPRINT << ": IN";
    59     DPRINT << ": IN";
    60     
    60 
    61     m_notesQueue = new QQueue<QObject*>();
    61     m_notesQueue = new QQueue<QObject*>();
    62     m_cpSettingsWrapper = new CpSettingsWrapper;
    62     m_cpSettingsWrapper = new CpSettingsWrapper;
    63     
    63     
    64     DPRINT << ": OUT";
    64     DPRINT << ": OUT";
    65     }
    65     }
    75     QObject* note(NULL);
    75     QObject* note(NULL);
    76     foreach (note, *m_notesQueue) {
    76     foreach (note, *m_notesQueue) {
    77         delete note;
    77         delete note;
    78     }
    78     }
    79     delete m_notesQueue;
    79     delete m_notesQueue;
       
    80     if(m_passwordDialog) {
       
    81         delete m_passwordDialog;
       
    82     }
       
    83         
    80     
    84     
    81     DPRINT << ": OUT";
    85     DPRINT << ": OUT";
    82 }
    86 }
    83 
    87 
    84 /*!
    88 /*!
    90     DPRINT << ": IN";
    94     DPRINT << ": IN";
    91     
    95     
    92     HbDeviceProgressDialog *note = 
    96     HbDeviceProgressDialog *note = 
    93         new HbDeviceProgressDialog(HbProgressDialog::WaitDialog, this);
    97         new HbDeviceProgressDialog(HbProgressDialog::WaitDialog, this);
    94     note->setText(text);
    98     note->setText(text);
       
    99     QAction *action = new QAction(hbTrId("txt_common_button_hide"), this);
       
   100     //Ownership of action is not transferred. Deleted when note closes.
       
   101     note->setAction(action, HbDeviceProgressDialog::CancelButtonRole );
    95     noteId = reinterpret_cast<int>(note);
   102     noteId = reinterpret_cast<int>(note);
    96     DPRINT << ", NOTEID: " << noteId;
   103     DPRINT << ", NOTEID: " << noteId;
    97     QObject::connect(
   104     QObject::connect(
    98         note, SIGNAL(aboutToClose()),
   105         note, SIGNAL(aboutToClose()),
    99         this, SLOT(activeNoteAboutToClose()));
   106         this, SLOT(activeNoteAboutToClose()));
   173     serviceListPopup->setContentWidget(serviceList.take());
   180     serviceListPopup->setContentWidget(serviceList.take());
   174     
   181     
   175     HbAction *backAction = 
   182     HbAction *backAction = 
   176         new HbAction(hbTrId("txt_common_button_back"), serviceListPopup.data());
   183         new HbAction(hbTrId("txt_common_button_back"), serviceListPopup.data());
   177     serviceListPopup->setPrimaryAction(backAction);
   184     serviceListPopup->setPrimaryAction(backAction);
   178     serviceListPopup->exec();
   185     
       
   186     HbDialog *serviceListPopupDialog = serviceListPopup.take();
       
   187     QObject::connect(
       
   188         serviceListPopupDialog, SIGNAL(finished(HbAction*)), 
       
   189         serviceListPopupDialog, SLOT(deleteLater()));
       
   190     serviceListPopupDialog->show();
   179     
   191     
   180     DPRINT << ": OUT";
   192     DPRINT << ": OUT";
   181 }
   193 }
   182 
   194 
   183 /*!
   195 /*!
   193             int index = m_notesQueue->indexOf(reinterpret_cast<QObject *>(noteId));
   205             int index = m_notesQueue->indexOf(reinterpret_cast<QObject *>(noteId));
   194             Q_ASSERT(-1 < index);
   206             Q_ASSERT(-1 < index);
   195             QObject *note = m_notesQueue->at(index);
   207             QObject *note = m_notesQueue->at(index);
   196             DPRINT << ": NOTEID: " << noteId;
   208             DPRINT << ": NOTEID: " << noteId;
   197             if (qobject_cast<HbDeviceProgressDialog *>(note)) {
   209             if (qobject_cast<HbDeviceProgressDialog *>(note)) {
   198               //  QObject::disconnect(
   210                 static_cast<HbDeviceProgressDialog *>(note)->close();
   199                 //    note, SIGNAL(cancelled()),
       
   200                   //  this, SLOT(ProgresNoteCanceled()));
       
   201                 static_cast<HbDeviceProgressDialog *>(note)->cancel();
       
   202             } else if (qobject_cast<HbDeviceMessageBox *>(note)) {
   211             } else if (qobject_cast<HbDeviceMessageBox *>(note)) {
   203                 static_cast<HbDeviceMessageBox *>(note)->close();
   212                 static_cast<HbDeviceMessageBox *>(note)->close();
   204             } else {
   213             } else {
   205                 DPRINT << ", UNKNOWN NOTE";
   214                 DPRINT << ", UNKNOWN NOTE";
   206                 Q_ASSERT(false);
   215                 Q_ASSERT(false);
   324 void CpPhoneNotes::showCallDivertDetails(
   333 void CpPhoneNotes::showCallDivertDetails(
   325     const PSCallDivertingStatus &divertStatus)
   334     const PSCallDivertingStatus &divertStatus)
   326 {
   335 {
   327     DPRINT << ": IN";
   336     DPRINT << ": IN";
   328     
   337     
   329     HbMessageBox *divertInfo = 
   338     QScopedPointer<HbMessageBox> divertInfoScopedPointer(
   330             new HbMessageBox(HbMessageBox::MessageTypeInformation);
   339         new HbMessageBox(HbMessageBox::MessageTypeInformation));
   331     divertInfo->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
   340     divertInfoScopedPointer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
   332     
   341     
   333     // TODO: Orbit layout support is insufficient currently and all text
   342     // TODO: Orbit layout support is insufficient currently and all text
   334     // is not shown.
   343     // is not shown.
   335     QString content = "";
   344     QString content = "";
   336     content.append(hbTrId("txt_phone_info_number"));
   345     content.append(hbTrId("txt_phone_info_number"));
   338     if (0 < divertStatus.iTimeout) {
   347     if (0 < divertStatus.iTimeout) {
   339         content.append(hbTrId("txt_phone_setlabel_delay"));
   348         content.append(hbTrId("txt_phone_setlabel_delay"));
   340         content.append(QString::number(divertStatus.iTimeout));
   349         content.append(QString::number(divertStatus.iTimeout));
   341         content.append(hbTrId(" seconds"));
   350         content.append(hbTrId(" seconds"));
   342     }
   351     }
   343     divertInfo->setText(content);
   352     divertInfoScopedPointer->setText(content);
   344     HbAction *backAction = new HbAction(hbTrId("txt_common_button_back"), divertInfo);
   353     HbAction *backAction = new HbAction(
   345     divertInfo->setPrimaryAction(backAction);
   354         hbTrId("txt_common_button_back"), 
   346     divertInfo->exec();
   355         divertInfoScopedPointer.data());
   347     delete divertInfo;
   356     divertInfoScopedPointer->setPrimaryAction(backAction);
       
   357     
       
   358     HbMessageBox *divertInfo = divertInfoScopedPointer.take();
       
   359     QObject::connect(
       
   360             divertInfo, SIGNAL(finished(HbAction*)), 
       
   361             divertInfo, SLOT(deleteLater()));
       
   362     divertInfo->show();
   348     
   363     
   349     DPRINT << ": OUT";
   364     DPRINT << ": OUT";
   350 }
   365 }
   351 
   366 
   352 /*!
   367 /*!
   353   CpPhoneNotes::showPasswordQueryDialog.
   368   CpPhoneNotes::showPasswordQueryDialog.
   354  */
   369  */
   355 void CpPhoneNotes::showPasswordQueryDialog(
   370 void CpPhoneNotes::showPasswordQueryDialog(
   356     const QString &title, 
   371     const QString &title, 
   357     const QValidator &validator,
   372     const QValidator &validator,
   358     int maxPasswordLength,
   373     int maxPasswordLength)
   359     QString &password, 
       
   360     bool &ok)
       
   361 {
   374 {
   362     DPRINT << ": IN";
   375     DPRINT << ": IN";
   363     
   376     
   364     QScopedPointer<HbInputDialog> passwordDialog(new HbInputDialog());
   377     QScopedPointer<HbInputDialog> passwordDialog(new HbInputDialog());
   365     
   378     
   368     passwordDialog->setEchoMode(HbLineEdit::Password);
   381     passwordDialog->setEchoMode(HbLineEdit::Password);
   369     passwordDialog->setInputMethodHints(Qt::ImhDigitsOnly);
   382     passwordDialog->setInputMethodHints(Qt::ImhDigitsOnly);
   370     HbLineEdit *hbLineEdit = passwordDialog->lineEdit();
   383     HbLineEdit *hbLineEdit = passwordDialog->lineEdit();
   371     hbLineEdit->setMaxLength(maxPasswordLength);
   384     hbLineEdit->setMaxLength(maxPasswordLength);
   372     HbEditorInterface editorInterface(hbLineEdit);
   385     HbEditorInterface editorInterface(hbLineEdit);
   373     editorInterface.setInputMode(HbInputModeNumeric);
   386     
   374     editorInterface.setConstraints(HbEditorConstraintFixedInputMode);
   387     editorInterface.setMode(HbInputModeNumeric);
       
   388     editorInterface.setInputConstraints(HbEditorConstraintFixedInputMode);
       
   389     
   375     editorInterface.setFilter(HbDigitsOnlyFilter::instance());
   390     editorInterface.setFilter(HbDigitsOnlyFilter::instance());
   376     
   391     
   377     m_passwordDialog = passwordDialog.data();
       
   378     m_passwordValidator = &validator;
   392     m_passwordValidator = &validator;
   379     passwordDialog->primaryAction()->setEnabled(false);
   393     passwordDialog->primaryAction()->setEnabled(false);
   380     connect(
   394     connect(
   381         hbLineEdit, SIGNAL(contentsChanged()), 
   395         hbLineEdit, SIGNAL(contentsChanged()), 
   382         this, SLOT(passwordTextChanged()));
   396         this, SLOT(passwordTextChanged()));
   383     
   397     
   384     HbAction* action = passwordDialog->exec();
   398     passwordDialog->open(this, SLOT(finishedPasswordQueryDialog(HbAction*)));
   385     if (action == passwordDialog->secondaryAction()) {
   399 	if(m_passwordDialog) {
   386         ok = false;
   400 		m_passwordDialog->deleteLater();
   387     } else {
   401 		m_passwordDialog = NULL;
   388         ok = true;
   402 	}
   389         password = passwordDialog->value().toString();
   403     m_passwordDialog = passwordDialog.take();
   390     }
   404         
   391     
   405     DPRINT << ": OUT";
   392     m_passwordDialog = NULL;
   406 }
   393     m_passwordValidator = NULL;
   407 
   394     disconnect(
   408 /*!
   395         hbLineEdit, SIGNAL(contentsChanged()), 
   409   CpPhoneNotes::finishedPasswordQueryDialog.
   396         this, SLOT(passwordTextChanged()));
   410  */
   397     
   411 void CpPhoneNotes::finishedPasswordQueryDialog(HbAction* action)
   398     DPRINT << ": OUT";
   412 {
       
   413     bool ok;
       
   414     QString password;
       
   415     if(m_passwordDialog) {
       
   416         if (action == m_passwordDialog->secondaryAction()) {
       
   417             ok = false;
       
   418         } else {
       
   419             ok = true;
       
   420             password = m_passwordDialog->value().toString();
       
   421         }
       
   422         
       
   423         disconnect(
       
   424             m_passwordDialog->lineEdit(), SIGNAL(contentsChanged()), 
       
   425             this, SLOT(passwordTextChanged()));
       
   426         
       
   427         m_passwordDialog->deleteLater();
       
   428         m_passwordDialog = NULL;
       
   429         m_passwordValidator = NULL;
       
   430         
       
   431         emit passwordQueryCompleted(password, ok);
       
   432     }
   399 }
   433 }
   400 
   434 
   401 /*!
   435 /*!
   402   CpPhoneNotes::formatPhoneNumber.
   436   CpPhoneNotes::formatPhoneNumber.
   403   Formats phone number according to locale specific rules.
   437   Formats phone number according to locale specific rules.
   440         if (qobject_cast<HbDeviceProgressDialog *>(note)) {
   474         if (qobject_cast<HbDeviceProgressDialog *>(note)) {
   441             DPRINT << ", show HbDeviceProgressDialog";
   475             DPRINT << ", show HbDeviceProgressDialog";
   442             static_cast<HbDeviceProgressDialog *>(note)->show();
   476             static_cast<HbDeviceProgressDialog *>(note)->show();
   443         } else if (qobject_cast<HbDeviceMessageBox *>(note)) {
   477         } else if (qobject_cast<HbDeviceMessageBox *>(note)) {
   444             DPRINT << ", show HbDeviceMessageBox";    
   478             DPRINT << ", show HbDeviceMessageBox";    
   445             static_cast<HbDeviceMessageBox *>(note)->exec();
   479             static_cast<HbDeviceMessageBox *>(note)->show();
   446         } else {
   480         } else {
   447             DPRINT << ", UNKNOWN NOTE";
   481             DPRINT << ", UNKNOWN NOTE";
   448             Q_ASSERT(false);
   482             Q_ASSERT(false);
   449         }
   483         }
   450     } else {
   484     } else {
   469         }
   503         }
   470         if(note) {
   504         if(note) {
   471             launchNextNoteIfReady();
   505             launchNextNoteIfReady();
   472             note->disconnect(this);
   506             note->disconnect(this);
   473             DPRINT << ", delete note: " << reinterpret_cast<int>(note);
   507             DPRINT << ", delete note: " << reinterpret_cast<int>(note);
       
   508             HbDeviceProgressDialog *pNote = 
       
   509                 qobject_cast<HbDeviceProgressDialog *>(note);
       
   510             if(pNote){
       
   511                 delete pNote->action();
       
   512             }
   474             note->deleteLater();
   513             note->deleteLater();
   475         }
   514         }
   476     }
   515     }
   477     
   516     
   478     DPRINT << ": OUT";
   517     DPRINT << ": OUT";