iaupdate/IAD/ui/src/iaupdateapplistitem.cpp
changeset 77 d1838696558c
equal deleted inserted replaced
75:2d2d25361590 77:d1838696558c
       
     1 /*
       
     2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:   This module contains the implementation of IAUpdateAppListItem
       
    15 *                class member functions.
       
    16 *
       
    17 */
       
    18 #include <HbProgressBar>
       
    19 
       
    20 #include "iaupdateapplistitem.h"
       
    21 #include "iaupdateapplistmodel.h"
       
    22 #include "iaupdatedebug.h"
       
    23 
       
    24 IAUpdateAppListItem::IAUpdateAppListItem(QGraphicsItem * parent) :
       
    25   HbListViewItem(parent)
       
    26 {
       
    27     mProgressBar = NULL;   
       
    28     mIsProgress = false;
       
    29     mSecondaryTextVisible = true;
       
    30 }
       
    31 
       
    32 IAUpdateAppListItem::~IAUpdateAppListItem() 
       
    33 {
       
    34 }
       
    35 
       
    36 HbAbstractViewItem * IAUpdateAppListItem::createItem()
       
    37 {
       
    38     return new IAUpdateAppListItem(*this);
       
    39 }
       
    40 
       
    41 
       
    42 void IAUpdateAppListItem::updateChildItems()
       
    43 {
       
    44     HbListViewItem::updateChildItems();
       
    45     
       
    46     mIsProgress = modelIndex().data(IAUpdateAppListModel::ProgressRole).toBool();
       
    47     if (mIsProgress)
       
    48     {  // progress state
       
    49         if (mSecondaryTextVisible)
       
    50             {
       
    51             foreach (QGraphicsItem * item, childItems()) 
       
    52                 {
       
    53                     if (HbStyle::itemName(item) == "text-2")     
       
    54                     {
       
    55                         item->setVisible(false);
       
    56                         mSecondaryTextVisible = false;
       
    57                         break;
       
    58                     }
       
    59                 }
       
    60             }
       
    61         if (!mProgressBar)
       
    62         {
       
    63             mProgressBar = new HbProgressBar(this);
       
    64             mProgressBar->setRange(0, 100);
       
    65             HbStyle::setItemName(mProgressBar, "progress");
       
    66         }
       
    67         if (!mProgressBar->isVisible())
       
    68         {
       
    69             HbStyle::setItemName(mProgressBar, "progress");
       
    70             mProgressBar->setVisible(true);
       
    71         }
       
    72         QList<QVariant> list = modelIndex().data(IAUpdateAppListModel::ProgressValueRole).toList();
       
    73         int value = list.at(0).toInt();
       
    74         int total = list.at(1).toInt();
       
    75         mProgressBar->setRange(0,total);
       
    76         mProgressBar->setProgressValue(value);
       
    77     }
       
    78     else
       
    79     {  //normal state
       
    80         if (mProgressBar)
       
    81         {
       
    82             if (mProgressBar->isVisible()) 
       
    83             { 
       
    84                 HbStyle::setItemName(mProgressBar, "");
       
    85                 mProgressBar->setVisible(false);
       
    86             }    
       
    87             if (!mSecondaryTextVisible)
       
    88             {    
       
    89                 foreach (QGraphicsItem * item, childItems()) 
       
    90                 {
       
    91                     if (HbStyle::itemName(item) == "text-2") 
       
    92                     {
       
    93                         item->setVisible(true);
       
    94                         mSecondaryTextVisible = true;
       
    95                         break;
       
    96                     }
       
    97                 }    
       
    98             }
       
    99         }
       
   100     }
       
   101 }
       
   102 
       
   103 
       
   104 void IAUpdateAppListItem::polish(HbStyleParameters& params)
       
   105 {       
       
   106     HbListViewItem::setProperty("progress", mIsProgress);
       
   107     HbListViewItem::polish(params);   
       
   108 }
       
   109