44 const QString POPUP_LIST_FRAME("qtg_fr_popup_list_normal"); |
47 const QString POPUP_LIST_FRAME("qtg_fr_popup_list_normal"); |
45 const QString NEW_MESSAGE_ICON("qtg_mono_create_message"); |
48 const QString NEW_MESSAGE_ICON("qtg_mono_create_message"); |
46 const QString SORT_ICON("qtg_mono_sort"); |
49 const QString SORT_ICON("qtg_mono_sort"); |
47 |
50 |
48 // LOCALIZATION CONSTANTS |
51 // LOCALIZATION CONSTANTS |
49 #define LOC_COMMON_OPEN hbTrId("txt_common_menu_open") |
52 |
50 #define LOC_COMMON_DELETE hbTrId("txt_common_menu_delete") |
53 // Long Tap |
51 #define VIEW_HEADING "Drafts" |
54 #define LOC_COMMON_OPEN hbTrId("txt_common_menu_open") |
52 #define MENU_DELETE_ALL "Delete all drafts" |
55 #define LOC_COMMON_DELETE hbTrId("txt_common_menu_delete") |
53 #define TB_VIEW_EXTN "View" |
56 |
54 #define TB_NEW_MESSAGE "New message" |
57 // View heading |
55 #define TB_EXTN_DRAFTS "Drafts" |
58 #define LOC_DLV_HEADING hbTrId("txt_messaging_title_drafts") |
56 #define TB_EXTN_CONVERSATIONS "Conversations" |
59 |
|
60 // Menu items |
|
61 #define LOC_MENU_DELETE_ALL hbTrId("txt_messaging_opt_delete_all") |
|
62 |
|
63 // Toolbar & toolbar exension |
|
64 #define LOC_TB_EXTN_DRAFTS hbTrId("txt_messaging_button_drafts") |
|
65 #define LOC_TB_EXTN_CONVERSATIONS hbTrId("txt_messaging_button_conversations") |
|
66 |
|
67 // Confirmation note |
|
68 #define LOC_DELETE_MESSAGE hbTrId("txt_messaging_dialog_delete_message") |
|
69 #define LOC_DELETE_ALL_DRAFTS hbTrId("txt_messaging_dialog_delate_all_drafts") |
|
70 #define LOC_BUTTON_DELETE hbTrId("txt_common_button_delete") |
|
71 #define LOC_BUTTON_CANCEL hbTrId("txt_common_button_cancel") |
57 |
72 |
58 //--------------------------------------------------------------- |
73 //--------------------------------------------------------------- |
59 // DraftsListView::DraftsListView |
74 // DraftsListView::DraftsListView |
60 // @see header |
75 // @see header |
61 //--------------------------------------------------------------- |
76 //--------------------------------------------------------------- |
62 DraftsListView::DraftsListView(QGraphicsItem *parent) : |
77 DraftsListView::DraftsListView(QGraphicsItem *parent) : |
63 MsgBaseView(parent), mListView(0), mViewExtnList(0) |
78 MsgBaseView(parent), mListView(0), mViewExtnList(0), mToolBar(0) |
64 { |
79 { |
65 createView(); |
80 // Delayed loading. |
|
81 connect(this->mainWindow(), SIGNAL(viewReady()), this, SLOT(doDelayedLoading())); |
66 } |
82 } |
67 |
83 |
68 //--------------------------------------------------------------- |
84 //--------------------------------------------------------------- |
69 // DraftsListView::~DraftsListView |
85 // DraftsListView::~DraftsListView |
70 // @see header |
86 // @see header |
72 DraftsListView::~DraftsListView() |
88 DraftsListView::~DraftsListView() |
73 { |
89 { |
74 } |
90 } |
75 |
91 |
76 //--------------------------------------------------------------- |
92 //--------------------------------------------------------------- |
77 // DraftsListView::createView |
93 // DraftsListView::setupMenu |
78 // @see header |
94 // @see header |
79 //--------------------------------------------------------------- |
95 //--------------------------------------------------------------- |
80 void DraftsListView::createView() |
96 void DraftsListView::setupMenu() |
|
97 { |
|
98 QAbstractItemModel *model = mListView->model(); |
|
99 |
|
100 // Menu items are added/removed based on the item count. |
|
101 connect(mListView->model(), SIGNAL(rowsInserted(QModelIndex, int, int)), this, |
|
102 SLOT(handleModelChanged()), Qt::UniqueConnection); |
|
103 connect(mListView->model(), SIGNAL(rowsRemoved(QModelIndex, int, int)), this, |
|
104 SLOT(handleModelChanged()), Qt::UniqueConnection); |
|
105 } |
|
106 |
|
107 //--------------------------------------------------------------- |
|
108 // DraftsListView::setupToolbar |
|
109 // @see header |
|
110 //--------------------------------------------------------------- |
|
111 void DraftsListView::setupToolbar() |
|
112 { |
|
113 if (!mToolBar) { |
|
114 mToolBar = this->toolBar(); |
|
115 mToolBar->setOrientation(Qt::Horizontal); |
|
116 |
|
117 // Create & setup ToolBar Extension |
|
118 HbToolBarExtension *viewExtn = new HbToolBarExtension(); |
|
119 HbAction *viewAction = mToolBar->addExtension(viewExtn); |
|
120 viewAction->setIcon(HbIcon(SORT_ICON)); |
|
121 |
|
122 mViewExtnList = new HbListWidget(); |
|
123 mViewExtnList->addItem(LOC_TB_EXTN_DRAFTS); |
|
124 mViewExtnList->addItem(LOC_TB_EXTN_CONVERSATIONS); |
|
125 |
|
126 HbListViewItem *prototype = mViewExtnList->listItemPrototype(); |
|
127 HbFrameBackground frame(POPUP_LIST_FRAME, HbFrameDrawer::NinePieces); |
|
128 prototype->setDefaultFrame(frame); |
|
129 |
|
130 connect(mViewExtnList, SIGNAL(activated(HbListWidgetItem*)), this, |
|
131 SLOT(handleViewExtnActivated(HbListWidgetItem*))); |
|
132 connect(mViewExtnList, SIGNAL(released(HbListWidgetItem*)), viewExtn, SLOT(close())); |
|
133 |
|
134 viewExtn->setContentWidget(mViewExtnList); |
|
135 |
|
136 // Create & setup 2nd ToolBar button. |
|
137 mToolBar->addAction(HbIcon(NEW_MESSAGE_ICON), "", this, SLOT(createNewMessage())); |
|
138 } |
|
139 } |
|
140 |
|
141 //--------------------------------------------------------------- |
|
142 // DraftsListView::setupListView |
|
143 // @see header |
|
144 //--------------------------------------------------------------- |
|
145 void DraftsListView::setupListView() |
|
146 { |
|
147 if (!mListView) { |
|
148 // Create parent layout. |
|
149 QGraphicsLinearLayout *mainLayout = new QGraphicsLinearLayout(Qt::Vertical); |
|
150 mainLayout->setContentsMargins(0, 0, 0, 0); |
|
151 mainLayout->setSpacing(0); |
|
152 |
|
153 // Create view heading. |
|
154 HbGroupBox *viewHeading = new HbGroupBox(); |
|
155 viewHeading->setHeading(LOC_DLV_HEADING); |
|
156 |
|
157 // Create List View. |
|
158 mListView = new HbListView(this); |
|
159 |
|
160 mListView->setScrollingStyle(HbScrollArea::PanOrFlick); |
|
161 mListView->setItemRecycling(true); |
|
162 mListView->setUniformItemSizes(true); |
|
163 mListView->setClampingStyle(HbScrollArea::BounceBackClamping); |
|
164 |
|
165 // Register the custorm css path. |
|
166 HbStyleLoader::registerFilePath(":/xml/hblistviewitem.css"); |
|
167 // mListView->setLayoutName("custom"); |
|
168 |
|
169 // Set list item properties. |
|
170 HbListViewItem *prototype = mListView->listItemPrototype(); |
|
171 prototype->setGraphicsSize(HbListViewItem::SmallIcon); |
|
172 prototype->setStretchingStyle(HbListViewItem::StretchLandscape); |
|
173 prototype->setSecondaryTextRowCount(1, 1); |
|
174 HbFrameBackground frame(LIST_ITEM_FRAME, HbFrameDrawer::NinePieces); |
|
175 prototype->setDefaultFrame(frame); |
|
176 |
|
177 // Create and set model |
|
178 QSortFilterProxyModel *proxyModel = new QSortFilterProxyModel(this); |
|
179 proxyModel->setDynamicSortFilter(true); |
|
180 proxyModel->setSourceModel(ConversationsEngine::instance()->getDraftsModel()); |
|
181 proxyModel->setSortRole(TimeStamp); |
|
182 proxyModel->sort(0, Qt::DescendingOrder); |
|
183 mListView->setModel(proxyModel); |
|
184 |
|
185 // Short & Long Taps |
|
186 connect(mListView, SIGNAL(activated(QModelIndex)), this, |
|
187 SLOT(openDraftMessage(QModelIndex))); |
|
188 connect(mListView, SIGNAL(longPressed(HbAbstractViewItem*,QPointF)), this, |
|
189 SLOT(handleLongPressed(HbAbstractViewItem*,QPointF))); |
|
190 |
|
191 // Add all widgets to main layout. |
|
192 mainLayout->addItem(viewHeading); |
|
193 mainLayout->addItem(mListView); |
|
194 |
|
195 this->setLayout(mainLayout); |
|
196 } |
|
197 } |
|
198 |
|
199 //------------------------------------------------------------------------------ |
|
200 // DraftsListView::doDelayedLoading |
|
201 // @see header |
|
202 //------------------------------------------------------------------------------ |
|
203 void DraftsListView::doDelayedLoading() |
81 { |
204 { |
82 setupToolbar(); |
205 setupToolbar(); |
|
206 setupListView(); |
83 setupMenu(); |
207 setupMenu(); |
84 setupListView(); |
208 disconnect(this->mainWindow(), SIGNAL(viewReady()), this, SLOT(doDelayedLoading())); |
85 } |
|
86 |
|
87 //--------------------------------------------------------------- |
|
88 // DraftsListView::setupMenu |
|
89 // @see header |
|
90 //--------------------------------------------------------------- |
|
91 void DraftsListView::setupMenu() |
|
92 { |
|
93 } |
|
94 |
|
95 //--------------------------------------------------------------- |
|
96 // DraftsListView::setupToolbar |
|
97 // @see header |
|
98 //--------------------------------------------------------------- |
|
99 void DraftsListView::setupToolbar() |
|
100 { |
|
101 HbToolBar *toolBar = this->toolBar(); |
|
102 toolBar->setOrientation(Qt::Horizontal); |
|
103 |
|
104 // Create & setup ToolBar Extension |
|
105 HbToolBarExtension *viewExtn = new HbToolBarExtension(); |
|
106 HbAction *viewAction = toolBar->addExtension(viewExtn); |
|
107 viewAction->setText(TB_VIEW_EXTN); |
|
108 viewAction->setIcon(HbIcon(SORT_ICON)); |
|
109 |
|
110 mViewExtnList = new HbListWidget(); |
|
111 mViewExtnList->addItem(TB_EXTN_DRAFTS); |
|
112 mViewExtnList->addItem(TB_EXTN_CONVERSATIONS); |
|
113 |
|
114 HbListViewItem *prototype = mViewExtnList->listItemPrototype(); |
|
115 HbFrameBackground frame(POPUP_LIST_FRAME, HbFrameDrawer::NinePieces); |
|
116 prototype->setDefaultFrame(frame); |
|
117 |
|
118 connect(mViewExtnList, SIGNAL(activated(HbListWidgetItem*)), this, |
|
119 SLOT(handleViewExtnActivated(HbListWidgetItem*))); |
|
120 connect(mViewExtnList, SIGNAL(activated(HbListWidgetItem*)), viewExtn, SLOT(close())); |
|
121 |
|
122 viewExtn->setContentWidget(mViewExtnList); |
|
123 |
|
124 // Create & setup 2nd ToolBar button. |
|
125 HbAction* newMessageAction = new HbAction(HbIcon(NEW_MESSAGE_ICON), TB_NEW_MESSAGE, this); |
|
126 connect(newMessageAction, SIGNAL(triggered()), this, SLOT(createNewMessage())); |
|
127 toolBar->addAction(newMessageAction); |
|
128 } |
|
129 |
|
130 //--------------------------------------------------------------- |
|
131 // DraftsListView::setupListView |
|
132 // @see header |
|
133 //--------------------------------------------------------------- |
|
134 void DraftsListView::setupListView() |
|
135 { |
|
136 // Create parent layout. |
|
137 QGraphicsLinearLayout *mainLayout = new QGraphicsLinearLayout(Qt::Vertical); |
|
138 mainLayout->setContentsMargins(0, 0, 0, 0); |
|
139 mainLayout->setSpacing(0); |
|
140 |
|
141 // Create view heading. |
|
142 HbGroupBox *viewHeading = new HbGroupBox(); |
|
143 viewHeading->setTitleText(VIEW_HEADING); |
|
144 |
|
145 // Create List View. |
|
146 mListView = new HbListView(this); |
|
147 mListView->setScrollingStyle(HbScrollArea::PanOrFlick); |
|
148 mListView->setItemRecycling(true); |
|
149 mListView->setUniformItemSizes(true); |
|
150 mListView->setClampingStyle(HbScrollArea::BounceBackClamping); |
|
151 |
|
152 // Register the custorm css path. |
|
153 HbStyleLoader::registerFilePath(":/hblistviewitem.css"); |
|
154 // mListView->setLayoutName("custom"); |
|
155 |
|
156 // Set list item properties. |
|
157 HbListViewItem *prototype = mListView->listItemPrototype(); |
|
158 prototype->setGraphicsSize(HbListViewItem::SmallIcon); |
|
159 prototype->setStretchingStyle(HbListViewItem::StretchLandscape); |
|
160 prototype->setSecondaryTextRowCount(1, 1); |
|
161 HbFrameBackground frame(LIST_ITEM_FRAME, HbFrameDrawer::NinePieces); |
|
162 prototype->setDefaultFrame(frame); |
|
163 |
|
164 // Create and set model |
|
165 QSortFilterProxyModel *proxyModel = new QSortFilterProxyModel(this); |
|
166 proxyModel->setDynamicSortFilter(true); |
|
167 proxyModel->setSourceModel(ConversationsEngine::instance()->getDraftsModel()); |
|
168 proxyModel->setSortRole(TimeStamp); |
|
169 proxyModel->sort(0, Qt::DescendingOrder); |
|
170 mListView->setModel(proxyModel); |
|
171 |
|
172 // Short & Long Taps |
|
173 connect(mListView, SIGNAL(activated(QModelIndex)), this, SLOT(openDraftMessage(QModelIndex))); |
|
174 connect(mListView, SIGNAL(longPressed(HbAbstractViewItem*,QPointF)), this, |
|
175 SLOT(handleLongPressed(HbAbstractViewItem*,QPointF))); |
|
176 |
|
177 // Add all widgets to main layout. |
|
178 mainLayout->addItem(viewHeading); |
|
179 mainLayout->addItem(mListView); |
|
180 |
|
181 this->setLayout(mainLayout); |
|
182 } |
209 } |
183 |
210 |
184 //------------------------------------------------------------------------------ |
211 //------------------------------------------------------------------------------ |
185 // DraftsListView::openDraftMessage |
212 // DraftsListView::openDraftMessage |
186 // @see header |
213 // @see header |