diff -r 139d4b7b2938 -r 99bcbff212ad emailuis/nmailui/src/nmrecipientfield.cpp --- a/emailuis/nmailui/src/nmrecipientfield.cpp Mon May 24 21:02:02 2010 +0300 +++ b/emailuis/nmailui/src/nmrecipientfield.cpp Fri May 28 13:56:43 2010 +0300 @@ -17,65 +17,41 @@ #include "nmuiheaders.h" -static const double Un = 6.66; -static const double Margin = 2 * Un; +static const QString ContactsServiceName = "com.nokia.services.phonebookservices"; +static const QString ContactsInterfaceName = "Fetch"; +static const QString ContactsOperationName = "fetch(QString,QString,QString)"; + static const int MaxRows = 10000; -static const double LabelFieldWidth = 12.5 * Un; -static const double ButtonWidth = 9.5 * Un; -static const double FieldHeight = 5 * Un; -static const char *ContactsServiceName = "com.nokia.services.phonebookservices"; -static const char *ContactsInterfaceName = "Fetch"; -static const char *ContactsOperationName = "fetch(QString,QString,QString)"; /*! widget is created using AD/docml */ -NmRecipientField::NmRecipientField(const QString &labelString, QGraphicsItem *parent): - HbWidget(parent), +NmRecipientField::NmRecipientField( + QObject *parent, HbDocumentLoader &docLoader, const QString &objPrefix): + QObject(parent), + mDocumentLoader(docLoader), + mObjectPrefix(objPrefix), mLabel(NULL), mRecipientsEditor(NULL), - mLaunchContactsPickerButton(NULL), - mOwned(true) + mLaunchContactsPickerButton(NULL) { - //construct default ui. - mLayoutHorizontal = new QGraphicsLinearLayout(Qt::Horizontal); - - mLabel = new HbLabel(labelString); - if (mLabel) { - mLayoutHorizontal->addItem(mLabel); - mLabel->setPreferredWidth(LabelFieldWidth); - mLabel->setFontSpec(HbFontSpec(HbFontSpec::Secondary)); - } + NM_FUNCTION; + + // Load the widgets from nmeditorview.docml. The names match to the definitions in that docml. + mWidget = qobject_cast + (mDocumentLoader.findWidget(mObjectPrefix + "Field")); - mRecipientsEditor = new NmRecipientLineEdit(); - if (mRecipientsEditor) { - mLayoutHorizontal->addItem(mRecipientsEditor); - mRecipientsEditor->setMaxRows(MaxRows); - mRecipientsEditor->setFontSpec(HbFontSpec(HbFontSpec::Secondary)); - mRecipientsEditor->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); - mRecipientsEditor->setMinimumHeight(FieldHeight); - mRecipientsEditor->setPreferredHeight(FieldHeight); - mRecipientsEditor->setMaximumHeight(FieldHeight); - } + mLabel = qobject_cast + (mDocumentLoader.findWidget(mObjectPrefix + "Label")); - mLaunchContactsPickerButton = new HbPushButton(); - if (mLaunchContactsPickerButton) { - mLayoutHorizontal->addItem(mLaunchContactsPickerButton); - mLayoutHorizontal->setAlignment(mLaunchContactsPickerButton, Qt::AlignTop); - mLaunchContactsPickerButton->setPreferredHeight(FieldHeight); - mLaunchContactsPickerButton->setPreferredWidth(ButtonWidth); - mLaunchContactsPickerButton->setMaximumHeight(FieldHeight); + mRecipientsEditor = qobject_cast + (mDocumentLoader.findWidget(mObjectPrefix + "Edit")); + mRecipientsEditor->setMaxRows(MaxRows); - mLaunchContactsPickerButton->setIcon(NmIcons::getIcon(NmIcons::NmIconContacts)); - } + mLaunchContactsPickerButton = qobject_cast + (mDocumentLoader.findWidget(mObjectPrefix + "Button")); - mLayoutHorizontal->setContentsMargins(0, 0, 0, 0); - // Set the spacing between the line edit and the Add button to - mLayoutHorizontal->setItemSpacing(1, Un); - // Set the spacing between the label and the line edit to 0.0 - mLayoutHorizontal->setItemSpacing(0, 0.0); - - this->setLayout(mLayoutHorizontal); + mLaunchContactsPickerButton->setIcon(NmIcons::getIcon(NmIcons::NmIconContacts)); createConnections(); } @@ -85,6 +61,8 @@ */ void NmRecipientField::createConnections() { + NM_FUNCTION; + connect(mRecipientsEditor, SIGNAL(textChanged(const QString &)), this, SIGNAL(textChanged(const QString &))); connect(mRecipientsEditor, SIGNAL(cursorPositionChanged(int, int)), @@ -107,21 +85,7 @@ */ NmRecipientField::~NmRecipientField() { - if (mOwned) - { - if (mLaunchContactsPickerButton) { - delete mLaunchContactsPickerButton; - mLaunchContactsPickerButton = 0; - } - if (mRecipientsEditor) { - delete mRecipientsEditor; - mRecipientsEditor = 0; - } - if (mLabel) { - delete mLabel; - mLabel = 0; - } - } + NM_FUNCTION; } /*! @@ -129,7 +93,9 @@ */ qreal NmRecipientField::height() { - return mRecipientsEditor->geometry().height() + Margin; + NM_FUNCTION; + + return mWidget->geometry().height(); } /*! @@ -137,6 +103,8 @@ */ NmRecipientLineEdit *NmRecipientField::editor() const { + NM_FUNCTION; + return mRecipientsEditor; } @@ -146,6 +114,8 @@ */ const QString NmRecipientField::text() const { + NM_FUNCTION; + return mRecipientsEditor->text(); } @@ -155,6 +125,8 @@ */ void NmRecipientField::setText(const QString &newText) { + NM_FUNCTION; + if (newText != mRecipientsEditor->text()) { mRecipientsEditor->setText(newText); emit textChanged(newText); @@ -168,6 +140,8 @@ */ void NmRecipientField::launchContactsPicker() { + NM_FUNCTION; + XQApplicationManager mAppmgr; XQAiwRequest *launchContactsPickerRequest; @@ -181,14 +155,20 @@ } else { // Failed creating request - NMLOG("XQApplicationManager: failed creating fecth contactspicker request."); + NM_ERROR(1,"XQApplicationManager: failed creating fecth contactspicker request"); return; } + QVariantList args; + args << "Non-filtered multi-fetch"; + args << KCntActionAll; + args << KCntFilterDisplayAll; + launchContactsPickerRequest->setArguments(args); + // Send request if (!launchContactsPickerRequest->send()) { //Failed sending request - NMLOG("XQApplicationManager: failed sending request."); + NM_ERROR(1,"XQApplicationManager: failed sending request"); } delete launchContactsPickerRequest;