ganeswidgets/src/hgwidgets_p.cpp
changeset 12 6c0ec0ccd2d4
parent 7 5ebec3429918
child 14 645b870db620
equal deleted inserted replaced
11:42505cd701c6 12:6c0ec0ccd2d4
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 #include <QApplication>
    18 #include <QApplication>
    19 #include <HbScrollbar>
    19 #include <HbScrollbar>
       
    20 #include <HbTheme>
    20 #include <hgwidgets/hgwidgets.h>
    21 #include <hgwidgets/hgwidgets.h>
    21 
    22 
    22 #include "hgwidgets_p.h"
    23 #include "hgwidgets_p.h"
    23 #include "hgcontainer.h"
    24 #include "hgcontainer.h"
    24 #include "hgcoverflowcontainer.h"
    25 #include "hgcoverflowcontainer.h"
    80     q->connect(mContainer, SIGNAL(longPressed(const QModelIndex&, const QPointF &)),
    81     q->connect(mContainer, SIGNAL(longPressed(const QModelIndex&, const QPointF &)),
    81                q, SIGNAL(longPressed(const QModelIndex&, const QPointF &)));
    82                q, SIGNAL(longPressed(const QModelIndex&, const QPointF &)));
    82     q->connect(mContainer, SIGNAL(scrollingStarted()), q, SIGNAL(scrollingStarted()));
    83     q->connect(mContainer, SIGNAL(scrollingStarted()), q, SIGNAL(scrollingStarted()));
    83     q->connect(mContainer, SIGNAL(scrollingEnded()), q, SIGNAL(scrollingEnded()));
    84     q->connect(mContainer, SIGNAL(scrollingEnded()), q, SIGNAL(scrollingEnded()));
    84     q->connect(mScrollBarHideTimer, SIGNAL(timeout()), q, SLOT(_q_hideScrollBars()));
    85     q->connect(mScrollBarHideTimer, SIGNAL(timeout()), q, SLOT(_q_hideScrollBars()));
    85 
    86     q->connect( HbTheme::instance(), SIGNAL(changed()), q, SLOT(_q_themeChanged()));
       
    87     
       
    88     mContainer->setHandleLongPress(mHandleLongPress);
       
    89     
    86 //    mIndexFeedback = new HgIndexFeedback(q);
    90 //    mIndexFeedback = new HgIndexFeedback(q);
    87 //    mIndexFeedback->setWidget(q);
    91 //    mIndexFeedback->setWidget(q);
    88 
    92 
    89 }
    93 }
    90 
    94 
   674 }
   678 }
   675 
   679 
   676 
   680 
   677 void HgWidgetPrivate::lostForeground()
   681 void HgWidgetPrivate::lostForeground()
   678 {
   682 {
   679     if( !mForeground ) return;
       
   680 
       
   681     mForeground = false;
   683     mForeground = false;
   682     QList<HgWidgetItem*> list = mContainer->items();
       
   683     foreach(HgWidgetItem* item, list){
       
   684         item->releaseItemData();
       
   685     }
       
   686 }
   684 }
   687 
   685 
   688 void HgWidgetPrivate::gainedForeground()
   686 void HgWidgetPrivate::gainedForeground()
   689 {
   687 {
   690     if( mForeground ) return;
       
   691 
       
   692     mForeground = true;
   688     mForeground = true;
   693     QList<HgWidgetItem*> list = mContainer->items();
       
   694     int bufferStart = 0;
       
   695     int bufferEnd = 0;
       
   696     mBufferManager->currentBuffer(bufferStart,bufferEnd);
       
   697     for(;bufferStart<=bufferEnd;bufferStart++){
       
   698         list.at(bufferStart)->updateItemData();
       
   699     }
       
   700 }
   689 }
   701 
   690 
   702 void HgWidgetPrivate::updateCurrentItem(const QModelIndex &currentItem)
   691 void HgWidgetPrivate::updateCurrentItem(const QModelIndex &currentItem)
   703 {
   692 {
   704     Q_UNUSED(currentItem);
   693     Q_UNUSED(currentItem);
   717 }
   706 }
   718 
   707 
   719 void HgWidgetPrivate::orientationChanged(Qt::Orientation orientation)
   708 void HgWidgetPrivate::orientationChanged(Qt::Orientation orientation)
   720 {
   709 {
   721     Q_Q(HgWidget);
   710     Q_Q(HgWidget);
   722     if (mContainer->orientation() != orientation) {
   711     if (mContainer->orientation() != orientation) {    
   723         mContainer->setOrientation(orientation, q->isVisible());
   712         mContainer->setOrientation(orientation, q->isVisible() && q->isActive());
   724         if (!mStaticScrollDirection) {
   713         if (!mStaticScrollDirection) {
   725             createScrollBar(orientation);
   714             createScrollBar(orientation);
   726         }
   715         }
   727         adjustGeometry();
   716         adjustGeometry();
   728     }
   717     }
   862     q->connect( mBufferManager, SIGNAL(releaseItems(int,int)), q, SLOT(_q_releaseItems(int,int)));
   851     q->connect( mBufferManager, SIGNAL(releaseItems(int,int)), q, SLOT(_q_releaseItems(int,int)));
   863     q->connect( mBufferManager, SIGNAL(requestItems(int,int)), q, SLOT(_q_requestItems(int,int)));
   852     q->connect( mBufferManager, SIGNAL(requestItems(int,int)), q, SLOT(_q_requestItems(int,int)));
   864     mBufferManager->resetBuffer(0, itemCount);
   853     mBufferManager->resetBuffer(0, itemCount);
   865 }
   854 }
   866 
   855 
       
   856 void HgWidgetPrivate::setHandleLongPress(bool handleLongPress)
       
   857 {
       
   858     if (mHandleLongPress != handleLongPress) {
       
   859         mHandleLongPress = handleLongPress;
       
   860         mContainer->setHandleLongPress(mHandleLongPress);
       
   861     }
       
   862 }
       
   863 
       
   864 bool HgWidgetPrivate::handleLongPress() const
       
   865 {
       
   866     return mHandleLongPress;
       
   867 }
       
   868 
       
   869 void HgWidgetPrivate::_q_themeChanged()
       
   870 {
       
   871     handleThemeChanged();
       
   872 }
       
   873 
       
   874 void HgWidgetPrivate::handleThemeChanged()
       
   875 {
       
   876     // TODO, add graphics updates here if required.    
       
   877 }
       
   878 
       
   879 
   867 #include "moc_hgwidgets.cpp"
   880 #include "moc_hgwidgets.cpp"