ui/views/listview/src/glxlistview.cpp
changeset 26 c499df2dbb33
parent 24 99ad1390cd33
child 44 aa2fa096cbfb
equal deleted inserted replaced
24:99ad1390cd33 26:c499df2dbb33
    22 #include <hbtoolbar.h>
    22 #include <hbtoolbar.h>
    23 #include <hblistview.h>
    23 #include <hblistview.h>
    24 #include <hbmainwindow.h>
    24 #include <hbmainwindow.h>
    25 #include <hbdocumentloader.h>
    25 #include <hbdocumentloader.h>
    26 #include <hbabstractviewitem.h>
    26 #include <hbabstractviewitem.h>
    27 #include <HbListViewItem.h>
    27 #include <hblistviewitem.h>
    28 //User Includes
    28 //User Includes
    29 #include "glxviewids.h"
    29 #include "glxviewids.h"
    30 #include "glxlistview.h"
    30 #include "glxlistview.h"
    31 #include "glxmodelparm.h"
    31 #include "glxmodelparm.h"
    32 #include "glxdocloaderdefs.h"
    32 #include "glxdocloaderdefs.h"
    33 #include "glxcommandhandlers.hrh"
    33 #include "glxcommandhandlers.hrh"
    34 
    34 
    35 
    35 
    36 GlxListView::GlxListView(HbMainWindow *window) : GlxView ( GLX_LISTVIEW_ID ), 
    36 GlxListView::GlxListView(HbMainWindow *window) 
    37              mListView(NULL), mView(NULL), mWindow(window), mModel ( NULL)
    37     : GlxView ( GLX_LISTVIEW_ID ), 
       
    38       mListView(NULL), 
       
    39       mView(NULL), 
       
    40       mWindow(window), 
       
    41       mModel ( NULL),
       
    42       mIsLongPress( false )
    38 {
    43 {
    39     qDebug("GlxListView::GlxListView()");
    44     qDebug("GlxListView::GlxListView()");
    40     mDocLoader = new HbDocumentLoader();
    45     mDocLoader = new HbDocumentLoader();
    41     setContentFullScreen( true );
    46     setContentFullScreen( true );
    42 }
    47 }
   101     disconnect(mListView, SIGNAL(longPressed( HbAbstractViewItem*, QPointF )),this, SLOT( indicateLongPress( HbAbstractViewItem*, QPointF ) ) );
   106     disconnect(mListView, SIGNAL(longPressed( HbAbstractViewItem*, QPointF )),this, SLOT( indicateLongPress( HbAbstractViewItem*, QPointF ) ) );
   102     disconnect( mListView, SIGNAL( scrollingEnded() ), this, SLOT( setVisvalWindowIndex() ) );
   107     disconnect( mListView, SIGNAL( scrollingEnded() ), this, SLOT( setVisvalWindowIndex() ) );
   103 }
   108 }
   104 
   109 
   105 void GlxListView::setVisvalWindowIndex()
   110 void GlxListView::setVisvalWindowIndex()
   106     {
   111 {
   107     QList< HbAbstractViewItem * >  visibleItemList =  mListView->visibleItems();
   112     QList< HbAbstractViewItem * >  visibleItemList =  mListView->visibleItems();
   108     qDebug("GlxListView::setVisvalWindowIndex() %d", visibleItemList.count());    
   113     qDebug("GlxListView::setVisvalWindowIndex() %d", visibleItemList.count());    
   109     
   114     
   110     if ( visibleItemList.count() <= 0 )
   115     if ( visibleItemList.count() <= 0 )
   111         return ;
   116         return ;
   116         
   121         
   117     if (  item->modelIndex().row() < 0 || item->modelIndex().row() >= mModel->rowCount() )
   122     if (  item->modelIndex().row() < 0 || item->modelIndex().row() >= mModel->rowCount() )
   118         return ;
   123         return ;
   119     
   124     
   120     mModel->setData( item->modelIndex (), item->modelIndex().row(), GlxVisualWindowIndex);
   125     mModel->setData( item->modelIndex (), item->modelIndex().row(), GlxVisualWindowIndex);
   121     }
   126 }
   122 
   127 
   123 void GlxListView::loadListView()
   128 void GlxListView::loadListView()
   124 {
   129 {
   125     qDebug("GlxListView::loadListView()");
   130     qDebug("GlxListView::loadListView()");
   126     bool loaded = true;
   131     bool loaded = true;
   127     //Load the widgets accroding to the current Orientation
   132     //Load the widgets accroding to the current Orientation
   128     if (mListView == NULL )
   133     if (mListView == NULL ) {
   129         {
       
   130         mDocLoader->load(GLX_LISTVIEW_DOCMLPATH,&loaded);
   134         mDocLoader->load(GLX_LISTVIEW_DOCMLPATH,&loaded);
   131         if(loaded)
   135         if(loaded) {
   132             {
       
   133             //retrieve the widgets
   136             //retrieve the widgets
   134             mView = static_cast<HbView*>(mDocLoader->findWidget(QString(GLX_LISTVIEW_VIEW)));
   137             mView = static_cast<HbView*>(mDocLoader->findWidget(QString(GLX_LISTVIEW_VIEW)));
   135             mListView = static_cast<HbListView*>(mDocLoader->findWidget(QString(GLX_LISTVIEW_LIST)));
   138             mListView = static_cast<HbListView*>(mDocLoader->findWidget(QString(GLX_LISTVIEW_LIST)));
   136 
   139 
   137             if(mListView)
   140             if(mListView) { 
   138                 { 
       
   139                 //sets the widget
   141                 //sets the widget
   140                 setWidget((QGraphicsWidget*) mView);
   142                 setWidget((QGraphicsWidget*) mView);
   141                 }
   143             }
   142             }  
   144         }  
   143         HbListViewItem *prototype = mListView->listItemPrototype();
   145         HbListViewItem *prototype = mListView->listItemPrototype();
   144         prototype->setStretchingStyle(HbListViewItem::StretchLandscape);
   146         prototype->setStretchingStyle(HbListViewItem::StretchLandscape);
   145         }
   147     }
   146 }
   148 }
   147 
   149 
   148 void GlxListView::createListView()
   150 void GlxListView::createListView()
   149 {
   151 {
   150     qDebug("GlxListView::createListView()");
   152     qDebug("GlxListView::createListView()");
   154 
   156 
   155 GlxListView::~GlxListView()
   157 GlxListView::~GlxListView()
   156 {
   158 {
   157     qDebug("GlxListView::~GlxListView()");
   159     qDebug("GlxListView::~GlxListView()");
   158 
   160 
   159     if(widget())
   161     if(widget()) {
   160         {
       
   161         qDebug("GlxListView::~GlxListView() takeWidget");
   162         qDebug("GlxListView::~GlxListView() takeWidget");
   162         takeWidget();    
   163         takeWidget();    
   163         }       
   164     }       
   164 
   165 
   165     removeViewConnection();
   166     removeViewConnection();
   166 
   167 
   167     if(mListView)
   168     if(mListView) {
   168         {
       
   169         delete mListView;
   169         delete mListView;
   170         mListView = NULL;
   170         mListView = NULL;
   171         }
   171     }
   172 
   172 
   173     if(mView)
   173     if(mView) {
   174         {
       
   175         delete mView ;
   174         delete mView ;
   176         mView = NULL;
   175         mView = NULL;
   177         }
   176     }
   178     if(mDocLoader)
   177     
   179         {
   178     if(mDocLoader) {
   180         delete mDocLoader;
   179         delete mDocLoader;
   181         mDocLoader = NULL;
   180         mDocLoader = NULL;
   182         }    
   181     }
   183 }
   182 }
   184 
   183 
   185 void GlxListView::itemSelected(const QModelIndex &  index)
   184 void GlxListView::itemSelected(const QModelIndex &  index)
   186 {
   185 {
   187     qDebug("GlxListView::itemSelected() index = %d", index.row() );
   186     qDebug("GlxListView::itemSelected() index = %d", index.row() );
       
   187     if ( mIsLongPress ) {
       
   188         mIsLongPress = false ;
       
   189         return ;
       
   190     }
   188     if ( mModel ) {
   191     if ( mModel ) {
   189         mModel->setData( index, index.row(), GlxFocusIndexRole );
   192         mModel->setData( index, index.row(), GlxFocusIndexRole );
   190     }
   193     }
   191     emit actionTriggered( EGlxCmdAlbumGridOpen );
   194     emit actionTriggered( EGlxCmdAlbumGridOpen );
   192 }
   195 }
   195 void GlxListView::indicateLongPress(HbAbstractViewItem *item, QPointF coords)
   198 void GlxListView::indicateLongPress(HbAbstractViewItem *item, QPointF coords)
   196 {
   199 {
   197     qDebug() << "GlxListView:indicateLongPress Item " << item->modelIndex() << "long pressed at " << coords;
   200     qDebug() << "GlxListView:indicateLongPress Item " << item->modelIndex() << "long pressed at " << coords;
   198     if ( mModel ) {
   201     if ( mModel ) {
   199         mModel->setData( item->modelIndex(), item->modelIndex().row(), GlxFocusIndexRole );
   202         mModel->setData( item->modelIndex(), item->modelIndex().row(), GlxFocusIndexRole );
   200     }      
   203     }
       
   204     mIsLongPress = true;
   201     emit itemSpecificMenuTriggered(viewId(),coords);
   205     emit itemSpecificMenuTriggered(viewId(),coords);
   202 }
   206 }
   203 
   207