emailuis/nmailui/src/nmrecipientfield.cpp
changeset 74 6c59112cfd31
parent 68 83cc6bae1de8
equal deleted inserted replaced
69:4e54af54a4a1 74:6c59112cfd31
    31     QObject(parent),
    31     QObject(parent),
    32     mDocumentLoader(docLoader),
    32     mDocumentLoader(docLoader),
    33     mObjectPrefix(objPrefix),
    33     mObjectPrefix(objPrefix),
    34     mLabel(NULL),
    34     mLabel(NULL),
    35     mRecipientsEditor(NULL),
    35     mRecipientsEditor(NULL),
    36     mLaunchContactsPickerButton(NULL)
    36     mLaunchContactsPickerButton(NULL),
       
    37     mAiwRequest(NULL)
       
    38     
    37 {
    39 {
    38     NM_FUNCTION;
    40     NM_FUNCTION;
    39 
    41 
    40     // Load the widgets from nmeditorview.docml. The names match to the definitions in that docml.
    42     // Load the widgets from nmeditorview.docml. The names match to the definitions in that docml.
    41     mWidget = qobject_cast<HbWidget *>
    43     mWidget = qobject_cast<HbWidget *>
    71     connect(mRecipientsEditor, SIGNAL(cursorPositionChanged(int, int)),
    73     connect(mRecipientsEditor, SIGNAL(cursorPositionChanged(int, int)),
    72         this, SIGNAL(cursorPositionChanged(int, int)));
    74         this, SIGNAL(cursorPositionChanged(int, int)));
    73     connect(mRecipientsEditor, SIGNAL(editingFinished()),
    75     connect(mRecipientsEditor, SIGNAL(editingFinished()),
    74         this, SIGNAL(editingFinished()));
    76         this, SIGNAL(editingFinished()));
    75     connect(mRecipientsEditor, SIGNAL(selectionChanged()),
    77     connect(mRecipientsEditor, SIGNAL(selectionChanged()),
    76         this, SIGNAL(selectionChanged()));
    78         this, SIGNAL(launchContactsPicker()));
    77     connect(mLaunchContactsPickerButton, SIGNAL(clicked()),
    79     connect(mLaunchContactsPickerButton, SIGNAL(clicked()),
    78         this, SIGNAL(launchContactsPickerButtonClicked()));
    80         this, SLOT(launchContactsPicker()));
    79     connect(mLaunchContactsPickerButton, SIGNAL(clicked()),
       
    80         this, SLOT(launchContactsPicker()), Qt::QueuedConnection);
       
    81 }
    81 }
    82 
    82 
    83 
    83 
    84 /*!
    84 /*!
    85    Destructor
    85    Destructor
    86 */
    86 */
    87 NmRecipientField::~NmRecipientField()
    87 NmRecipientField::~NmRecipientField()
    88 {
    88 {
    89     NM_FUNCTION;
    89     NM_FUNCTION;
       
    90     delete mAiwRequest;
    90 }
    91 }
    91 
    92 
    92 /*!
    93 /*!
    93    Widget height
    94    Widget height
    94 */
    95 */
   107     NM_FUNCTION;
   108     NM_FUNCTION;
   108 
   109 
   109     return mRecipientsEditor;
   110     return mRecipientsEditor;
   110 }
   111 }
   111 
   112 
       
   113 /*!
       
   114    Label widget
       
   115 */
       
   116 HbLabel *NmRecipientField::label() const
       
   117 {
       
   118     NM_FUNCTION;
       
   119     
       
   120     return mLabel;
       
   121 }
   112 
   122 
   113 /*!
   123 /*!
   114    LineEdit contents
   124    LineEdit contents
   115 */
   125 */
   116 const QString NmRecipientField::text() const
   126 const QString NmRecipientField::text() const
   140 */
   150 */
   141 void NmRecipientField::launchContactsPicker()
   151 void NmRecipientField::launchContactsPicker()
   142 {
   152 {
   143     NM_FUNCTION;
   153     NM_FUNCTION;
   144 
   154 
   145     XQApplicationManager mAppmgr;
   155     if (!mAiwRequest) {
   146     XQAiwRequest *launchContactsPickerRequest;
   156         XQApplicationManager mAppmgr;
   147 
   157         
   148     bool isEmbeded = true;
   158     
   149     launchContactsPickerRequest = mAppmgr.create(NmContactsServiceName, NmContactsInterfaceName,
   159         bool isEmbeded = true;
   150                                                  NmContactsOperationName, isEmbeded);
   160         mAiwRequest = mAppmgr.create(NmContactsServiceName, NmContactsInterfaceName,
   151 
   161                                                      NmContactsOperationName, isEmbeded);
   152     if (launchContactsPickerRequest) {
   162         
   153         connect(launchContactsPickerRequest, SIGNAL(requestOk(QVariant)),
   163         if (mAiwRequest) {
   154                 mRecipientsEditor, SLOT(addSelectedContacts(QVariant)));
   164             connect(mAiwRequest, SIGNAL(requestOk(QVariant)),
       
   165                     mRecipientsEditor, SLOT(addSelectedContacts(QVariant)));
       
   166             connect(mAiwRequest, SIGNAL(requestOk(QVariant)),
       
   167                            this, SLOT(requestCompleted()));
       
   168             connect(mAiwRequest, SIGNAL(requestError(int, QString &)),
       
   169                            this, SLOT(requestCompleted()));
       
   170             mAiwRequest->setSynchronous(false);
       
   171         }
       
   172         else {
       
   173             // Failed creating request
       
   174             NM_ERROR(1,"XQApplicationManager: failed creating fecth contactspicker request");
       
   175             return;
       
   176         }
       
   177     
       
   178         QVariantList args;
       
   179         args << hbTrId("txt_mail_select_contacts");
       
   180         args << KCntActionEmail;
       
   181         mAiwRequest->setArguments(args);
       
   182         
       
   183         // Send request
       
   184         if (!mAiwRequest->send()) {
       
   185            //Failed sending request
       
   186            NM_ERROR(1,"XQApplicationManager: failed sending request");
       
   187         }
   155     }
   188     }
   156     else {
       
   157         // Failed creating request
       
   158         NM_ERROR(1,"XQApplicationManager: failed creating fecth contactspicker request");
       
   159 	    return;
       
   160     }
       
   161 
       
   162     QVariantList args;
       
   163     args << hbTrId("txt_mail_select_contacts");
       
   164     args << KCntActionEmail;
       
   165     launchContactsPickerRequest->setArguments(args);
       
   166 
       
   167     // Send request
       
   168     if (!launchContactsPickerRequest->send()) {
       
   169        //Failed sending request
       
   170        NM_ERROR(1,"XQApplicationManager: failed sending request");
       
   171     }
       
   172 
       
   173     delete launchContactsPickerRequest;
       
   174     launchContactsPickerRequest = NULL;
       
   175 }
   189 }
       
   190 /*!
       
   191    XQAiwRequest calls this if request is ok or an error happens.
       
   192 */
       
   193 void NmRecipientField::requestCompleted()
       
   194 {
       
   195     delete mAiwRequest;
       
   196     mAiwRequest = NULL;
       
   197 }