filemanager/src/fmbkupenginewrapper/src/fmrestoresettings.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 settings of file manager
       
    17  */
       
    18 
       
    19 #include "fmrestoresettings.h"
       
    20 #include "fmbackupsettings.h"
       
    21 #include "fmbkupengine.h"
       
    22 #include "fmbkupcommon.h"
       
    23 
       
    24 #include <QString>
       
    25 #include <QDateTime>
       
    26 #include <QSettings>
       
    27 
       
    28 FmRestoreSettings::FmRestoreSettings( FmBkupEngine& engine ) : mEngine( engine )
       
    29 {
       
    30 
       
    31 }
       
    32 
       
    33 FmRestoreSettings::~FmRestoreSettings()
       
    34 {
       
    35     resetAndDestoryRestoreEntry();
       
    36 }
       
    37 
       
    38 void FmRestoreSettings::load( QList<FmBkupDrivesAndOperation* > drivesAndOperationList )
       
    39 {
       
    40     refreshList( drivesAndOperationList );
       
    41 }
       
    42 
       
    43 QList< FmRestoreEntry* > FmRestoreSettings::restoreEntryList()
       
    44 {
       
    45     return mRestoreEntryList;
       
    46 }
       
    47 
       
    48 void FmRestoreSettings::resetAndDestoryRestoreEntry()
       
    49 {
       
    50     for( QList< FmRestoreEntry* >::iterator it = mRestoreEntryList.begin(); 
       
    51         it!= mRestoreEntryList.end(); ++it ){
       
    52         delete *it;
       
    53     }
       
    54     mRestoreEntryList.clear();
       
    55 }
       
    56 
       
    57 void FmRestoreSettings::refreshList( QList<FmBkupDrivesAndOperation* > &drivesAndOperationList )
       
    58 {
       
    59     resetAndDestoryRestoreEntry();
       
    60 
       
    61     QList< FmRestoreInfo > restoreInfoList;
       
    62     
       
    63     QString targetDrive = mEngine.BackupSettingsL()->availableTargetDrive();
       
    64     mEngine.GetRestoreInfoArray( drivesAndOperationList, restoreInfoList, targetDrive );
       
    65     
       
    66 
       
    67     // fetch info list from engine, and then init the entry list for display
       
    68 
       
    69     int count( restoreInfoList.count() );
       
    70     quint32 mask( FmBkupEngineCommon::EFileManagerBackupContentFirst);
       
    71     while ( mask <= FmBkupEngineCommon::EFileManagerBackupContentLast )
       
    72         {
       
    73         for ( int i( 0 ); i < count; ++i )
       
    74             {
       
    75             FmRestoreInfo& info( restoreInfoList[ i ] );
       
    76             if ( info.content() & mask )
       
    77                 {
       
    78                 FmRestoreEntry* entry = CreateEntry( info );
       
    79                 mRestoreEntryList.push_back( entry );
       
    80                 }
       
    81             }
       
    82         mask <<= 1;
       
    83         }
       
    84 }
       
    85 
       
    86 
       
    87 FmRestoreEntry *FmRestoreSettings::CreateEntry( const FmRestoreInfo &info )
       
    88 {
       
    89     QString text = FmBackupSettings::contentToString( info.content() );
       
    90 
       
    91     FmRestoreEntry *entry = new FmRestoreEntry( text, info );
       
    92     return entry;
       
    93 }
       
    94 
       
    95 void FmRestoreSettings::SetSelection(
       
    96         const quint64& aSelection )
       
    97     {
       
    98     iSelection = aSelection;
       
    99     }
       
   100 
       
   101 void FmRestoreSettings::GetSelectionL(
       
   102         QList< FmRestoreInfo >& infoArray ) const
       
   103 {
       
   104     infoArray.clear();
       
   105 
       
   106     int count( mRestoreEntryList.count() );
       
   107 
       
   108     for ( int i( 0 ); i < count; ++i )
       
   109     {
       
   110         if ( ( ( ( quint64 ) 1 ) << i ) & iSelection )
       
   111         {
       
   112             infoArray.append( mRestoreEntryList[ i ]->restoreInfo() );
       
   113         }
       
   114     }
       
   115 }