21 #include <hbapplication.h> |
21 #include <hbapplication.h> |
22 #include <HbMenu> |
22 #include <HbMenu> |
23 #include <HbAction> |
23 #include <HbAction> |
24 #include <HbListView> |
24 #include <HbListView> |
25 #include <HbMessageBox> |
25 #include <HbMessageBox> |
26 #include <HbNotificationDialog> |
|
27 #include <HbFrameBackground> |
26 #include <HbFrameBackground> |
28 #include <HbStaticVkbHost> |
27 #include <HbStaticVkbHost> |
29 #include <HbStyleLoader> |
28 #include <HbStyleLoader> |
30 #include <xqaiwrequest.h> |
29 #include <xqaiwrequest.h> |
31 #include <xqappmgr.h> |
30 #include <xqappmgr.h> |
134 // @see header file |
133 // @see header file |
135 //--------------------------------------------------------------- |
134 //--------------------------------------------------------------- |
136 MsgConversationView::~MsgConversationView() |
135 MsgConversationView::~MsgConversationView() |
137 { |
136 { |
138 //delete the popup dialog |
137 //delete the popup dialog |
139 delete mDialog; |
138 if (mDialog) { |
|
139 delete mDialog; |
|
140 } |
140 } |
141 } |
141 //--------------------------------------------------------------- |
142 //--------------------------------------------------------------- |
142 // MsgConversationView::setupView |
143 // MsgConversationView::setupView |
143 // @see header file |
144 // @see header file |
144 //--------------------------------------------------------------- |
145 //--------------------------------------------------------------- |
149 if (!HbStyleLoader::registerFilePath(":/layouts")) { |
150 if (!HbStyleLoader::registerFilePath(":/layouts")) { |
150 QDEBUG_WRITE("ERROR: ConversationView -> HbStyleLoader::registerFilePath"); |
151 QDEBUG_WRITE("ERROR: ConversationView -> HbStyleLoader::registerFilePath"); |
151 } |
152 } |
152 mConversationList->setLayoutName("custom"); |
153 mConversationList->setLayoutName("custom"); |
153 mConversationList->setItemRecycling(true); |
154 mConversationList->setItemRecycling(true); |
|
155 mConversationList->setItemPixmapCacheEnabled(true); |
154 MsgConversationViewItem *item = new MsgConversationViewItem(this); |
156 MsgConversationViewItem *item = new MsgConversationViewItem(this); |
155 HbFrameBackground defaultBackground; |
157 HbFrameBackground defaultBackground; |
156 defaultBackground.setFrameGraphicsName(QString("")); |
158 defaultBackground.setFrameGraphicsName(QString("")); |
157 item->setDefaultFrame(defaultBackground); |
159 item->setDefaultFrame(defaultBackground); |
158 mConversationList->setItemPrototype(item); |
160 mConversationList->setItemPrototype(item); |
159 mConversationList->setSelectionMode(HbListView::NoSelection); |
161 mConversationList->setSelectionMode(HbListView::NoSelection); |
160 mConversationList->setClampingStyle(HbScrollArea::BounceBackClamping); |
162 mConversationList->setClampingStyle(HbScrollArea::BounceBackClamping); |
161 mConversationList->setScrollingStyle(HbScrollArea::PanOrFlick); |
|
162 |
163 |
163 mMessageModel = ConversationsEngine::instance()->getConversationsModel(); |
164 mMessageModel = ConversationsEngine::instance()->getConversationsModel(); |
164 |
165 |
165 connect(ConversationsEngine::instance(), |
166 connect(ConversationsEngine::instance(), |
166 SIGNAL(conversationModelPopulated()), |
167 SIGNAL(conversationModelPopulated()), |
216 void MsgConversationView::setupMenu() |
217 void MsgConversationView::setupMenu() |
217 { |
218 { |
218 // Just create dummy menu. |
219 // Just create dummy menu. |
219 // Actual menu will be created in menuAboutToShow() |
220 // Actual menu will be created in menuAboutToShow() |
220 HbMenu *mainMenu = this->menu(); |
221 HbMenu *mainMenu = this->menu(); |
221 HbAction* clearConversation = mainMenu->addAction(QString()); |
222 mainMenu->addAction(QString()); |
222 connect(mainMenu, SIGNAL(aboutToShow()), this, SLOT(menuAboutToShow())); |
223 connect(mainMenu, SIGNAL(aboutToShow()), this, SLOT(menuAboutToShow())); |
223 } |
224 } |
224 |
225 |
225 //--------------------------------------------------------------- |
226 //--------------------------------------------------------------- |
226 // MsgConversationView::fetchMoreConversations |
227 // MsgConversationView::fetchMoreConversations |
241 void MsgConversationView::refreshView() |
242 void MsgConversationView::refreshView() |
242 { |
243 { |
243 // Hide editor in case of BT conversations. |
244 // Hide editor in case of BT conversations. |
244 qint64 convId = ConversationsEngine::instance()->getCurrentConversationId(); |
245 qint64 convId = ConversationsEngine::instance()->getCurrentConversationId(); |
245 if (INVALID_CONVID != convId) { |
246 if (INVALID_CONVID != convId) { |
246 if (KBluetoothMsgsConversationId == convId) { |
247 mContactCardWidget->updateContents(); |
|
248 if (KBluetoothMsgsConversationId == convId || !(mContactCardWidget->isValidAddress())) { |
247 mMainLayout->removeItem(mEditorWidget); |
249 mMainLayout->removeItem(mEditorWidget); |
248 mEditorWidget->hide(); |
250 mEditorWidget->hide(); |
249 mEditorWidget->setParent(this); |
251 mEditorWidget->setParent(this); |
250 } |
252 } |
251 else { |
253 else { |
252 mMainLayout->addItem(mEditorWidget); |
254 mMainLayout->addItem(mEditorWidget); |
253 TRAP_IGNORE(mEditorWidget->setEncodingSettingsL()); |
|
254 mEditorWidget->show(); |
255 mEditorWidget->show(); |
255 } |
256 } |
256 mContactCardWidget->updateContents(); |
257 TRAP_IGNORE(mEditorWidget->setEncodingSettingsL()); |
257 } |
258 } |
258 } |
259 } |
259 |
260 |
260 //--------------------------------------------------------------- |
261 //--------------------------------------------------------------- |
261 // MsgConversationView::scrollToBottom() |
262 // MsgConversationView::scrollToBottom() |
982 int sendingState = index.data(SendingState).toInt(); |
983 int sendingState = index.data(SendingState).toInt(); |
983 |
984 |
984 // For suspended message both short tap and long tap needs to show the same |
985 // For suspended message both short tap and long tap needs to show the same |
985 // context menu..... |
986 // context menu..... |
986 if(direction == ConvergedMessage::Outgoing |
987 if(direction == ConvergedMessage::Outgoing |
987 && ((sendingState == ConvergedMessage::Suspended) || (sendingState == ConvergedMessage::Failed))) |
988 && (sendingState == ConvergedMessage::Suspended)) |
988 { |
989 { |
989 handleShortTap(); |
990 handleShortTap(); |
990 return; |
991 return; |
991 } |
992 } |
992 |
993 |
993 //If message is in any other state other than 'Sent' |
994 //If message is in any state other than 'Sent' or 'Failed' |
994 //do not open the message |
995 //do not open the message |
995 if(direction == ConvergedMessage::Outgoing |
996 if(direction == ConvergedMessage::Outgoing |
996 && sendingState != ConvergedMessage::SentState ) |
997 && sendingState != ConvergedMessage::SentState |
|
998 && sendingState != ConvergedMessage::Failed) |
997 |
999 |
998 { |
1000 { |
999 return; |
1001 return; |
1000 } |
1002 } |
1001 |
1003 |
1002 |
|
1003 |
|
1004 // contact Id |
1004 // contact Id |
1005 qint32 contactId = index.data(ContactId).toLongLong(); |
1005 qint32 contactId = index.data(ContactId).toLongLong(); |
1006 |
1006 |
1007 //if message unread, mark as read before opening view |
1007 //if message unread, mark as read before opening view |
1008 QList<int> msgIdList; |
1008 QList<int> msgIdList; |
1193 cardHeight = mContactCardWidget->rect().height(); |
1193 cardHeight = mContactCardWidget->rect().height(); |
1194 spacing = HbDeviceProfile::profile(this).unitValue(); |
1194 spacing = HbDeviceProfile::profile(this).unitValue(); |
1195 } |
1195 } |
1196 |
1196 |
1197 this->setMaximumHeight(appRect.height()- cardHeight - spacing); |
1197 this->setMaximumHeight(appRect.height()- cardHeight - spacing); |
1198 mConversationList->adjustSize(); |
1198 |
1199 |
1199 |
1200 disconnect(mVkbHost,SIGNAL(keypadOpened()),this,SLOT(vkbOpened())); |
1200 disconnect(mVkbHost,SIGNAL(keypadOpened()),this,SLOT(vkbOpened())); |
1201 |
1201 |
1202 } |
1202 } |
1203 |
1203 |
1210 emit vkbOpened(false); |
1210 emit vkbOpened(false); |
1211 |
1211 |
1212 scrollToBottom(); |
1212 scrollToBottom(); |
1213 |
1213 |
1214 this->setMaximumHeight(-1); |
1214 this->setMaximumHeight(-1); |
1215 mConversationList->adjustSize(); |
1215 |
1216 |
1216 |
1217 connect(mVkbHost,SIGNAL(keypadOpened()),this,SLOT(vkbOpened())); |
1217 connect(mVkbHost,SIGNAL(keypadOpened()),this,SLOT(vkbOpened())); |
1218 } |
1218 } |
1219 |
1219 |
1220 //--------------------------------------------------------------- |
1220 //--------------------------------------------------------------- |