messagingapp/msgui/msgapp/src/msglistview.cpp
branchGCC_SURGE
changeset 47 5b14749788d7
parent 27 e4592d119491
parent 44 36f374c67aa8
--- a/messagingapp/msgui/msgapp/src/msglistview.cpp	Thu Jun 17 09:57:06 2010 +0100
+++ b/messagingapp/msgui/msgapp/src/msglistview.cpp	Thu Jul 22 16:32:06 2010 +0100
@@ -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")
@@ -80,11 +77,29 @@
 // @see header
 //---------------------------------------------------------------
 MsgListView::MsgListView(QGraphicsItem *parent) :
-    MsgBaseView(parent),
-    mItemLongPressed(false)
-{
-    connect(this->mainWindow(),SIGNAL(viewReady()),this,SLOT(doDelayedConstruction()));
-}
+    MsgBaseView(parent)
+    {
+    //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
@@ -101,7 +116,6 @@
 //---------------------------------------------------------------
 void MsgListView::longPressed(HbAbstractViewItem* viewItem, const QPointF& point)
 {
-    mItemLongPressed = true;
     if (this->isVisible()) {
         // Set the current index as the present Item's index.
         // By default it will not be set.
@@ -144,11 +158,6 @@
 //---------------------------------------------------------------
 void MsgListView::openConversation(const QModelIndex& index)
 {
-    if(mItemLongPressed)
-     {
-     mItemLongPressed = false;
-     return;
-     }
     //TODO: model populating possibilities.
     if (index.isValid()) {
         QVariant conversationId = index.data(ConversationId);
@@ -219,8 +228,8 @@
 #endif
     //confirmation dialog.
     HbMessageBox::question(LOC_DIALOG_DELETE_CONVERSATION,
-                                this,SLOT(onDialogDeleteMsg(HbAction*)),
-                                LOC_BUTTON_DELETE, LOC_BUTTON_CANCEL);    
+                           this,SLOT(onDialogDeleteMsg(HbAction*)),
+                           HbMessageBox::Delete | HbMessageBox::Cancel);    
 #ifdef _DEBUG_TRACES_	
     qDebug() << " Leaving MsgConversationView::deleteItem";
 #endif
@@ -231,16 +240,7 @@
 // @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(":/clv");
 
@@ -250,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
@@ -309,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);
 
@@ -347,10 +340,8 @@
 // @see header
 //---------------------------------------------------------------
 void MsgListView::doDelayedConstruction()
-    {
-    setupToolBar();    
+    {    
     setupListView();
-    setupMenu();
     
     disconnect(this->mainWindow(),SIGNAL(viewReady()),this,SLOT(doDelayedConstruction()));
     }
@@ -425,17 +416,46 @@
 // @see header
 //---------------------------------------------------------------
 void MsgListView::onDialogDeleteMsg(HbAction* action)
-{
+    {
     HbMessageBox *dlg = qobject_cast<HbMessageBox*> (sender());
-    if (action == dlg->actions().at(0)) {
-        QModelIndex index = mMsgList->currentIndex();
-        if(index.isValid())
+    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);    
+
+            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