14 * Description:Conversation Base view. |
14 * Description:Conversation Base view. |
15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 #include "msgconversationbaseview.h" |
18 #include "msgconversationbaseview.h" |
19 #include "msguiutilsmanager.h" |
|
20 |
19 |
21 // SYSTEM INCLUDES |
20 // SYSTEM INCLUDES |
22 #include <QSqlDatabase> |
|
23 #include <QSqlQuery> |
|
24 #include <QSqlError> |
|
25 #include <QtDebug> |
|
26 #include <QGraphicsLinearLayout> |
21 #include <QGraphicsLinearLayout> |
|
22 #include <HbMainWindow> |
|
23 #include <HbNotificationDialog> |
|
24 |
|
25 #include <xqaiwrequest.h> |
|
26 #include <xqappmgr.h> |
|
27 |
|
28 #include <cntservicescontact.h> |
|
29 #include <qtcontactsglobal.h> |
|
30 #include <qtcontacts.h> |
|
31 #include <ccsdefs.h> |
27 |
32 |
28 // USER INCLUDES |
33 // USER INCLUDES |
29 #include "msgconversationview.h" |
34 #include "msgconversationview.h" |
30 //#include "convergedmessage.h" |
|
31 #include "conversationsengine.h" |
35 #include "conversationsengine.h" |
32 #include "msgviewdefines.h" |
36 #include "msgviewdefines.h" |
33 #include "conversationsenginedefines.h" |
37 #include "conversationsenginedefines.h" |
34 #include "msgcontactcardwidget.h" |
38 #include "msgcontactcardwidget.h" |
35 |
39 |
|
40 QTM_USE_NAMESPACE |
|
41 |
|
42 // LOCALIZATION |
|
43 #define LOC_SAVED_TO_DRAFTS hbTrId("txt_messaging_dpopinfo_saved_to_drafts") |
|
44 |
36 //--------------------------------------------------------------- |
45 //--------------------------------------------------------------- |
37 // MsgConversationBaseView::MsgConversationBaseView |
46 // MsgConversationBaseView::MsgConversationBaseView |
38 // Constructor |
47 // Constructor |
39 //--------------------------------------------------------------- |
48 //--------------------------------------------------------------- |
40 MsgConversationBaseView::MsgConversationBaseView(QGraphicsItem* parent) : |
49 MsgConversationBaseView::MsgConversationBaseView(QGraphicsItem* parent) : |
41 MsgBaseView(parent), |
50 MsgBaseView(parent), |
42 mConversationView(NULL), |
51 mConversationView(NULL), |
43 mConversationId(-1) |
52 mConversationId(-1) |
44 { |
53 { |
|
54 connect(this->mainWindow(),SIGNAL(viewReady()),this,SLOT(doDelayedConstruction())); |
45 initView(); |
55 initView(); |
46 } |
56 } |
47 |
57 |
48 //--------------------------------------------------------------- |
58 //--------------------------------------------------------------- |
49 // MsgConversationBaseView::~MsgConversationBaseView |
59 // MsgConversationBaseView::~MsgConversationBaseView |
57 // MsgConversationBaseView::openConversationView |
67 // MsgConversationBaseView::openConversationView |
58 // Launches conversation view for entry id and mode |
68 // Launches conversation view for entry id and mode |
59 //--------------------------------------------------------------- |
69 //--------------------------------------------------------------- |
60 void MsgConversationBaseView::openConversation(qint64 convId) |
70 void MsgConversationBaseView::openConversation(qint64 convId) |
61 { |
71 { |
62 ConversationsEngine::instance()->getConversations(convId); |
72 ConversationsEngine::instance()->getConversations(convId); |
63 mConversationId = convId; |
73 mConversationId = convId; |
64 mConversationView->refreshView(); |
74 connect(this->mainWindow(),SIGNAL(viewReady()),this,SLOT(doDelayedConstruction())); |
|
75 |
|
76 if(mConversationView) |
|
77 { |
|
78 mConversationView->refreshView(); |
|
79 } |
65 } |
80 } |
66 |
81 |
67 //--------------------------------------------------------------- |
82 //--------------------------------------------------------------- |
68 // MsgConversationBaseView::initView |
83 // MsgConversationBaseView::initView |
69 // create and initialise the conversationview |
84 // create and initialise the conversationview |
70 //--------------------------------------------------------------- |
85 //--------------------------------------------------------------- |
71 void MsgConversationBaseView::initView() |
86 void MsgConversationBaseView::initView() |
72 { |
87 { |
|
88 |
73 // Create header widget |
89 // Create header widget |
74 MsgContactCardWidget *contactCardWidget = new MsgContactCardWidget(); |
90 mContactCard = new MsgContactCardWidget(this); |
75 |
91 |
76 connect(contactCardWidget, SIGNAL(clicked()), this, SLOT(openContactDetails())); |
92 mMainLayout = new QGraphicsLinearLayout(Qt::Vertical); |
77 |
93 |
78 QGraphicsLinearLayout *mainLayout = new QGraphicsLinearLayout(Qt::Vertical); |
94 qreal spacing = HbDeviceProfile::profile(this).unitValue(); |
79 |
95 mMainLayout->setSpacing(spacing); |
80 mainLayout->setContentsMargins(CONTENT_MARGIN, CONTENT_MARGIN, |
96 mMainLayout->setContentsMargins(CONTENT_MARGIN, CONTENT_MARGIN, |
81 CONTENT_MARGIN, CONTENT_MARGIN); |
97 CONTENT_MARGIN, CONTENT_MARGIN); |
82 |
98 |
83 mainLayout->setSpacing(CONTENT_SPACING); |
99 mMainLayout->addItem(mContactCard); |
84 |
|
85 mainLayout->addItem(contactCardWidget); |
|
86 |
100 |
87 /** |
101 /** |
88 * Create conversation view and connect to proper signals. |
102 * Create conversation view and connect to proper signals. |
89 * NOTE: contactCardWidget is NOT parent of MsgConversationView. |
103 * NOTE: contactCardWidget is NOT parent of MsgConversationView. |
90 * Just passing reference to MsgConversationView. |
104 * Just passing reference to MsgConversationView. |
91 */ |
105 */ |
92 mConversationView = new MsgConversationView(contactCardWidget); |
106 mConversationView = new MsgConversationView(mContactCard); |
|
107 |
|
108 mConversationView->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
93 |
109 |
94 connect(mConversationView, SIGNAL(closeConversationView()), |
110 connect(mConversationView, SIGNAL(closeConversationView()), |
95 this, SLOT(closeConversationView())); |
111 this, SLOT(closeConversationView())); |
96 |
112 |
97 connect(mConversationView,SIGNAL(replyStarted()), |
113 connect(mConversationView,SIGNAL(replyStarted()), |
98 this,SLOT(markMessagesAsRead())); |
114 this,SLOT(markMessagesAsRead())); |
99 |
115 |
100 connect(mConversationView, SIGNAL(switchView(const QVariantList&)), |
116 connect(mConversationView, SIGNAL(switchView(const QVariantList&)), |
101 this, SIGNAL(switchView(const QVariantList&))); |
117 this, SIGNAL(switchView(const QVariantList&))); |
|
118 |
|
119 connect(mConversationView,SIGNAL(hideChrome(bool)),this,SLOT(hideChrome(bool))); |
102 |
120 |
103 this->setMenu(mConversationView->menu()); |
121 this->setMenu(mConversationView->menu()); |
104 |
122 |
105 mainLayout->addItem(mConversationView); |
123 mMainLayout->addItem(mConversationView); |
106 |
124 |
107 this->setLayout(mainLayout); |
125 this->setLayout(mMainLayout); |
108 |
126 |
109 } |
127 } |
110 |
128 |
111 //--------------------------------------------------------------- |
129 //--------------------------------------------------------------- |
112 // MsgConversationBaseView::closeConversationView |
130 // MsgConversationBaseView::closeConversationView |
131 |
149 |
132 //--------------------------------------------------------------- |
150 //--------------------------------------------------------------- |
133 // MsgConversationBaseView::saveContentToDrafts |
151 // MsgConversationBaseView::saveContentToDrafts |
134 // saves the editors content to drafts |
152 // saves the editors content to drafts |
135 //--------------------------------------------------------------- |
153 //--------------------------------------------------------------- |
136 bool MsgConversationBaseView::saveContentToDrafts() |
154 void MsgConversationBaseView::saveContentToDrafts() |
137 { |
155 { |
138 bool result = false; |
156 bool result = false; |
139 if( mConversationId >= 0) |
157 if( mConversationId >= 0) |
140 { |
158 { |
141 result = mConversationView->saveContentToDrafts(); |
159 result = mConversationView->saveContentToDrafts(); |
142 } |
160 } |
143 return result; |
161 |
144 } |
162 if(result) |
145 |
163 { |
146 //--------------------------------------------------------------- |
164 HbNotificationDialog::launchDialog(LOC_SAVED_TO_DRAFTS); |
147 // MsgConversationBaseView::openContactDetails |
165 } |
148 // close conversation view |
166 } |
149 //--------------------------------------------------------------- |
|
150 void MsgConversationBaseView::openContactDetails() |
|
151 { |
|
152 MsgUiUtilsManager uiUtilsManager(this); |
|
153 QModelIndex aIndex = ConversationsEngine::instance()->getConversationsModel()->index(0, 0); |
|
154 qint32 contactId = aIndex.data(ContactId).toLongLong(); |
|
155 uiUtilsManager.openContactDetails(contactId); |
|
156 } |
|
157 |
167 |
158 //--------------------------------------------------------------- |
168 //--------------------------------------------------------------- |
159 // MsgConversationBaseView::clearContent |
169 // MsgConversationBaseView::clearContent |
160 // clears conversation view content |
170 // clears conversation view content |
161 //--------------------------------------------------------------- |
171 //--------------------------------------------------------------- |
162 void MsgConversationBaseView::clearContent() |
172 void MsgConversationBaseView::clearContent() |
163 { |
173 { |
164 ConversationsEngine::instance()->clearConversations(); |
174 ConversationsEngine::instance()->clearConversations(); |
165 mConversationView->clearEditors(); |
175 mConversationView->clearEditors(); |
166 } |
176 } |
|
177 |
|
178 //--------------------------------------------------------------- |
|
179 // MsgConversationBaseView::handleOk |
|
180 // |
|
181 //--------------------------------------------------------------- |
|
182 void MsgConversationBaseView::handleOk(const QVariant& result) |
|
183 { |
|
184 Q_UNUSED(result) |
|
185 } |
|
186 |
|
187 //--------------------------------------------------------------- |
|
188 // MsgConversationBaseView::handleError |
|
189 // |
|
190 //--------------------------------------------------------------- |
|
191 void MsgConversationBaseView::handleError(int errorCode, const QString& errorMessage) |
|
192 { |
|
193 Q_UNUSED(errorMessage) |
|
194 Q_UNUSED(errorCode) |
|
195 } |
|
196 |
|
197 //--------------------------------------------------------------- |
|
198 // MsgConversationBaseView::doDelayedConstruction |
|
199 // |
|
200 //--------------------------------------------------------------- |
|
201 void MsgConversationBaseView::doDelayedConstruction() |
|
202 { |
|
203 disconnect(this->mainWindow(),SIGNAL(viewReady()),this,SLOT(doDelayedConstruction())); |
|
204 ConversationsEngine::instance()->fetchMoreConversations(); |
|
205 } |
|
206 |
|
207 //--------------------------------------------------------------- |
|
208 // MsgConversationBaseView::hideChrome |
|
209 // |
|
210 //--------------------------------------------------------------- |
|
211 void MsgConversationBaseView::hideChrome(bool hide) |
|
212 { |
|
213 if(hide) |
|
214 { |
|
215 this->hideItems(Hb::StatusBarItem | Hb::TitleBarItem); |
|
216 this->setContentFullScreen(true); |
|
217 |
|
218 if(this->mainWindow()->orientation() == Qt::Horizontal) |
|
219 { |
|
220 mMainLayout->removeItem(mContactCard); |
|
221 mContactCard->hide(); |
|
222 } |
|
223 } |
|
224 else |
|
225 { |
|
226 this->showItems(Hb::StatusBarItem | Hb::TitleBarItem); |
|
227 this->setContentFullScreen(false); |
|
228 |
|
229 if(!mContactCard->isVisible()) |
|
230 { |
|
231 mMainLayout->insertItem(0,mContactCard); |
|
232 mContactCard->show(); |
|
233 } |
|
234 } |
|
235 } |
|
236 |
167 // EOF |
237 // EOF |