15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 // INCLUDES |
18 // INCLUDES |
19 #include "debugtraces.h" |
19 #include "debugtraces.h" |
20 #include <HbTextItem> |
|
21 #include <HbLineEdit> |
|
22 #include <HbIconItem> |
20 #include <HbIconItem> |
23 |
21 |
24 // USER INCLUDES |
22 // USER INCLUDES |
25 #include "msgunieditorsubject.h" |
23 #include "msgunieditorsubject.h" |
26 #include "UniEditorGenUtils.h" |
24 #include "UniEditorGenUtils.h" |
|
25 #include "msgunifiededitorlineedit.h" |
27 |
26 |
28 // Localized Constants |
27 // Localized Constants |
29 #define LOC_SUBJECT hbTrId("txt_messaging_formlabel_subject") |
28 #define LOC_SUBJECT hbTrId("txt_messaging_formlabel_subject") |
|
29 |
|
30 //priority icon |
|
31 const QString HIGH_PRIORITY("qtg_small_priority_high"); |
|
32 const QString LOW_PRIORITY("qtg_small_priority_low"); |
30 |
33 |
31 //--------------------------------------------------------------- |
34 //--------------------------------------------------------------- |
32 // MsgUnifiedEditorSubject::MsgUnifiedEditorSubject |
35 // MsgUnifiedEditorSubject::MsgUnifiedEditorSubject |
33 // @see header file |
36 // @see header file |
34 //--------------------------------------------------------------- |
37 //--------------------------------------------------------------- |
35 MsgUnifiedEditorSubject::MsgUnifiedEditorSubject( const QString& pluginPath, QGraphicsItem *parent ) : |
38 MsgUnifiedEditorSubject::MsgUnifiedEditorSubject( const QString& pluginPath, QGraphicsItem *parent ) : |
36 HbWidget(parent), |
39 HbWidget(parent), |
37 mPluginPath(pluginPath), |
40 mPluginPath(pluginPath), |
38 mPriorityIcon(NULL), |
41 mPriorityIcon(NULL), |
|
42 mPriority(ConvergedMessage::Normal), |
39 mGenUtils(0) |
43 mGenUtils(0) |
40 { |
44 { |
41 #ifdef _DEBUG_TRACES_ |
45 #ifdef _DEBUG_TRACES_ |
42 qDebug() << "MsgUnifiedEditorSubject calling HbStyle::registerPlugin"; |
46 qDebug() << "MsgUnifiedEditorSubject calling HbStyle::registerPlugin"; |
43 #endif |
47 #endif |
44 |
48 |
45 setPluginBaseId(style()->registerPlugin(mPluginPath)); |
49 setPluginBaseId(style()->registerPlugin(mPluginPath)); |
46 |
50 |
47 mSubjectLabel = new HbTextItem(LOC_SUBJECT,this); |
51 mSubjectEdit = new MsgUnifiedEditorLineEdit(LOC_SUBJECT,this); |
48 HbStyle::setItemName(mSubjectLabel,"subjectLabel"); |
52 mSubjectEdit->setDefaultBehaviour(true); |
49 |
|
50 mSubjectEdit = new HbLineEdit(this); |
|
51 HbStyle::setItemName(mSubjectEdit,"subjectEdit"); |
53 HbStyle::setItemName(mSubjectEdit,"subjectEdit"); |
52 mSubjectEdit->setMinRows(1); |
54 mSubjectEdit->setMinRows(1); |
53 mSubjectEdit->setMaxRows(10); |
55 mSubjectEdit->setMaxRows(10); |
54 |
56 |
55 mGenUtils = new UniEditorGenUtils(); |
57 mGenUtils = new UniEditorGenUtils(); |
56 |
58 |
57 connect(mSubjectEdit, SIGNAL(textChanged(const QString&)), |
59 connect(mSubjectEdit, SIGNAL(contentsChanged(const QString&)), |
58 this, SLOT(onTextChanged(const QString&))); |
60 this, SLOT(onContentsAdded(const QString&))); |
59 } |
61 } |
60 |
62 |
61 //--------------------------------------------------------------- |
63 //--------------------------------------------------------------- |
62 // MsgUnifiedEditorSubject::~MsgUnifiedEditorSubject |
64 // MsgUnifiedEditorSubject::~MsgUnifiedEditorSubject |
63 // @see header file |
65 // @see header file |
80 {// Transition from low/high => low/normal/high |
82 {// Transition from low/high => low/normal/high |
81 mPriorityIcon->setParent(NULL); |
83 mPriorityIcon->setParent(NULL); |
82 delete mPriorityIcon; |
84 delete mPriorityIcon; |
83 mPriorityIcon = NULL; |
85 mPriorityIcon = NULL; |
84 } |
86 } |
85 else |
|
86 {// Transition from normal |
|
87 if(mPriority == ConvergedMessage::Normal) |
|
88 {// to normal |
|
89 return; |
|
90 } |
|
91 else |
|
92 {// to high/low |
|
93 emit mmContentAdded(true); |
|
94 } |
|
95 } |
|
96 |
87 |
97 switch(priority) |
88 switch(priority) |
98 { |
89 { |
99 case ConvergedMessage::High : |
90 case ConvergedMessage::High : |
100 { |
91 { |
101 mPriorityIcon = new HbIconItem(":/qtg_small_priority_high.svg", this); |
92 mPriorityIcon = new HbIconItem(HIGH_PRIORITY, this); |
102 HbStyle::setItemName(mPriorityIcon,"priorityIcon"); |
93 HbStyle::setItemName(mPriorityIcon,"priorityIcon"); |
103 } |
94 } |
104 break; |
95 break; |
105 case ConvergedMessage::Low : |
96 case ConvergedMessage::Low : |
106 { |
97 { |
107 mPriorityIcon = new HbIconItem(":/qtg_small_priority_low.svg", this); |
98 mPriorityIcon = new HbIconItem(LOW_PRIORITY, this); |
108 HbStyle::setItemName(mPriorityIcon,"priorityIcon"); |
99 HbStyle::setItemName(mPriorityIcon,"priorityIcon"); |
109 } |
|
110 break; |
|
111 case ConvergedMessage::Normal : |
|
112 { |
|
113 emit mmContentAdded(false); |
|
114 } |
100 } |
115 break; |
101 break; |
116 default: |
102 default: |
117 break; |
103 break; |
118 } |
104 } |
119 |
105 |
|
106 emit contentChanged(); |
120 this->repolish(); |
107 this->repolish(); |
121 } |
108 } |
122 |
109 |
123 QString MsgUnifiedEditorSubject::text() |
110 QString MsgUnifiedEditorSubject::text() |
124 { |
111 { |
125 return mSubjectEdit->text(); |
112 return mSubjectEdit->content(); |
126 } |
113 } |
127 |
114 |
128 ConvergedMessage::Priority MsgUnifiedEditorSubject::priority() |
115 ConvergedMessage::Priority MsgUnifiedEditorSubject::priority() |
129 { |
116 { |
130 return mPriority; |
117 return mPriority; |
131 } |
118 } |
132 |
119 |
133 void MsgUnifiedEditorSubject::onTextChanged(const QString& text) |
120 void MsgUnifiedEditorSubject::onContentsAdded(const QString& text) |
134 { |
121 { |
135 if(!text.isEmpty()) |
122 if(!text.isEmpty()) |
136 { |
123 { |
137 disconnect(mSubjectEdit, SIGNAL(textChanged(const QString&)), |
124 disconnect(mSubjectEdit, SIGNAL(contentsChanged(const QString&)), |
138 this, SLOT(onTextChanged(const QString&))); |
125 this, SLOT(onContentsAdded(const QString&))); |
139 if(!subjectOkInSms()) |
126 if(!subjectOkInSms()) |
140 { |
127 { |
141 emit mmContentAdded(true); |
128 emit contentChanged(); |
142 } |
129 } |
143 connect(mSubjectEdit, SIGNAL(textChanged(const QString&)), |
130 connect(mSubjectEdit, SIGNAL(contentsChanged(const QString&)), |
144 this, SLOT(onTextRemoved(const QString&))); |
131 this, SLOT(onContentsRemoved(const QString&))); |
145 } |
132 } |
146 } |
133 } |
147 |
134 |
148 void MsgUnifiedEditorSubject::onTextRemoved(const QString& text) |
135 void MsgUnifiedEditorSubject::onContentsRemoved(const QString& text) |
149 { |
136 { |
150 if(text.isEmpty()) |
137 if(text.isEmpty()) |
151 { |
138 { |
152 disconnect(mSubjectEdit, SIGNAL(textChanged(const QString&)), |
139 disconnect(mSubjectEdit, SIGNAL(contentsChanged(const QString&)), |
153 this, SLOT(onTextRemoved(const QString&))); |
140 this, SLOT(onContentsRemoved(const QString&))); |
154 if(!subjectOkInSms()) |
141 if(!subjectOkInSms()) |
155 { |
142 { |
156 emit mmContentAdded(false); |
143 emit contentChanged(); |
157 } |
144 } |
158 connect(mSubjectEdit, SIGNAL(textChanged(const QString&)), |
145 connect(mSubjectEdit, SIGNAL(contentsChanged(const QString&)), |
159 this, SLOT(onTextChanged(const QString&))); |
146 this, SLOT(onContentsAdded(const QString&))); |
160 } |
147 } |
161 } |
148 } |
162 |
149 |
163 bool MsgUnifiedEditorSubject::subjectOkInSms() |
150 bool MsgUnifiedEditorSubject::subjectOkInSms() |
164 { |
151 { |