emailuis/nmailui/src/nmrecipientfield.cpp
changeset 40 2c62ef3caffd
parent 20 ecc8def7944a
child 30 759dc5235cdb
equal deleted inserted replaced
39:b0b89ca206b5 40:2c62ef3caffd
    18 #include "nmuiheaders.h"
    18 #include "nmuiheaders.h"
    19 
    19 
    20 static const double Un = 6.66;
    20 static const double Un = 6.66;
    21 static const double Margin = 2 * Un;
    21 static const double Margin = 2 * Un;
    22 static const int MaxRows = 10000;
    22 static const int MaxRows = 10000;
    23 static const double LabelFieldWidth = 10 * Un + Un;
    23 static const double LabelFieldWidth = 12.5 * Un;
    24 static const double ButtonWidth = 9.5 * Un;
    24 static const double ButtonWidth = 9.5 * Un;
    25 static const double FieldHeight = 5 * Un;
    25 static const double FieldHeight = 5 * Un;
    26 static const char *ContactsServiceName = "com.nokia.services.phonebookservices";
    26 static const char *ContactsServiceName = "com.nokia.services.phonebookservices";
    27 static const char *ContactsInterfaceName = "Fetch";
    27 static const char *ContactsInterfaceName = "Fetch";
    28 static const char *ContactsOperationName = "fetch(QString,QString,QString)";
    28 static const char *ContactsOperationName = "fetch(QString,QString,QString)";
    29 
    29 
    30 /*!
    30 /*!
    31    Constructor
       
    32 */
       
    33 NmRecipientField::NmRecipientField(
       
    34     HbLabel *label,
       
    35     NmRecipientLineEdit *edit,
       
    36     HbPushButton *button,
       
    37     QGraphicsItem *parent):
       
    38     HbWidget(parent),
       
    39     mLabel(label),
       
    40     mRecipientsEditor(edit),
       
    41     mLaunchContactsPickerButton(button),
       
    42     mOwned(false)
       
    43 {
       
    44     mLaunchContactsPickerButton->setIcon(NmIcons::getIcon(NmIcons::NmIconContacts));
       
    45     createConnections();
       
    46 }
       
    47 
       
    48 
       
    49 /*!
       
    50    Constructor for 'Cc:' and 'Bcc:' fields. This can be removed when groupBox content
       
    51    widget is created using AD/docml
    31    widget is created using AD/docml
    52 */
    32 */
    53 NmRecipientField::NmRecipientField(const QString &labelString, QGraphicsItem *parent):
    33 NmRecipientField::NmRecipientField(const QString &labelString, QGraphicsItem *parent):
    54     HbWidget(parent),
    34     HbWidget(parent),
    55     mLabel(NULL),
    35     mLabel(NULL),
    56     mRecipientsEditor(NULL),
    36     mRecipientsEditor(NULL),
    57     mLaunchContactsPickerButton(NULL),
    37     mLaunchContactsPickerButton(NULL),
    58     mOwned(true)
    38     mOwned(true)
    59 {
    39 {
    60     mLayoutHorizontal = new QGraphicsLinearLayout(Qt::Horizontal, this);
    40     //construct default ui.    
       
    41     mLayoutHorizontal = new QGraphicsLinearLayout(Qt::Horizontal);
    61 
    42 
    62     mLabel = new HbLabel(labelString);
    43     mLabel = new HbLabel(labelString);
    63     if (mLabel) {
    44     if (mLabel) {
    64         mLayoutHorizontal->addItem(mLabel);
    45         mLayoutHorizontal->addItem(mLabel);
    65         mLabel->setPreferredWidth(LabelFieldWidth);
    46         mLabel->setPreferredWidth(LabelFieldWidth);
    66         mLabel->setFontSpec(HbFontSpec(HbFontSpec::Secondary));
    47         mLabel->setFontSpec(HbFontSpec(HbFontSpec::Secondary));
    67         mLabel->setAlignment(Qt::AlignTop);
       
    68     }
    48     }
    69 
    49 
    70     mRecipientsEditor = new NmRecipientLineEdit();
    50     mRecipientsEditor = new NmRecipientLineEdit();
    71     if (mRecipientsEditor) {
    51     if (mRecipientsEditor) {
    72     	mLayoutHorizontal->addItem(mRecipientsEditor);
    52     	mLayoutHorizontal->addItem(mRecipientsEditor);
    73         mRecipientsEditor->setMaxRows(MaxRows);
    53         mRecipientsEditor->setMaxRows(MaxRows);
       
    54         mRecipientsEditor->setFontSpec(HbFontSpec(HbFontSpec::Secondary));
       
    55         mRecipientsEditor->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
       
    56         mRecipientsEditor->setMinimumHeight(FieldHeight);
    74         mRecipientsEditor->setPreferredHeight(FieldHeight);
    57         mRecipientsEditor->setPreferredHeight(FieldHeight);
    75         mRecipientsEditor->setMinimumHeight(FieldHeight);
    58         mRecipientsEditor->setMaximumHeight(FieldHeight);
    76         mRecipientsEditor->setFontSpec(HbFontSpec(HbFontSpec::Secondary));
       
    77     }
    59     }
    78 
    60 
    79     mLaunchContactsPickerButton = new HbPushButton();
    61     mLaunchContactsPickerButton = new HbPushButton();
    80     if (mLaunchContactsPickerButton) {
    62     if (mLaunchContactsPickerButton) {
    81     	mLayoutHorizontal->addItem(mLaunchContactsPickerButton);
    63     	mLayoutHorizontal->addItem(mLaunchContactsPickerButton);
    90     mLayoutHorizontal->setContentsMargins(0, 0, 0, 0);
    72     mLayoutHorizontal->setContentsMargins(0, 0, 0, 0);
    91     // Set the spacing between the line edit  and the Add button to
    73     // Set the spacing between the line edit  and the Add button to
    92     mLayoutHorizontal->setItemSpacing(1, Un);
    74     mLayoutHorizontal->setItemSpacing(1, Un);
    93     // Set the spacing between the label and the line edit to 0.0
    75     // Set the spacing between the label and the line edit to 0.0
    94     mLayoutHorizontal->setItemSpacing(0, 0.0);
    76     mLayoutHorizontal->setItemSpacing(0, 0.0);
       
    77     
       
    78     this->setLayout(mLayoutHorizontal);
    95 
    79 
    96     createConnections();
    80     createConnections();
    97 }
    81 }
    98 
    82 
       
    83 /*!
       
    84    Creates connections for this class items
       
    85 */
    99 void NmRecipientField::createConnections()
    86 void NmRecipientField::createConnections()
   100 {
    87 {
   101     connect(mRecipientsEditor, SIGNAL(textChanged(const QString &)),
    88     connect(mRecipientsEditor, SIGNAL(textChanged(const QString &)),
   102         this, SIGNAL(textChanged(const QString &)));
    89         this, SIGNAL(textChanged(const QString &)));
   103     connect(mRecipientsEditor, SIGNAL(cursorPositionChanged(int, int)),
    90     connect(mRecipientsEditor, SIGNAL(cursorPositionChanged(int, int)),