16 */ |
16 */ |
17 |
17 |
18 // INCLUDES |
18 // INCLUDES |
19 #include "debugtraces.h" |
19 #include "debugtraces.h" |
20 #include <HbIconItem> |
20 #include <HbIconItem> |
|
21 #include <HbNotificationDialog> |
21 |
22 |
22 // USER INCLUDES |
23 // USER INCLUDES |
23 #include "msgunieditorsubject.h" |
24 #include "msgunieditorsubject.h" |
24 #include "UniEditorGenUtils.h" |
25 #include "UniEditorGenUtils.h" |
25 #include "msgunifiededitorlineedit.h" |
26 #include "msgunifiededitorlineedit.h" |
|
27 #include "msgmonitor.h" |
26 |
28 |
27 // Localized Constants |
29 // Localized Constants |
28 #define LOC_SUBJECT hbTrId("txt_messaging_formlabel_subject") |
30 #define LOC_SUBJECT hbTrId("txt_messaging_formlabel_subject") |
|
31 #define LOC_UNABLE_TO_ADD_CONTENT hbTrId("txt_messaging_dpopinfo_unable_to_add_more_content") |
29 |
32 |
30 //priority icon |
33 //priority icon |
31 const QString HIGH_PRIORITY("qtg_small_priority_high"); |
34 const QString HIGH_PRIORITY("qtg_small_priority_high"); |
32 const QString LOW_PRIORITY("qtg_small_priority_low"); |
35 const QString LOW_PRIORITY("qtg_small_priority_low"); |
33 |
36 |
34 //--------------------------------------------------------------- |
37 //--------------------------------------------------------------- |
35 // MsgUnifiedEditorSubject::MsgUnifiedEditorSubject |
38 // MsgUnifiedEditorSubject::MsgUnifiedEditorSubject |
36 // @see header file |
39 // @see header file |
37 //--------------------------------------------------------------- |
40 //--------------------------------------------------------------- |
38 MsgUnifiedEditorSubject::MsgUnifiedEditorSubject( const QString& pluginPath, QGraphicsItem *parent ) : |
41 MsgUnifiedEditorSubject::MsgUnifiedEditorSubject( QGraphicsItem *parent ) : |
39 HbWidget(parent), |
42 MsgUnifiedEditorBaseWidget(parent), |
40 mPluginPath(pluginPath), |
|
41 mPriorityIcon(NULL), |
43 mPriorityIcon(NULL), |
42 mPriority(ConvergedMessage::Normal), |
44 mPriority(ConvergedMessage::Normal), |
43 mGenUtils(0) |
45 mGenUtils(0) |
44 { |
46 { |
45 #ifdef _DEBUG_TRACES_ |
|
46 qDebug() << "MsgUnifiedEditorSubject calling HbStyle::registerPlugin"; |
|
47 #endif |
|
48 |
|
49 setPluginBaseId(style()->registerPlugin(mPluginPath)); |
|
50 |
|
51 mSubjectEdit = new MsgUnifiedEditorLineEdit(LOC_SUBJECT,this); |
47 mSubjectEdit = new MsgUnifiedEditorLineEdit(LOC_SUBJECT,this); |
52 mSubjectEdit->setDefaultBehaviour(true); |
48 mSubjectEdit->setDefaultBehaviour(true); |
53 HbStyle::setItemName(mSubjectEdit,"subjectEdit"); |
49 HbStyle::setItemName(mSubjectEdit,"subjectEdit"); |
54 mSubjectEdit->setMinRows(1); |
50 mSubjectEdit->setMinRows(1); |
55 mSubjectEdit->setMaxRows(10); |
51 mSubjectEdit->setMaxRows(10); |
56 |
52 |
57 mGenUtils = new UniEditorGenUtils(); |
53 mGenUtils = new UniEditorGenUtils(); |
58 |
54 |
59 connect(mSubjectEdit, SIGNAL(contentsChanged(const QString&)), |
55 connect(mSubjectEdit, SIGNAL(contentsChanged(const QString&)), |
60 this, SLOT(onContentsAdded(const QString&))); |
56 this, SLOT(onContentsChanged(const QString&))); |
61 } |
57 } |
62 |
58 |
63 //--------------------------------------------------------------- |
59 //--------------------------------------------------------------- |
64 // MsgUnifiedEditorSubject::~MsgUnifiedEditorSubject |
60 // MsgUnifiedEditorSubject::~MsgUnifiedEditorSubject |
65 // @see header file |
61 // @see header file |
66 //--------------------------------------------------------------- |
62 //--------------------------------------------------------------- |
67 MsgUnifiedEditorSubject::~MsgUnifiedEditorSubject() |
63 MsgUnifiedEditorSubject::~MsgUnifiedEditorSubject() |
68 { |
64 { |
69 style()->unregisterPlugin(mPluginPath); |
|
70 |
|
71 if(mGenUtils) |
65 if(mGenUtils) |
72 { |
66 { |
73 delete mGenUtils; |
67 delete mGenUtils; |
74 mGenUtils = NULL; |
68 mGenUtils = NULL; |
75 } |
69 } |
115 ConvergedMessage::Priority MsgUnifiedEditorSubject::priority() |
109 ConvergedMessage::Priority MsgUnifiedEditorSubject::priority() |
116 { |
110 { |
117 return mPriority; |
111 return mPriority; |
118 } |
112 } |
119 |
113 |
120 void MsgUnifiedEditorSubject::onContentsAdded(const QString& text) |
114 void MsgUnifiedEditorSubject::onContentsChanged(const QString& text) |
121 { |
115 { |
122 if(!text.isEmpty()) |
116 // reject any text input if mms size limit is reached |
|
117 int futureSize = subjectSize() + |
|
118 MsgMonitor::containerSize() + MsgMonitor::bodySize(); |
|
119 if(futureSize > MsgMonitor::maxMmsSize()) |
123 { |
120 { |
|
121 // atomic operation |
124 disconnect(mSubjectEdit, SIGNAL(contentsChanged(const QString&)), |
122 disconnect(mSubjectEdit, SIGNAL(contentsChanged(const QString&)), |
125 this, SLOT(onContentsAdded(const QString&))); |
123 this, SLOT(onContentsChanged(const QString&))); |
126 if(!subjectOkInSms()) |
124 mSubjectEdit->clearContent(); |
127 { |
125 mSubjectEdit->setText(mPrevBuffer); |
128 emit contentChanged(); |
|
129 } |
|
130 connect(mSubjectEdit, SIGNAL(contentsChanged(const QString&)), |
126 connect(mSubjectEdit, SIGNAL(contentsChanged(const QString&)), |
131 this, SLOT(onContentsRemoved(const QString&))); |
127 this, SLOT(onContentsChanged(const QString&))); |
|
128 HbNotificationDialog::launchDialog(LOC_UNABLE_TO_ADD_CONTENT); |
|
129 return; |
132 } |
130 } |
133 } |
|
134 |
131 |
135 void MsgUnifiedEditorSubject::onContentsRemoved(const QString& text) |
132 mPrevBuffer = text; |
136 { |
133 if(!subjectOkInSms()) |
137 if(text.isEmpty()) |
|
138 { |
134 { |
139 disconnect(mSubjectEdit, SIGNAL(contentsChanged(const QString&)), |
135 emit contentChanged(); |
140 this, SLOT(onContentsRemoved(const QString&))); |
|
141 if(!subjectOkInSms()) |
|
142 { |
|
143 emit contentChanged(); |
|
144 } |
|
145 connect(mSubjectEdit, SIGNAL(contentsChanged(const QString&)), |
|
146 this, SLOT(onContentsAdded(const QString&))); |
|
147 } |
136 } |
148 } |
137 } |
149 |
138 |
150 bool MsgUnifiedEditorSubject::subjectOkInSms() |
139 bool MsgUnifiedEditorSubject::subjectOkInSms() |
151 { |
140 { |