filemanager/src/filemanager/src/backuprestore/fmrestoreviewitem.cpp
branchRCL_3
changeset 39 65326cf895ed
parent 38 491b3ed49290
child 42 f5c50b8af68c
equal deleted inserted replaced
38:491b3ed49290 39:65326cf895ed
     1 /*
       
     2  * Copyright (c) 2009 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  * 
       
    15  * Description:
       
    16  *     The source file of the restore view list item of file manager
       
    17  */
       
    18 #include "fmrestoreviewitem.h"
       
    19 #include "fmfileiconprovider.h"
       
    20 #include <QGraphicsLinearLayout>
       
    21 #include <QGraphicsGridLayout>
       
    22 #include <hblabel.h>
       
    23 #include <hbcheckbox.h>
       
    24 #include <hbwidget.h>
       
    25 #include <hblineedit.h>
       
    26 
       
    27 //FmRestoreViewItem
       
    28 FmRestoreViewItem::FmRestoreViewItem( QGraphicsItem *parent )
       
    29   : HbListViewItem( parent ),
       
    30     mRestoreContentLabel( 0 ),
       
    31     mDateTimeLabel( 0 ),
       
    32     mCheckBox( 0 ),
       
    33     hLayout( 0 ),
       
    34     mParentWidget((HbWidget *)parent)
       
    35 {
       
    36 	//init();
       
    37 }
       
    38 
       
    39 FmRestoreViewItem::~FmRestoreViewItem()
       
    40 {
       
    41 }
       
    42 
       
    43 
       
    44 HbAbstractViewItem *FmRestoreViewItem::createItem()
       
    45 {
       
    46 	return new FmRestoreViewItem( *this );
       
    47 }
       
    48 
       
    49 void FmRestoreViewItem::polish(HbStyleParameters& params)
       
    50 {
       
    51     Q_UNUSED(params);
       
    52 }
       
    53 
       
    54 void FmRestoreViewItem::updateChildItems()
       
    55 {
       
    56     if( !hLayout ) {
       
    57        init();
       
    58     }
       
    59 	QString string = modelIndex().data( Qt::DisplayRole ).toString();	
       
    60 
       
    61 	QStringList stringList = string.split( '\t' );
       
    62 
       
    63 	if( stringList.count() == 0 ){
       
    64 		return;
       
    65 	}
       
    66 
       
    67     mRestoreContentLabel->setPlainText(stringList.first());
       
    68 
       
    69     if (stringList.size() > 0)
       
    70         {
       
    71         mDateTimeLabel->setPlainText(stringList.at(1));
       
    72         }
       
    73     if (stringList.size() > 1)
       
    74         {
       
    75         QIcon icon = mIconProvider->icon(QFileInfo(stringList.at(2)));
       
    76         // FmFileIconProvider already handle null icon issue
       
    77         mIconLabel->setIcon(HbIcon(icon));
       
    78         }
       
    79     
       
    80     connect(this, SIGNAL(stateChanged(int)), mParentWidget,
       
    81             SIGNAL(stateChanged(int)));
       
    82 
       
    83 }
       
    84 
       
    85 void FmRestoreViewItem::init()
       
    86 {
       
    87     mIconProvider = new FmFileIconProvider(); 
       
    88     hLayout = new QGraphicsLinearLayout();
       
    89     hLayout->setOrientation(Qt::Horizontal);
       
    90     hLayout->addItem(layout());
       
    91 
       
    92     mCheckBox = new HbCheckBox(this);
       
    93     hLayout->addItem(mCheckBox);
       
    94     hLayout->setAlignment(mCheckBox, Qt::AlignVCenter);
       
    95 
       
    96     QGraphicsGridLayout *vLayout = new QGraphicsGridLayout();
       
    97 
       
    98     mRestoreContentLabel = new HbLabel("");
       
    99     mRestoreContentLabel->setFontSpec(HbFontSpec(HbFontSpec::Primary));
       
   100     
       
   101     mIconLabel = new HbLabel();    
       
   102 
       
   103     mDateTimeLabel = new HbLabel("");
       
   104     mDateTimeLabel->setFontSpec(HbFontSpec(HbFontSpec::Secondary));
       
   105 
       
   106     vLayout->addItem(mRestoreContentLabel, 0, 0);
       
   107     vLayout->addItem(mIconLabel, 0, 1);
       
   108     vLayout->addItem(mDateTimeLabel, 1, 0);
       
   109 
       
   110     HbWidget *textWidget = new HbWidget();
       
   111     textWidget->setLayout(vLayout);
       
   112 
       
   113     hLayout->addItem(textWidget);
       
   114     hLayout->setAlignment(textWidget, Qt::AlignVCenter);
       
   115     
       
   116     connect(mCheckBox, SIGNAL(stateChanged(int)), this,
       
   117             SIGNAL(stateChanged(int)));
       
   118     setLayout(hLayout);
       
   119 }
       
   120 
       
   121 void FmRestoreViewItem::setCheckBoxState()
       
   122 {
       
   123 	if ( mCheckBox->checkState() ==  Qt::Unchecked ){
       
   124 		mCheckBox->setCheckState( Qt::Checked );
       
   125 		setSelected( true );		
       
   126 	}
       
   127 	else if( mCheckBox->checkState() ==  Qt::Checked ){
       
   128 		mCheckBox->setCheckState( Qt::Unchecked );
       
   129 		setSelected( false );
       
   130 	}	
       
   131 }
       
   132 
       
   133 bool FmRestoreViewItem::getCheckBoxState()
       
   134 {
       
   135     if( mCheckBox->checkState() == Qt::Unchecked ) {
       
   136         return false;
       
   137     } else {
       
   138         return true;
       
   139     }
       
   140 }
       
   141