messagingapp/msgui/msgapp/src/msglistview.cpp
changeset 34 84197e66a4bd
parent 31 ebfee66fde93
child 44 36f374c67aa8
equal deleted inserted replaced
31:ebfee66fde93 34:84197e66a4bd
    78 //---------------------------------------------------------------
    78 //---------------------------------------------------------------
    79 // MsgListView::MsgListView
    79 // MsgListView::MsgListView
    80 // @see header
    80 // @see header
    81 //---------------------------------------------------------------
    81 //---------------------------------------------------------------
    82 MsgListView::MsgListView(QGraphicsItem *parent) :
    82 MsgListView::MsgListView(QGraphicsItem *parent) :
    83     MsgBaseView(parent),
    83     MsgBaseView(parent)
    84     mItemLongPressed(false)
    84 {
    85 {
    85     //These changes are needed for splash implementation to avoid flicker
       
    86     setupToolBar();    
       
    87     setupMenu();
       
    88 
       
    89     // Create parent layout.
       
    90     mMainLayout = new QGraphicsLinearLayout(Qt::Vertical);
       
    91     mMainLayout->setContentsMargins(0, 0, 0, 0);
       
    92     mMainLayout->setSpacing(0);
       
    93     
       
    94     // Create view heading.
       
    95     HbGroupBox *viewHeading = new HbGroupBox();
       
    96     viewHeading->setHeading(LOC_VIEW_HEADING);
       
    97     
       
    98     // Add view heading widget to main layout.
       
    99     mMainLayout->addItem(viewHeading);
       
   100 
       
   101     this->setLayout(mMainLayout);
       
   102 
    86     connect(this->mainWindow(),SIGNAL(viewReady()),this,SLOT(doDelayedConstruction()));
   103     connect(this->mainWindow(),SIGNAL(viewReady()),this,SLOT(doDelayedConstruction()));
    87 }
   104 }
    88 
   105 
    89 //---------------------------------------------------------------
   106 //---------------------------------------------------------------
    90 // MsgListView::~MsgListView
   107 // MsgListView::~MsgListView
    99 // MsgListView::longPressed
   116 // MsgListView::longPressed
   100 // @see header
   117 // @see header
   101 //---------------------------------------------------------------
   118 //---------------------------------------------------------------
   102 void MsgListView::longPressed(HbAbstractViewItem* viewItem, const QPointF& point)
   119 void MsgListView::longPressed(HbAbstractViewItem* viewItem, const QPointF& point)
   103 {
   120 {
   104     mItemLongPressed = true;
       
   105     if (this->isVisible()) {
   121     if (this->isVisible()) {
   106         // Set the current index as the present Item's index.
   122         // Set the current index as the present Item's index.
   107         // By default it will not be set.
   123         // By default it will not be set.
   108         mMsgList->setCurrentIndex(viewItem->modelIndex(), QItemSelectionModel::Select);
   124         mMsgList->setCurrentIndex(viewItem->modelIndex(), QItemSelectionModel::Select);
   109 
   125 
   142 // MsgListView::openConversation
   158 // MsgListView::openConversation
   143 // @see header
   159 // @see header
   144 //---------------------------------------------------------------
   160 //---------------------------------------------------------------
   145 void MsgListView::openConversation(const QModelIndex& index)
   161 void MsgListView::openConversation(const QModelIndex& index)
   146 {
   162 {
   147     if(mItemLongPressed)
       
   148      {
       
   149      mItemLongPressed = false;
       
   150      return;
       
   151      }
       
   152     //TODO: model populating possibilities.
   163     //TODO: model populating possibilities.
   153     if (index.isValid()) {
   164     if (index.isValid()) {
   154         QVariant conversationId = index.data(ConversationId);
   165         QVariant conversationId = index.data(ConversationId);
   155 
   166 
   156         // Launch conversation view
   167         // Launch conversation view
   230 // MsgListView::setupView
   241 // MsgListView::setupView
   231 // @see header
   242 // @see header
   232 //---------------------------------------------------------------
   243 //---------------------------------------------------------------
   233 void MsgListView::setupListView()
   244 void MsgListView::setupListView()
   234 {
   245 {
   235     // Create parent layout.
       
   236     QGraphicsLinearLayout *mainLayout = new QGraphicsLinearLayout(Qt::Vertical);
       
   237     mainLayout->setContentsMargins(0, 0, 0, 0);
       
   238     mainLayout->setSpacing(0);
       
   239 
       
   240     // Create view heading.
       
   241     HbGroupBox *viewHeading = new HbGroupBox();
       
   242     viewHeading->setHeading(LOC_VIEW_HEADING);
       
   243 
       
   244     // Register the custorm css path.
   246     // Register the custorm css path.
   245     HbStyleLoader::registerFilePath(":/clv");
   247     HbStyleLoader::registerFilePath(":/clv");
   246 
   248 
   247     mMsgList = new HbListView(this);
   249     mMsgList = new HbListView(this);
   248     mMsgList->setScrollingStyle(HbScrollArea::PanOrFlick);
   250     mMsgList->setScrollingStyle(HbScrollArea::PanOrFlick);
   273 
   275 
   274     // Long tap list item
   276     // Long tap list item
   275     connect(mMsgList, SIGNAL(longPressed(HbAbstractViewItem*, const QPointF&)),
   277     connect(mMsgList, SIGNAL(longPressed(HbAbstractViewItem*, const QPointF&)),
   276             this, SLOT(longPressed(HbAbstractViewItem*, const QPointF&)));
   278             this, SLOT(longPressed(HbAbstractViewItem*, const QPointF&)));
   277 
   279 
   278     // Add all widgets to main layout.
   280     // Add list view to main layout.
   279     mainLayout->addItem(viewHeading);
   281     mMainLayout->addItem(mMsgList);
   280     mainLayout->addItem(mMsgList);
       
   281 
       
   282     this->setLayout(mainLayout);
       
   283 }
   282 }
   284 
   283 
   285 //---------------------------------------------------------------
   284 //---------------------------------------------------------------
   286 // MsgListView::addMenu
   285 // MsgListView::addMenu
   287 // @see header
   286 // @see header
   345 //---------------------------------------------------------------
   344 //---------------------------------------------------------------
   346 // MsgListView::doDelayedConstruction
   345 // MsgListView::doDelayedConstruction
   347 // @see header
   346 // @see header
   348 //---------------------------------------------------------------
   347 //---------------------------------------------------------------
   349 void MsgListView::doDelayedConstruction()
   348 void MsgListView::doDelayedConstruction()
   350     {
   349     {    
   351     setupToolBar();    
       
   352     setupListView();
   350     setupListView();
   353     setupMenu();
       
   354     
   351     
   355     disconnect(this->mainWindow(),SIGNAL(viewReady()),this,SLOT(doDelayedConstruction()));
   352     disconnect(this->mainWindow(),SIGNAL(viewReady()),this,SLOT(doDelayedConstruction()));
   356     }
   353     }
   357 
   354 
   358 //---------------------------------------------------------------
   355 //---------------------------------------------------------------