vmbx/vmbxengine/src/vmbxqtuihandler.cpp
changeset 12 ae8abd0db65c
child 19 e44a8c097b15
equal deleted inserted replaced
0:ff3b6d0fd310 12:ae8abd0db65c
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *
       
    16 *
       
    17 */
       
    18 
       
    19 // qt
       
    20 #include <QtGui/QtGui>
       
    21 #include <QString>
       
    22 #include <QObject>
       
    23 
       
    24 #include <hbdialog.h>
       
    25 #include <hblabel.h>
       
    26 #include <hbaction.h>
       
    27 #include <hbtextedit.h>
       
    28 #include <hbmessagebox.h>
       
    29 #include <hbvalidator.h>
       
    30 #include <hblineedit.h>
       
    31 #include <hbinputeditorinterface.h>
       
    32 #include <hblistwidget.h>
       
    33 
       
    34 #include "vmbxqtuihandler.h"
       
    35 #include "voicemailboxdefsinternal.h"
       
    36 #include "vmbxlogger.h"
       
    37 
       
    38 // ======== MEMBER FUNCTIONS ==================================================
       
    39 
       
    40 // ----------------------------------------------------------------------------
       
    41 // VmbxQtUiHandler::VmbxQtUiHandler
       
    42 // (Constructor).
       
    43 // ----------------------------------------------------------------------------
       
    44 //
       
    45 VmbxQtUiHandler::VmbxQtUiHandler(QObject* parent): QObject(parent)
       
    46 {
       
    47     VMBLOGSTRING("VmbxQtUiHandler::VmbxQtUiHandler")
       
    48     VMBLOGSTRING("VmbxQtUiHandler::VmbxQtUiHandler Exit")
       
    49 }
       
    50 
       
    51 // ----------------------------------------------------------------------------
       
    52 // VmbxQtUiHandler::~VmbxQtUiHandler
       
    53 // (Destructor).
       
    54 // ----------------------------------------------------------------------------
       
    55 //
       
    56 VmbxQtUiHandler::~VmbxQtUiHandler()
       
    57 {
       
    58     VMBLOGSTRING("VmbxQtUiHandler::~VmbxQtUiHandler")
       
    59     VMBLOGSTRING("VmbxQtUiHandler::~VmbxQtUiHandler Exit")
       
    60 }
       
    61 
       
    62 // ----------------------------------------------------------------------------
       
    63 // VmbxQtUiHandler::ShowVmbxQueryDialog
       
    64 // (show query dialog).
       
    65 // ----------------------------------------------------------------------------
       
    66 //
       
    67 void VmbxQtUiHandler::showVmbxQueryDialog(const TVmbxType& aType,
       
    68                           const TVmbxQueryMode& aMode,
       
    69                           QString& aNumber, int& aResult)
       
    70 {
       
    71     VMBLOGSTRING("VmbxQtUiHandler::showVmbxQueryDialog")
       
    72 
       
    73     HbDialog *displayPopup = new HbDialog();
       
    74     displayPopup->setDismissPolicy(HbDialog ::NoDismiss);
       
    75     displayPopup->setTimeout(HbDialog ::NoTimeout);
       
    76 
       
    77     displayPopup->setModal(true);
       
    78     QString header;
       
    79     if (EVmbxVoice == aType) {
       
    80         if (EVmbxDefineMode == aMode) {
       
    81             header = tr("Define voice mailbox:");
       
    82         } else {
       
    83             header = tr("Change voice mailbox:");
       
    84         }
       
    85     } else {
       
    86         // type of EVmbxVideo
       
    87         if (EVmbxDefineMode == aMode) {
       
    88             header = tr("Define video mailbox:");
       
    89         } else {
       
    90             header = tr("Change video mailbox:");
       
    91         }
       
    92     }
       
    93     // Set the label as heading widget
       
    94     displayPopup->setHeadingWidget(new HbLabel(header));
       
    95     // Set the HbLineEdit as Content widget
       
    96     // Define parameters for text box
       
    97     HbLineEdit *lineEdit = new HbLineEdit();
       
    98     lineEdit->setText( aNumber ); // default text
       
    99     //lineEdit->setMaximumRows( 3 ); // just a magic number
       
   100     HbEditorInterface inputMode(lineEdit); // Enables VKB
       
   101     inputMode.setInputMode( HbInputModeNumeric );
       
   102     // Limit charachter set
       
   103     HbValidator *val = new HbValidator;
       
   104     QRegExp r;
       
   105     r.setPattern("[0123456789*#+]{0,255}"); // define what characters can be entered
       
   106     val->setMasterValidator(new QRegExpValidator(r,0));
       
   107     lineEdit->setValidator( val );
       
   108 
       
   109     displayPopup->setContentWidget( lineEdit ); // ownership moved
       
   110 
       
   111     HbAction* okAction = new HbAction(tr("Ok"));
       
   112     // Sets the "OK"-action/button
       
   113     displayPopup->setPrimaryAction(okAction);
       
   114     bool ret = connect(okAction, SIGNAL(triggered()),
       
   115         displayPopup, SLOT(close()));
       
   116     VMBLOGSTRING2( "VmbxQtUiHandler::showVmbxQueryDialog:connect ok %d",
       
   117         ret )
       
   118     //  Sets the "Back"-action/button
       
   119     HbAction* cancelAction =  new HbAction(tr("Cancel"));
       
   120     displayPopup->setSecondaryAction(cancelAction);
       
   121     ret = connect(okAction, SIGNAL(triggered()),
       
   122         displayPopup, SLOT(close()));
       
   123     VMBLOGSTRING2( "VmbxQtUiHandler::showVmbxQueryDialog:connect cancel %d",
       
   124         ret )
       
   125     VMBLOGSTRING( "VmbxQtUiHandler::ShowVmbxQueryDialog to show" )
       
   126     HbAction* result = displayPopup->exec();
       
   127     if( okAction == result ) {
       
   128         VMBLOGSTRING( "VmbxQtUiHandler::showVmbxQueryDialog select OK" )
       
   129         // asign OK KEY value
       
   130         aResult = KErrNone;
       
   131         aNumber = lineEdit->text();
       
   132         VMBLOGSTRING2( "VmbxQtUiHandler::showVmbxQueryDialog number = %s",
       
   133             aNumber.utf16() )
       
   134     } else {
       
   135         aResult = KErrCancel;
       
   136     }
       
   137     delete val;
       
   138     val = 0;
       
   139     delete displayPopup;
       
   140     displayPopup = 0;
       
   141     VMBLOGSTRING2("VmbxQtUiHandler::showVmbxQueryDialog aResult = %d", aResult)
       
   142     VMBLOGSTRING("VmbxQtUiHandler::showVmbxQueryDialog Exit")
       
   143 }
       
   144 
       
   145 // ----------------------------------------------------------------------------
       
   146 // VmbxQtUiHandler::showDefineSelectionDialog
       
   147 // (Shoe define list dialog).
       
   148 // ----------------------------------------------------------------------------
       
   149 //
       
   150 void VmbxQtUiHandler::showDefineSelectionDialog(
       
   151     TVmbxType& aType, int& aResult)
       
   152 {
       
   153     VMBLOGSTRING("VmbxQtUiHandler::showDefineSelectionDialog")
       
   154     HbDialog* defineListDialog = new HbDialog();
       
   155     defineListDialog->setDismissPolicy(HbDialog::NoDismiss);
       
   156     defineListDialog->setTimeout(HbDialog::NoTimeout);
       
   157 
       
   158     defineListDialog->setModal(true);
       
   159     // Set heading widget
       
   160     defineListDialog->setHeadingWidget(new HbLabel(tr("Define number:")));
       
   161     // Create a define list 
       
   162     HbListWidget *list = new HbListWidget();
       
   163     list->addItem(tr("Voice Mailbox"));
       
   164     list->addItem(tr("Video Mailbox"));
       
   165     // Set content widget
       
   166     defineListDialog->setContentWidget(list);
       
   167 
       
   168     HbAction* okAction = new HbAction(tr("Ok"));
       
   169     // Sets the "OK"-action/button
       
   170     defineListDialog->setPrimaryAction(okAction);
       
   171     //  Sets the "Back"-action/button
       
   172     HbAction* cancelAction =  new HbAction(tr("Cancel"));
       
   173     defineListDialog->setSecondaryAction(cancelAction);
       
   174 
       
   175     connect(list, SIGNAL(activated(HbListWidgetItem*)), 
       
   176         defineListDialog, SLOT(close()));
       
   177     HbAction* result = defineListDialog->exec();
       
   178 
       
   179     if (cancelAction == result){
       
   180         aType = EVmbxNone;
       
   181         aResult = KErrCancel;
       
   182     } else {
       
   183     // OK or single click items
       
   184         aResult = KErrNone;
       
   185         int currentItem = list->row(list->currentItem());
       
   186         VMBLOGSTRING2("VmbxQtUiHandler::showDefineSelectionDialog:\
       
   187             currentItem %d", currentItem)
       
   188         if (0 == currentItem) {
       
   189             aType = EVmbxVoice;
       
   190         } else {
       
   191             aType = EVmbxVideo;
       
   192         }
       
   193     }
       
   194     VMBLOGSTRING2("VmbxQtUiHandler::showDefineSelectionDialog: aType%d", aType)
       
   195     VMBLOGSTRING2("VmbxQtUiHandler::showDefineSelectionDialog: aResult%d", \
       
   196         aResult)
       
   197     delete defineListDialog;
       
   198     defineListDialog = 0;
       
   199     VMBLOGSTRING("VmbxQtUiHandler::showDefineSelectionDialog Exit")
       
   200 }
       
   201 // ----------------------------------------------------------------------------
       
   202 // VmbxQtUiHandler::ShowInformationNote
       
   203 // (show information note).
       
   204 // ----------------------------------------------------------------------------
       
   205 //
       
   206 void VmbxQtUiHandler::showInformationNote(int aNoteType)
       
   207 {
       
   208     VMBLOGSTRING("VmbxQtUiHandler::showInformationNote")
       
   209     QString noteText;
       
   210     QString iconName;
       
   211     VMBLOGSTRING2("VmbxQtUiHandler::~showInformationNote type =%d", aNoteType)
       
   212     switch (aNoteType) {
       
   213     case EInvalidNumber:
       
   214         noteText = tr("Invalid phone number.");
       
   215         iconName = "note_error";
       
   216         break;
       
   217     case ESavedToPhoneMemory:
       
   218         noteText = tr("Voice mailbox number saved to Phone memory.");
       
   219         iconName = "note_info";
       
   220         break;
       
   221     case ESavedToSimMemory:
       
   222         noteText = tr("Voice mailbox number saved to Sim card.");
       
   223         iconName = "note_info";
       
   224         break;
       
   225     case EVideoNumberSaved:
       
   226         noteText = tr("Video call mailbox saved.");
       
   227         iconName = "note_info";
       
   228         break;
       
   229     default:
       
   230         VMBLOGSTRING("VmbxQtUiHandler::ShowInformationNote default")
       
   231         break;
       
   232     }
       
   233 
       
   234     HbMessageBox *msgBox = new HbMessageBox(HbMessageBox::MessageTypeInformation);
       
   235     msgBox->setText(noteText);
       
   236     msgBox->setIcon(HbIcon(iconName));
       
   237     msgBox->exec();
       
   238     delete msgBox;
       
   239     VMBLOGSTRING("VmbxQtUiHandler::~ShowInformationNote Exit")
       
   240     
       
   241 }
       
   242 
       
   243 // ----------------------------------------------------------------------------
       
   244 // VmbxQtUiHandler::ShowSaveEmptyNote
       
   245 // (show information note).
       
   246 // ----------------------------------------------------------------------------
       
   247 //
       
   248 void VmbxQtUiHandler::showSaveEmptyNote(const TVmbxType& aType)
       
   249 {
       
   250     VMBLOGSTRING("VmbxQtUiHandler::~showSaveEmptyNote")
       
   251     QString noteText;
       
   252     VMBLOGSTRING2("VmbxQtUiHandler::~showSaveEmptyNote type = %d", aType)
       
   253     switch (aType) {
       
   254     case EVmbxVoice:
       
   255         noteText = tr("Voice mailbox number not defined.");
       
   256         break;
       
   257     case EVmbxVideo:
       
   258         noteText = tr("Video mailbox number not defined.");
       
   259         break;
       
   260     default:
       
   261         VMBLOGSTRING("VmbxQtUiHandler::ShowSaveEmptyNote default")
       
   262         break;
       
   263     }
       
   264     HbMessageBox *msgBox = new HbMessageBox(HbMessageBox::MessageTypeInformation);
       
   265     msgBox->setText(noteText);
       
   266     msgBox->setIcon(HbIcon("note_error"));
       
   267     msgBox->exec();
       
   268     delete msgBox;
       
   269     VMBLOGSTRING("VmbxQtUiHandler::~ShowSaveEmptyNote Exit")
       
   270 }
       
   271 
       
   272 //End of file