9 * Initial Contributors: |
9 * Initial Contributors: |
10 * Nokia Corporation - initial contribution. |
10 * Nokia Corporation - initial contribution. |
11 * |
11 * |
12 * Contributors: |
12 * Contributors: |
13 * |
13 * |
14 * Description: nmrecipientlineedit.h |
14 * Description: implementation of recipient field (to, cc, bcc) line editor |
15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 #ifndef NMRECIPIENTLINEEDIT_H_ |
18 #ifndef NMRECIPIENTLINEEDIT_H_ |
19 #define NMRECIPIENTLINEEDIT_H_ |
19 #define NMRECIPIENTLINEEDIT_H_ |
20 |
20 |
21 #include <nmailuiwidgetsdef.h> |
|
22 #include <nmhtmllineedit.h> |
21 #include <nmhtmllineedit.h> |
23 #include <nmaddress.h> |
|
24 |
22 |
25 class QGraphicsItem; |
23 class QGraphicsItem; |
|
24 class QModelIndex; |
26 |
25 |
|
26 class HbPopup; |
|
27 class HbListView; |
|
28 |
|
29 class NmContactHistoryModel; |
|
30 class NmAutoFillListViewItem; |
|
31 class NmPopupBackground; |
|
32 class NmAddress; |
27 |
33 |
28 class NMAILUIWIDGETS_EXPORT NmRecipientLineEdit : public NmHtmlLineEdit |
34 class NMAILUIWIDGETS_EXPORT NmRecipientLineEdit : public NmHtmlLineEdit |
29 { |
35 { |
30 Q_OBJECT |
36 Q_OBJECT |
31 |
37 |
32 public: |
38 public: |
33 NmRecipientLineEdit(QGraphicsItem *parent = 0); |
39 NmRecipientLineEdit(QGraphicsItem *parent = NULL); |
34 virtual ~NmRecipientLineEdit(); |
40 virtual ~NmRecipientLineEdit(); |
35 |
|
36 // Get the emailaddress list generated from the content of the lineedit. |
|
37 QList<NmAddress> emailAddressList(); |
41 QList<NmAddress> emailAddressList(); |
38 void addContacts(QList<NmAddress *> contacts); |
42 void addContacts(QList<NmAddress *> contacts); |
39 |
43 |
40 public slots: |
44 public slots: |
41 #ifdef Q_OS_SYMBIAN |
|
42 void addSelectedContacts(const QVariant &selectedContacts); |
45 void addSelectedContacts(const QVariant &selectedContacts); |
43 #endif |
46 void addSelectedContactFromHistory(const QModelIndex &modelIndex); |
44 |
47 |
45 protected: // from HbLineEdit |
48 protected: // from HbLineEdit |
46 void keyPressEvent(QKeyEvent *event); |
49 void keyPressEvent(QKeyEvent *event); |
47 void inputMethodEvent(QInputMethodEvent *event); |
50 void inputMethodEvent(QInputMethodEvent *event); |
48 |
51 |
49 private: |
52 private: |
50 // Generate emailaddress list from the content of the lineedit. |
|
51 void generateEmailAddressList(); |
53 void generateEmailAddressList(); |
52 |
54 void createAutofillComponents(); |
53 private slots: |
55 void createAutoFillPopup(); |
|
56 void showAutofillPopup(); |
|
57 void hideAutofillPopup(); |
|
58 void currentTextPart(int& startIndex, int& length); |
|
59 void getChosenAddressFromModel(const QModelIndex &modelIndex, NmAddress &address); |
|
60 void setHighlight(int currentPos); |
|
61 void gestureEvent(QGestureEvent* event); |
|
62 void handleTap(); |
|
63 void insertContactText(const QString &text); |
|
64 void keyPressEventSemicolon(QKeyEvent *event); |
|
65 void keyPressEventDelete(QKeyEvent *event); |
|
66 void keyPressEventLeft(QKeyEvent *event); |
|
67 void keyPressEventRight(QKeyEvent *event); |
|
68 |
|
69 private slots: |
54 void handleTextChanged(const QString &text); |
70 void handleTextChanged(const QString &text); |
|
71 void modelCompleted(int err); |
55 |
72 |
56 private: |
73 private: |
57 // mEmailAddressList contains all emailaddress that appear in the lineedit and |
74 // mEmailAddressList contains all emailaddress that appear in the lineedit and |
58 // all emailaddress corresponding to the contact's name added from Contacts, |
75 // all emailaddress corresponding to the contact's name added from Contacts, |
59 // including invalid emailaddress user typed or invalid emailaddress added from Contacts. |
76 // including invalid emailaddress user typed or invalid emailaddress added from Contacts. |
60 // Emailaddress validation check is conducted in nmeditorview. |
77 // Emailaddress validation check is conducted in nmeditorview. |
61 QList<NmAddress> mEmailAddressList; |
78 QList<NmAddress> mEmailAddressList; |
62 |
|
63 QList<NmAddress> mRecipientsAddedFromContacts; |
79 QList<NmAddress> mRecipientsAddedFromContacts; |
64 |
80 |
65 // Flag "need to generate mEmailAddressList" is used whenever editing made after |
81 // Flag "need to generate mEmailAddressList" is used whenever editing made after |
66 // the emailaddress validation check failed. |
82 // the emailaddress validation check failed. |
67 bool mNeedToGenerateEmailAddressList; |
83 bool mNeedToGenerateEmailAddressList; |
|
84 |
|
85 NmContactHistoryModel *mContactHistoryModel; // owned |
|
86 |
|
87 HbPopup *mAutoFillPopup; // owned |
|
88 |
|
89 HbListView *mAutofillListView; // owned |
|
90 NmAutoFillListViewItem *mAutofillListViewItem; //owned |
|
91 NmPopupBackground *mPopupBackground; // pwned |
|
92 }; |
|
93 |
|
94 class NmPopupBackground : public QGraphicsItem |
|
95 { |
|
96 public: |
|
97 explicit NmPopupBackground(HbPopup *popup, QGraphicsItem *parent = 0); |
|
98 bool isModal() { return true; } |
|
99 QRectF boundingRect() const { return QRect(-100, -100, 1000, 1000); } |
|
100 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); |
|
101 protected: |
|
102 bool sceneEvent(QEvent *event); |
|
103 private: |
|
104 mutable QRectF mRect; |
|
105 HbPopup *mPopup; //not owned |
68 }; |
106 }; |
69 |
107 |
70 #endif // NMRECIPIENTLINEEDIT_H_ |
108 #endif // NMRECIPIENTLINEEDIT_H_ |