40 #include "msgcontactcardwidget.h" |
40 #include "msgcontactcardwidget.h" |
41 #include "conversationidpsconsts.h" |
41 #include "conversationidpsconsts.h" |
42 |
42 |
43 QTM_USE_NAMESPACE |
43 QTM_USE_NAMESPACE |
44 |
44 |
|
45 const int INVALID_MSGID = -1; |
|
46 const int INVALID_CONVID = -1; |
|
47 |
45 // LOCALIZATION |
48 // LOCALIZATION |
46 #define LOC_SAVED_TO_DRAFTS hbTrId("txt_messaging_dpopinfo_saved_to_drafts") |
49 #define LOC_SAVED_TO_DRAFTS hbTrId("txt_messaging_dpopinfo_saved_to_drafts") |
47 |
50 |
48 //--------------------------------------------------------------- |
51 //--------------------------------------------------------------- |
49 // MsgConversationBaseView::MsgConversationBaseView |
52 // MsgConversationBaseView::MsgConversationBaseView |
50 // Constructor |
53 // Constructor |
51 //--------------------------------------------------------------- |
54 //--------------------------------------------------------------- |
52 MsgConversationBaseView::MsgConversationBaseView(QGraphicsItem* parent) : |
55 MsgConversationBaseView::MsgConversationBaseView(QGraphicsItem* parent) : |
53 MsgBaseView(parent), |
56 MsgBaseView(parent), mConversationId(-1), mCVIdkey(XQSettingsKey::TargetPublishAndSubscribe, |
54 mConversationId(-1), |
57 KMsgCVIdProperty, KMsgCVIdKey) |
55 mCVIdkey(XQSettingsKey::TargetPublishAndSubscribe,KMsgCVIdProperty, |
58 { |
56 KMsgCVIdKey) |
59 connect(this->mainWindow(), SIGNAL(viewReady()), this, SLOT(doDelayedConstruction())); |
57 { |
|
58 connect(this->mainWindow(),SIGNAL(viewReady()),this,SLOT(doDelayedConstruction())); |
|
59 initView(); |
60 initView(); |
60 } |
61 } |
61 |
62 |
62 //--------------------------------------------------------------- |
63 //--------------------------------------------------------------- |
63 // MsgConversationBaseView::~MsgConversationBaseView |
64 // MsgConversationBaseView::~MsgConversationBaseView |
64 // Destructor |
65 // Destructor |
65 //--------------------------------------------------------------- |
66 //--------------------------------------------------------------- |
66 MsgConversationBaseView::~MsgConversationBaseView() |
67 MsgConversationBaseView::~MsgConversationBaseView() |
67 { |
68 { |
68 } |
69 } |
69 |
70 |
70 //--------------------------------------------------------------- |
71 //--------------------------------------------------------------- |
71 // MsgConversationBaseView::openConversationView |
72 // MsgConversationBaseView::openConversationView |
72 // Launches conversation view for entry id and mode |
73 // Launches conversation view for entry id and mode |
73 //--------------------------------------------------------------- |
74 //--------------------------------------------------------------- |
74 void MsgConversationBaseView::openConversation(qint64 convId) |
75 void MsgConversationBaseView::openConversation(qint64 convId) |
75 { |
76 { |
76 ConversationsEngine::instance()->getConversations(convId); |
77 ConversationsEngine::instance()->getConversations(convId); |
77 mConversationId = convId; |
78 mConversationId = convId; |
78 connect(this->mainWindow(),SIGNAL(viewReady()),this,SLOT(doDelayedConstruction())); |
79 connect(this->mainWindow(), SIGNAL(viewReady()), this, SLOT(doDelayedConstruction())); |
79 |
80 |
80 // publsih conversation id |
81 // publsih conversation id |
81 mSettingsManager->writeItemValue(mCVIdkey,(int)mConversationId); |
82 mSettingsManager->writeItemValue(mCVIdkey, (int) mConversationId); |
82 |
83 |
83 if(mConversationView) |
84 if (mConversationView) { |
84 { |
|
85 mConversationView->refreshView(); |
85 mConversationView->refreshView(); |
86 } |
86 } |
87 } |
87 } |
88 |
88 |
89 //--------------------------------------------------------------- |
89 //--------------------------------------------------------------- |
90 // MsgConversationBaseView::initView |
90 // MsgConversationBaseView::initView |
91 // create and initialise the conversationview |
91 // create and initialise the conversationview |
92 //--------------------------------------------------------------- |
92 //--------------------------------------------------------------- |
93 void MsgConversationBaseView::initView() |
93 void MsgConversationBaseView::initView() |
94 { |
94 { |
95 |
95 |
96 // Create header widget |
96 // Create header widget |
97 mContactCard = new MsgContactCardWidget(this); |
97 mContactCard = new MsgContactCardWidget(this); |
98 |
98 |
99 mMainLayout = new QGraphicsLinearLayout(Qt::Vertical); |
99 mMainLayout = new QGraphicsLinearLayout(Qt::Vertical); |
100 |
100 |
101 qreal spacing = HbDeviceProfile::profile(this).unitValue(); |
101 qreal spacing = HbDeviceProfile::profile(this).unitValue(); |
102 mMainLayout->setSpacing(spacing); |
102 mMainLayout->setSpacing(spacing); |
103 mMainLayout->setContentsMargins(CONTENT_MARGIN, CONTENT_MARGIN, |
103 mMainLayout->setContentsMargins(CONTENT_MARGIN, CONTENT_MARGIN, CONTENT_MARGIN, CONTENT_MARGIN); |
104 CONTENT_MARGIN, CONTENT_MARGIN); |
|
105 |
104 |
106 mMainLayout->addItem(mContactCard); |
105 mMainLayout->addItem(mContactCard); |
|
106 connect(mContactCard, SIGNAL(conversationIdChanged(qint64)), this, |
|
107 SLOT(handleConversationIdChange(qint64))); |
107 |
108 |
108 /** |
109 /** |
109 * Create conversation view and connect to proper signals. |
110 * Create conversation view and connect to proper signals. |
110 * NOTE: contactCardWidget is NOT parent of MsgConversationView. |
111 * NOTE: contactCardWidget is NOT parent of MsgConversationView. |
111 * Just passing reference to MsgConversationView. |
112 * Just passing reference to MsgConversationView. |
112 */ |
113 */ |
113 mConversationView = new MsgConversationView(mContactCard); |
114 mConversationView = new MsgConversationView(mContactCard); |
114 |
115 |
115 mConversationView->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
116 mConversationView->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
116 |
117 |
117 connect(mConversationView, SIGNAL(closeConversationView()), |
118 connect(mConversationView, SIGNAL(closeConversationView()), this, SLOT(closeConversationView())); |
118 this, SLOT(closeConversationView())); |
119 |
119 |
120 connect(mConversationView, SIGNAL(replyStarted()), this, SLOT(markMessagesAsRead())); |
120 connect(mConversationView,SIGNAL(replyStarted()), |
121 |
121 this,SLOT(markMessagesAsRead())); |
122 connect(mConversationView, SIGNAL(switchView(const QVariantList&)), this, |
122 |
123 SIGNAL(switchView(const QVariantList&))); |
123 connect(mConversationView, SIGNAL(switchView(const QVariantList&)), |
124 |
124 this, SIGNAL(switchView(const QVariantList&))); |
125 connect(mConversationView, SIGNAL(vkbOpened(bool)), this, SLOT(hideChrome(bool))); |
125 |
126 connect(mConversationView, SIGNAL(vkbOpened(bool)), mContactCard, SLOT(ignoreSignals(bool))); |
126 connect(mConversationView,SIGNAL(hideChrome(bool)),this,SLOT(hideChrome(bool))); |
|
127 |
127 |
128 this->setMenu(mConversationView->menu()); |
128 this->setMenu(mConversationView->menu()); |
129 |
129 |
130 mMainLayout->addItem(mConversationView); |
130 mMainLayout->addItem(mConversationView); |
131 |
131 |
132 this->setLayout(mMainLayout); |
132 this->setLayout(mMainLayout); |
133 |
133 |
134 mSettingsManager = new XQSettingsManager(this); |
134 mSettingsManager = new XQSettingsManager(this); |
135 |
135 |
136 } |
136 } |
137 |
137 |
138 //--------------------------------------------------------------- |
138 //--------------------------------------------------------------- |
139 // MsgConversationBaseView::closeConversationView |
139 // MsgConversationBaseView::closeConversationView |
140 // close conversation view |
140 // close conversation view |
141 //--------------------------------------------------------------- |
141 //--------------------------------------------------------------- |
142 void MsgConversationBaseView::closeConversationView() |
142 void MsgConversationBaseView::closeConversationView() |
143 { |
143 { |
144 markMessagesAsRead(); |
144 markMessagesAsRead(); |
145 } |
145 } |
146 |
146 |
147 //--------------------------------------------------------------- |
147 //--------------------------------------------------------------- |
148 // MsgConversationBaseView::markMessagesAsRead |
148 // MsgConversationBaseView::markMessagesAsRead |
149 // Mark unread msgs in cv as read |
149 // Mark unread msgs in cv as read |
150 //--------------------------------------------------------------- |
150 //--------------------------------------------------------------- |
151 void MsgConversationBaseView::markMessagesAsRead() |
151 void MsgConversationBaseView::markMessagesAsRead() |
152 { |
152 { |
153 if( mConversationId >= 0) |
153 if (mConversationId >= 0) { |
154 { |
|
155 ConversationsEngine::instance()->markConversationRead(mConversationId); |
154 ConversationsEngine::instance()->markConversationRead(mConversationId); |
156 } |
155 } |
157 } |
156 } |
158 |
157 |
159 //--------------------------------------------------------------- |
158 //--------------------------------------------------------------- |
160 // MsgConversationBaseView::saveContentToDrafts |
159 // MsgConversationBaseView::saveContentToDrafts |
161 // saves the editors content to drafts |
160 // saves the editors content to drafts |
162 //--------------------------------------------------------------- |
161 //--------------------------------------------------------------- |
163 void MsgConversationBaseView::saveContentToDrafts() |
162 int MsgConversationBaseView::saveContentToDrafts() |
164 { |
163 { |
|
164 int msgId = INVALID_MSGID; |
165 bool result = false; |
165 bool result = false; |
166 if( mConversationId >= 0) |
166 if (mConversationId >= 0) { |
167 { |
167 msgId = mConversationView->saveContentToDrafts(); |
168 result = mConversationView->saveContentToDrafts(); |
168 } |
169 } |
169 |
170 |
170 if (msgId != INVALID_MSGID) { |
171 if(result) |
|
172 { |
|
173 HbNotificationDialog::launchDialog(LOC_SAVED_TO_DRAFTS); |
171 HbNotificationDialog::launchDialog(LOC_SAVED_TO_DRAFTS); |
174 } |
172 } |
175 } |
173 return msgId; |
|
174 } |
176 |
175 |
177 //--------------------------------------------------------------- |
176 //--------------------------------------------------------------- |
178 // MsgConversationBaseView::conversationId |
177 // MsgConversationBaseView::conversationId |
179 // get the conversation ID |
178 // get the conversation ID |
180 //--------------------------------------------------------------- |
179 //--------------------------------------------------------------- |
181 qint64 MsgConversationBaseView::conversationId() |
180 qint64 MsgConversationBaseView::conversationId() |
182 { |
181 { |
183 return mConversationId; |
182 return mConversationId; |
184 } |
183 } |
185 |
184 |
186 //--------------------------------------------------------------- |
185 //--------------------------------------------------------------- |
187 // MsgConversationBaseView::clearContent |
186 // MsgConversationBaseView::clearContent |
188 // clears conversation view content |
187 // clears conversation view content |
189 //--------------------------------------------------------------- |
188 //--------------------------------------------------------------- |
196 //--------------------------------------------------------------- |
195 //--------------------------------------------------------------- |
197 // MsgConversationBaseView::handleOk |
196 // MsgConversationBaseView::handleOk |
198 // |
197 // |
199 //--------------------------------------------------------------- |
198 //--------------------------------------------------------------- |
200 void MsgConversationBaseView::handleOk(const QVariant& result) |
199 void MsgConversationBaseView::handleOk(const QVariant& result) |
201 { |
200 { |
202 Q_UNUSED(result) |
201 Q_UNUSED(result) |
203 } |
202 } |
204 |
203 |
205 //--------------------------------------------------------------- |
204 //--------------------------------------------------------------- |
206 // MsgConversationBaseView::handleError |
205 // MsgConversationBaseView::handleError |
207 // |
206 // |
208 //--------------------------------------------------------------- |
207 //--------------------------------------------------------------- |
209 void MsgConversationBaseView::handleError(int errorCode, const QString& errorMessage) |
208 void MsgConversationBaseView::handleError(int errorCode, const QString& errorMessage) |
210 { |
209 { |
211 Q_UNUSED(errorMessage) |
210 Q_UNUSED(errorMessage) |
212 Q_UNUSED(errorCode) |
211 Q_UNUSED(errorCode) |
213 } |
212 } |
214 |
213 |
215 //--------------------------------------------------------------- |
214 //--------------------------------------------------------------- |
216 // MsgConversationBaseView::doDelayedConstruction |
215 // MsgConversationBaseView::doDelayedConstruction |
217 // |
216 // |
218 //--------------------------------------------------------------- |
217 //--------------------------------------------------------------- |
219 void MsgConversationBaseView::doDelayedConstruction() |
218 void MsgConversationBaseView::doDelayedConstruction() |
220 { |
219 { |
221 disconnect(this->mainWindow(),SIGNAL(viewReady()),this,SLOT(doDelayedConstruction())); |
220 disconnect(this->mainWindow(), SIGNAL(viewReady()), this, SLOT(doDelayedConstruction())); |
222 QTimer::singleShot(50,this,SLOT(handleViewReady())); |
221 QTimer::singleShot(50, this, SLOT(handleViewReady())); |
223 } |
222 } |
224 |
|
225 |
223 |
226 //--------------------------------------------------------------- |
224 //--------------------------------------------------------------- |
227 // MsgConversationBaseView::handleViewReady |
225 // MsgConversationBaseView::handleViewReady |
228 // |
226 // |
229 //--------------------------------------------------------------- |
227 //--------------------------------------------------------------- |
230 void MsgConversationBaseView::handleViewReady() |
228 void MsgConversationBaseView::handleViewReady() |
231 { |
229 { |
232 ConversationsEngine::instance()->fetchMoreConversations(); |
230 mConversationView->onViewReady(); |
233 } |
231 } |
|
232 |
|
233 //--------------------------------------------------------------- |
|
234 // MsgConversationBaseView::handleConversationIdChange |
|
235 // |
|
236 //--------------------------------------------------------------- |
|
237 void MsgConversationBaseView::handleConversationIdChange(qint64 convId) |
|
238 { |
|
239 if (INVALID_CONVID != convId && mConversationId != convId) { |
|
240 |
|
241 mConversationId = convId; |
|
242 // publsih conversation id |
|
243 mSettingsManager->writeItemValue(mCVIdkey, (int) mConversationId); |
|
244 } |
|
245 } |
234 |
246 |
235 //--------------------------------------------------------------- |
247 //--------------------------------------------------------------- |
236 // MsgConversationBaseView::hideChrome |
248 // MsgConversationBaseView::hideChrome |
237 // |
249 // |
238 //--------------------------------------------------------------- |
250 //--------------------------------------------------------------- |
239 void MsgConversationBaseView::hideChrome(bool hide) |
251 void MsgConversationBaseView::hideChrome(bool hide) |
240 { |
252 { |
241 if(hide) |
253 if (hide) { |
242 { |
|
243 this->hideItems(Hb::StatusBarItem | Hb::TitleBarItem); |
254 this->hideItems(Hb::StatusBarItem | Hb::TitleBarItem); |
244 this->setContentFullScreen(true); |
255 this->setContentFullScreen(true); |
245 |
256 |
246 if(this->mainWindow()->orientation() == Qt::Horizontal) |
257 if (this->mainWindow()->orientation() == Qt::Horizontal) { |
247 { |
|
248 mMainLayout->removeItem(mContactCard); |
258 mMainLayout->removeItem(mContactCard); |
249 mContactCard->hide(); |
259 mContactCard->hide(); |
250 } |
|
251 } |
260 } |
252 else |
261 } |
253 { |
262 else { |
254 this->showItems(Hb::StatusBarItem | Hb::TitleBarItem); |
263 this->showItems(Hb::StatusBarItem | Hb::TitleBarItem); |
255 this->setContentFullScreen(false); |
264 this->setContentFullScreen(false); |
256 |
265 |
257 if(!mContactCard->isVisible()) |
266 if (!mContactCard->isVisible()) { |
258 { |
267 mMainLayout->insertItem(0, mContactCard); |
259 mMainLayout->insertItem(0,mContactCard); |
|
260 mContactCard->show(); |
268 mContactCard->show(); |
261 } |
|
262 } |
269 } |
263 } |
270 } |
|
271 } |
264 |
272 |
265 //--------------------------------------------------------------- |
273 //--------------------------------------------------------------- |
266 // MsgConversationBaseView::setPSCVId |
274 // MsgConversationBaseView::setPSCVId |
267 // |
275 // |
268 //--------------------------------------------------------------- |
276 //--------------------------------------------------------------- |
269 void MsgConversationBaseView::setPSCVId(bool setId) |
277 void MsgConversationBaseView::setPSCVId(bool setId) |
270 { |
278 { |
271 if(setId){ |
279 if (setId) { |
272 mSettingsManager->writeItemValue(mCVIdkey,(int)mConversationId); |
280 mSettingsManager->writeItemValue(mCVIdkey, (int) mConversationId); |
273 } |
281 } |
274 else { |
282 else { |
275 mSettingsManager->writeItemValue(mCVIdkey,-1); |
283 mSettingsManager->writeItemValue(mCVIdkey, -1); |
276 } |
284 } |
277 } |
285 } |
278 // EOF |
286 // EOF |