diff -r d1daf54a55b5 -r 1957042d8c7e filemanager/src/filemanager/src/backuprestore/fmdeletebackupwidget.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/filemanager/src/filemanager/src/backuprestore/fmdeletebackupwidget.cpp Fri Apr 16 14:53:38 2010 +0300 @@ -0,0 +1,129 @@ +/* + * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * + * Description: + * The header file of the delete backup widget of file manager + */ +#include "fmdeletebackupwidget.h" +#include "fmrestoresettings.h" +#include "fmrestoreviewitem.h" +#include "fmoperationservice.h" +#include "fmviewmanager.h" + +#include "fmbackupconfigloader.h" +#include "fmbkupengine.h" +#include "fmbackuprestorehandler.h" + +#include +#include +#include + +#include + +FmDeleteBackupWidget::FmDeleteBackupWidget( HbWidget *parent ) +: HbWidget( parent ), mModel( 0 ) +{ + init(); +} + +FmDeleteBackupWidget::~FmDeleteBackupWidget() +{ + mListView->setModel( 0 ); + delete mModel; +} + +void FmDeleteBackupWidget::refresh() +{ + mListView->setModel( 0 ); + loadData(); + mListView->setModel( mModel ); +} +QList FmDeleteBackupWidget::selectionIndexes() +{ + QList selectionList; + + for ( int i=0; irowCount(); i++ ) { + FmRestoreViewItem *item = static_cast( + mListView->itemByIndex( mModel->index( i ) ) ); + if( item && item->getCheckBoxState() ) { + selectionList.push_back( i ); + } + } + + return selectionList; +} + +void FmDeleteBackupWidget::loadData() +{ + if( !mModel ) { + mModel = new QStringListModel(); + } + mModel->removeRows( 0, mModel->rowCount() ); + + mRestoreSettings = FmViewManager::viewManager()->operationService()->backupRestoreHandler()->bkupEngine()->RestoreSettingsL(); + mBackupConfigLoader = FmViewManager::viewManager()->operationService()->backupRestoreHandler()->backupConfigLoader(); + mRestoreSettings->load( mBackupConfigLoader->driversAndOperationList() ); + + int index = 0; + + QList< FmRestoreEntry* > retoreEntryList = mRestoreSettings->restoreEntryList(); + mModel->insertRows( 0, retoreEntryList.count() ); + + for ( QList< FmRestoreEntry* >::iterator it = retoreEntryList.begin(); + it != retoreEntryList.end(); ++it ){ + QString string = ( *it )->text(); + QDateTime datetime = ( *it )->restoreInfo().dateTime(); + string.append( '\t' ); + string.append( datetime.toString( "hh:mm ap dd/MM/yyyy") ); + QVariant variant( string ); + + mModel->setData( mModel->index( index ), variant, Qt::DisplayRole ); + + ++index; + } + +} + +void FmDeleteBackupWidget::init() +{ + QGraphicsLinearLayout *vLayout = new QGraphicsLinearLayout( this ); + vLayout->setOrientation( Qt::Vertical ); + + mListView = new HbListView( this ); + connect( mListView, SIGNAL( activated( const QModelIndex & ) ), + this, SLOT( on_list_activated( const QModelIndex & ) ) ); + + mListView->setSelectionMode( HbAbstractItemView::MultiSelection ); + + vLayout->addItem( mListView ); + + loadData(); + mListView->setModel( mModel ); + + mListView->setItemPrototype( new FmRestoreViewItem( this ) ); + +} + +void FmDeleteBackupWidget::on_list_activated( const QModelIndex &index ) +{ + FmRestoreViewItem *restoreViewItem = static_cast< FmRestoreViewItem* > + ( mListView->itemByIndex( index ) ); + + restoreViewItem->setCheckBoxState(); +} + +int FmDeleteBackupWidget::backupDataCount() +{ + return mModel->rowCount(); +}