diff -r 84d9eb65b26f -r 518b245aa84c messagingapp/msgui/msgapp/src/msglistview.cpp --- a/messagingapp/msgui/msgapp/src/msglistview.cpp Mon May 03 12:29:07 2010 +0300 +++ b/messagingapp/msgui/msgapp/src/msglistview.cpp Fri Jun 25 15:47:40 2010 +0530 @@ -60,10 +60,7 @@ #define LOC_OPEN hbTrId("txt_common_menu_open") #define LOC_SAVETO_CONTACTS hbTrId("txt_messaging_menu_save_to_contacts") #define LOC_DELETE_CONVERSATION hbTrId("txt_messaging_menu_delete_conversation") -#define LOC_OPEN_CONTACT_INFO hbTrId("txt_messaging_menu_open_contact_info") - -#define LOC_BUTTON_DELETE hbTrId("txt_common_button_delete") -#define LOC_BUTTON_CANCEL hbTrId("txt_common_button_cancel") +#define LOC_OPEN_CONTACT_INFO hbTrId("txt_messaging_menu_contact_info") //main menu #define LOC_SETTINGS hbTrId("txt_messaging_opt_settings") @@ -81,9 +78,28 @@ //--------------------------------------------------------------- MsgListView::MsgListView(QGraphicsItem *parent) : MsgBaseView(parent) -{ - connect(this->mainWindow(),SIGNAL(viewReady()),this,SLOT(doDelayedConstruction())); -} + { + //These changes are needed for splash implementation to avoid flicker + setupToolBar(); + setupMenu(); + + // Create parent layout. + mMainLayout = new QGraphicsLinearLayout(Qt::Vertical); + mMainLayout->setContentsMargins(0, 0, 0, 0); + mMainLayout->setSpacing(0); + + // Create view heading. + HbGroupBox *viewHeading = new HbGroupBox(); + viewHeading->setHeading(LOC_VIEW_HEADING); + + // Add view heading widget to main layout. + mMainLayout->addItem(viewHeading); + + this->setLayout(mMainLayout); + + connect(this->mainWindow(), SIGNAL(viewReady()), this, + SLOT(doDelayedConstruction())); + } //--------------------------------------------------------------- // MsgListView::~MsgListView @@ -107,7 +123,7 @@ // Create new menu HbMenu *contextMenu = new HbMenu(); - + contextMenu->setAttribute(Qt::WA_DeleteOnClose); //open menu option contextMenu->addAction(LOC_OPEN,this,SLOT(openConversation())); @@ -131,9 +147,8 @@ //delete conversation contextMenu->addAction(LOC_DELETE_CONVERSATION,this,SLOT(deleteItem())); - contextMenu->exec(point); - // Cleanup - delete contextMenu; + contextMenu->setPreferredPos(point); + contextMenu->show(); } } @@ -211,18 +226,10 @@ #ifdef _DEBUG_TRACES_ qDebug() << "Inside MsgListView::deleteItem"; #endif - - QModelIndex index = mMsgList->currentIndex(); - qint64 conversationId = index.data(ConversationId).toLongLong(); - //confirmation dialog. - bool result = HbMessageBox::question(LOC_DIALOG_DELETE_CONVERSATION, - LOC_BUTTON_DELETE, LOC_BUTTON_CANCEL); - if (result) - { - ConversationsEngine::instance()->deleteConversations(conversationId); - } - + HbMessageBox::question(LOC_DIALOG_DELETE_CONVERSATION, + this,SLOT(onDialogDeleteMsg(HbAction*)), + HbMessageBox::Delete | HbMessageBox::Cancel); #ifdef _DEBUG_TRACES_ qDebug() << " Leaving MsgConversationView::deleteItem"; #endif @@ -233,19 +240,9 @@ // @see header //--------------------------------------------------------------- void MsgListView::setupListView() -{ - // Create parent layout. - QGraphicsLinearLayout *mainLayout = new QGraphicsLinearLayout(Qt::Vertical); - mainLayout->setContentsMargins(0, 0, 0, 0); - mainLayout->setSpacing(0); - - // Create view heading. - HbGroupBox *viewHeading = new HbGroupBox(); - viewHeading->setHeading(LOC_VIEW_HEADING); - + { // Register the custorm css path. - HbStyleLoader::registerFilePath(":/xml/msglistviewitem.css"); - HbStyleLoader::registerFilePath(":/xml/msglistviewitem.widgetml"); + HbStyleLoader::registerFilePath(":/clv"); mMsgList = new HbListView(this); mMsgList->setScrollingStyle(HbScrollArea::PanOrFlick); @@ -253,37 +250,29 @@ mMsgList->setLayoutName("custom"); mMsgList->setItemRecycling(true); - mMsgList->setUniformItemSizes(true); + mMsgList->setUniformItemSizes(true); MsgListViewItem *prototype = new MsgListViewItem(this); mMsgList->setItemPrototype(prototype); - - // Set proxy model - QSortFilterProxyModel* proxyModel = new QSortFilterProxyModel(this); - proxyModel->setDynamicSortFilter(true); - proxyModel->setSourceModel(ConversationsEngine::instance()->getConversationsSummaryModel()); - proxyModel->setSortRole(TimeStamp); - proxyModel->sort(0, Qt::DescendingOrder); - - mMsgList->setModel(proxyModel); - - connect(ConversationsEngine::instance(), SIGNAL(conversationListModelPopulated()), - this, SLOT(populateListView())); - + mMsgList->setModel(ConversationsEngine::instance()->getConversationsSummaryModel()); + // Single tap list item - connect(mMsgList, SIGNAL(activated(const QModelIndex&)), - this, SLOT(openConversation(const QModelIndex&))); + connect(mMsgList, SIGNAL(activated(const QModelIndex&)), this, + SLOT(openConversation(const QModelIndex&))); // Long tap list item - connect(mMsgList, SIGNAL(longPressed(HbAbstractViewItem*, const QPointF&)), - this, SLOT(longPressed(HbAbstractViewItem*, const QPointF&))); + connect(mMsgList, + SIGNAL(longPressed(HbAbstractViewItem*, const QPointF&)), this, + SLOT(longPressed(HbAbstractViewItem*, const QPointF&))); - // Add all widgets to main layout. - mainLayout->addItem(viewHeading); - mainLayout->addItem(mMsgList); + // enable tap after delete is completed + connect(ConversationsEngine::instance(), + SIGNAL(conversationListEntryDeleted( int )), this, + SLOT(enableListitem( int ))); - this->setLayout(mainLayout); -} + // Add list view to main layout. + mMainLayout->addItem(mMsgList); + } //--------------------------------------------------------------- // MsgListView::addMenu @@ -312,6 +301,7 @@ viewAction->setIcon(HbIcon(SORT_ICON)); mViewExtnList = new HbListWidget(); + mViewExtnList->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Fixed); mViewExtnList->addItem(LOC_TB_EXTN_DRAFTS); mViewExtnList->addItem(LOC_TB_EXTN_CONVERSATIONS); @@ -350,10 +340,8 @@ // @see header //--------------------------------------------------------------- void MsgListView::doDelayedConstruction() - { - setupToolBar(); + { setupListView(); - setupMenu(); disconnect(this->mainWindow(),SIGNAL(viewReady()),this,SLOT(doDelayedConstruction())); } @@ -423,4 +411,51 @@ delete request; } +//--------------------------------------------------------------- +// MsgListView::onDialogDeleteMsg +// @see header +//--------------------------------------------------------------- +void MsgListView::onDialogDeleteMsg(HbAction* action) + { + HbMessageBox *dlg = qobject_cast (sender()); + if (action == dlg->actions().at(0)) + { + QModelIndex index = mMsgList->currentIndex(); + if (index.isValid()) + { + HbAbstractViewItem *item = mMsgList->currentViewItem(); + item->ungrabGesture(Qt::TapGesture); + qint64 conversationId = index.data(ConversationId).toLongLong(); + + ConversationsEngine::instance()->deleteConversations( + conversationId); + + } + + } + } + +//--------------------------------------------------------------- +// MsgListView::enableListitem +// @see header +//--------------------------------------------------------------- +void MsgListView::enableListitem(int conversationId) + { + QAbstractItemModel* proxyModel = mMsgList->model(); + QModelIndexList indexList = proxyModel->match(proxyModel->index(0, 0), + ConversationId, conversationId, 1, Qt::MatchExactly); + HbAbstractViewItem* item = NULL; + int count = indexList.count(); + // only item is expected to be the result of the above match function + if (1 == count) + { + item = mMsgList->itemByIndex(indexList[0]); + if (item) + { + item->grabGesture(Qt::TapGesture); + } + } + + } + //EOF