ganeswidgets/src/hgwidgets.cpp
changeset 1 e48454f237ca
parent 0 89c329efa980
child 2 49c70dcc3f17
equal deleted inserted replaced
0:89c329efa980 1:e48454f237ca
    28 #include "hgscrollbuffermanager.h"
    28 #include "hgscrollbuffermanager.h"
    29 #include "hgcoverflowcontainer.h"
    29 #include "hgcoverflowcontainer.h"
    30 #include "hggridcontainer.h"
    30 #include "hggridcontainer.h"
    31 #include "trace.h"
    31 #include "trace.h"
    32 
    32 
    33 HgWidget::HgWidget(HbWidgetPrivate* widgetPrivate, QGraphicsItem *parent ):
    33 
    34     HbWidget(*widgetPrivate, parent)
    34 
    35 {
    35 HgWidget::HgWidget( QGraphicsItem *parent ) : HbWidget(parent), p_ptr( new HgWidgetPrivate )
    36     Q_D(HgWidget);
    36 {
    37     d->q_ptr = this;
    37     
    38 
       
    39     HbStyleLoader::registerFilePath(":/hgwidget.css");
    38     HbStyleLoader::registerFilePath(":/hgwidget.css");
    40     HbStyleLoader::registerFilePath(":/hgwidget.widgetml");    
    39     HbStyleLoader::registerFilePath(":/hgwidget.widgetml");    
       
    40 
       
    41     Q_D( HgWidget );
       
    42     d->q_ptr = this;
       
    43 }
       
    44 
       
    45 HgWidget::HgWidget(HgWidgetPrivate &dd, QGraphicsItem *parent ):
       
    46     HbWidget(parent), p_ptr( &dd )
       
    47 {
       
    48     HbStyleLoader::registerFilePath(":/hgwidget.css");
       
    49     HbStyleLoader::registerFilePath(":/hgwidget.widgetml");    
       
    50     Q_D( HgWidget );
       
    51     d->q_ptr = this;
    41 }
    52 }
    42 
    53 
    43 HgWidget::~HgWidget()
    54 HgWidget::~HgWidget()
    44 {
    55 {
       
    56     delete p_ptr;
       
    57     
    45     HbStyleLoader::unregisterFilePath(":/hgwidget.css");
    58     HbStyleLoader::unregisterFilePath(":/hgwidget.css");
    46     HbStyleLoader::unregisterFilePath(":/hgwidget.widgetml");
    59     HbStyleLoader::unregisterFilePath(":/hgwidget.widgetml");
    47 }
    60 }
    48 
    61 
    49 /*!
    62 /*!
   127 }
   140 }
   128 
   141 
   129 void HgWidget::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
   142 void HgWidget::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
   130 {
   143 {
   131     Q_D( HgWidget);
   144     Q_D( HgWidget);
   132     // TODO,take columns into count
   145     d->dataChanged(topLeft, bottomRight);
   133     for( int i = topLeft.row(); i <= bottomRight.row(); i++ ){
       
   134         // if data for item outside our current buffer has changed
       
   135         // we just have to ignore it since we dont have resources
       
   136         // to handle it(or we dont want to waste resources).
       
   137         if(d->mBufferManager->positionInsideBuffer(i)){
       
   138             HgWidgetItem* item = d->mContainer->itemByIndex( i );
       
   139             if( item ){
       
   140                 item->updateItemData();
       
   141             }
       
   142         }
       
   143     }
       
   144     d->mContainer->itemDataChanged( topLeft, bottomRight );
       
   145 }
   146 }
   146 
   147 
   147 /*!
   148 /*!
   148  * Returns true if the scroll area handles
   149  * Returns true if the scroll area handles
   149  * long press gestures, false otherwise
   150  * long press gestures, false otherwise
   320 {
   321 {
   321     Q_D(const HgWidget);
   322     Q_D(const HgWidget);
   322     return d->indexFeedbackPolicy();
   323     return d->indexFeedbackPolicy();
   323 }
   324 }
   324 
   325 
       
   326 void HgWidget::setDefaultImage(QImage defaultImage)
       
   327 {
       
   328     Q_D(HgWidget);
       
   329     d->setDefaultImage(defaultImage);
       
   330 }
       
   331 
       
   332 void HgWidget::setItemSizePolicy(HgWidget::ItemSizePolicy policy)
       
   333 {
       
   334     Q_D(HgWidget);
       
   335     d->setItemSizePolicy(policy);
       
   336 }
       
   337 
       
   338 HgWidget::ItemSizePolicy HgWidget::itemSizePolicy() const
       
   339 {
       
   340     Q_D(const HgWidget);
       
   341     return d->itemSizePolicy();
       
   342 }
       
   343 
       
   344 void HgWidget::setItemSize(const QSizeF& size)
       
   345 {
       
   346     Q_D(HgWidget);
       
   347     d->setItemSize(size);
       
   348 }
       
   349 
       
   350 QSizeF HgWidget::itemSize() const
       
   351 {
       
   352     Q_D(const HgWidget);
       
   353     return d->itemSize();
       
   354 }
       
   355 
       
   356 void HgWidget::setItemSpacing(const QSizeF& spacing)
       
   357 {
       
   358     Q_D(HgWidget);
       
   359     d->setItemSpacing(spacing);    
       
   360 }
       
   361 
       
   362 QSizeF HgWidget::itemSpacing() const
       
   363 {
       
   364     Q_D(const HgWidget);
       
   365     return d->itemSpacing();
       
   366 }
       
   367 
       
   368 
   325 // EOF
   369 // EOF