ui/views/listview/src/glxlistview.cpp
changeset 24 99ad1390cd33
parent 23 74c9f037fd5d
child 26 c499df2dbb33
equal deleted inserted replaced
23:74c9f037fd5d 24:99ad1390cd33
    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 
    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"
    52 
    52 
    53 void GlxListView::deActivate()
    53 void GlxListView::deActivate()
    54 {
    54 {
    55     qDebug("GlxListView::deActivate()");
    55     qDebug("GlxListView::deActivate()");
    56     disconnect(mWindow, SIGNAL(orientationChanged(Qt::Orientation)), this, SLOT(orientationChanged(Qt::Orientation)));
    56     disconnect(mWindow, SIGNAL(orientationChanged(Qt::Orientation)), this, SLOT(orientationChanged(Qt::Orientation)));
    57     takeToolBar(); //To:Do improved later
       
    58     emit toolBarChanged();
       
    59 }
    57 }
    60 
    58 
    61 void GlxListView::setModel(QAbstractItemModel *model) 
    59 void GlxListView::setModel(QAbstractItemModel *model) 
    62 {
    60 {
    63     qDebug("GlxListView::setModel()");
    61     qDebug("GlxListView::setModel()");
    65     mListView->setModel(mModel);
    63     mListView->setModel(mModel);
    66 }
    64 }
    67 
    65 
    68 void GlxListView::addToolBar( HbToolBar *toolBar ) 
    66 void GlxListView::addToolBar( HbToolBar *toolBar ) 
    69 {
    67 {
    70     //toolBar->setParent(this);
       
    71     if ( mListView ) {
       
    72         toolBar->setZValue(mListView->zValue());
       
    73     }
       
    74     setToolBar(toolBar) ;
    68     setToolBar(toolBar) ;
    75 }
    69 }
    76 
    70 
    77 void GlxListView::initializeView(QAbstractItemModel *model)
    71 void GlxListView::initializeView(QAbstractItemModel *model)
    78 {
    72 {
    95 void GlxListView::addViewConnection ()
    89 void GlxListView::addViewConnection ()
    96 {
    90 {
    97     qDebug("GlxListView::addViewConnection()");
    91     qDebug("GlxListView::addViewConnection()");
    98     connect(mListView, SIGNAL(activated(const QModelIndex &)), this, SLOT( itemSelected(const QModelIndex &)));
    92     connect(mListView, SIGNAL(activated(const QModelIndex &)), this, SLOT( itemSelected(const QModelIndex &)));
    99     connect(mListView, SIGNAL(longPressed( HbAbstractViewItem*, QPointF )),this, SLOT( indicateLongPress( HbAbstractViewItem*, QPointF ) ) );
    93     connect(mListView, SIGNAL(longPressed( HbAbstractViewItem*, QPointF )),this, SLOT( indicateLongPress( HbAbstractViewItem*, QPointF ) ) );
       
    94     connect( mListView, SIGNAL( scrollingEnded() ), this, SLOT( setVisvalWindowIndex() ) );
   100 }
    95 }
   101 
    96 
   102 void GlxListView::removeViewConnection()
    97 void GlxListView::removeViewConnection()
   103 {
    98 {
   104     qDebug("GlxListView::removeViewConnection()");
    99     qDebug("GlxListView::removeViewConnection()");
   105     disconnect(mListView, SIGNAL(activated(const QModelIndex &)), this, SLOT( itemSelected(const QModelIndex &)));
   100     disconnect(mListView, SIGNAL(activated(const QModelIndex &)), this, SLOT( itemSelected(const QModelIndex &)));
   106     disconnect(mListView, SIGNAL(longPressed( HbAbstractViewItem*, QPointF )),this, SLOT( indicateLongPress( HbAbstractViewItem*, QPointF ) ) );
   101     disconnect(mListView, SIGNAL(longPressed( HbAbstractViewItem*, QPointF )),this, SLOT( indicateLongPress( HbAbstractViewItem*, QPointF ) ) );
   107 }
   102     disconnect( mListView, SIGNAL( scrollingEnded() ), this, SLOT( setVisvalWindowIndex() ) );
       
   103 }
       
   104 
       
   105 void GlxListView::setVisvalWindowIndex()
       
   106     {
       
   107     QList< HbAbstractViewItem * >  visibleItemList =  mListView->visibleItems();
       
   108     qDebug("GlxListView::setVisvalWindowIndex() %d", visibleItemList.count());    
       
   109     
       
   110     if ( visibleItemList.count() <= 0 )
       
   111         return ;
       
   112 
       
   113     HbAbstractViewItem *item = visibleItemList.at(0);    
       
   114     if ( item == NULL ) 
       
   115         return ;
       
   116         
       
   117     if (  item->modelIndex().row() < 0 || item->modelIndex().row() >= mModel->rowCount() )
       
   118         return ;
       
   119     
       
   120     mModel->setData( item->modelIndex (), item->modelIndex().row(), GlxVisualWindowIndex);
       
   121     }
   108 
   122 
   109 void GlxListView::loadListView()
   123 void GlxListView::loadListView()
   110 {
   124 {
   111     qDebug("GlxListView::loadListView()");
   125     qDebug("GlxListView::loadListView()");
   112     bool loaded = true;
   126     bool loaded = true;
   123             if(mListView)
   137             if(mListView)
   124                 { 
   138                 { 
   125                 //sets the widget
   139                 //sets the widget
   126                 setWidget((QGraphicsWidget*) mView);
   140                 setWidget((QGraphicsWidget*) mView);
   127                 }
   141                 }
   128             }   
   142             }  
       
   143         HbListViewItem *prototype = mListView->listItemPrototype();
       
   144         prototype->setStretchingStyle(HbListViewItem::StretchLandscape);
   129         }
   145         }
   130 }
   146 }
   131 
   147 
   132 void GlxListView::createListView()
   148 void GlxListView::createListView()
   133 {
   149 {