filemanager/src/fmbkupenginewrapper/src/fmrestoresettings.cpp
changeset 14 1957042d8c7e
child 18 edd66bde63a4
equal deleted inserted replaced
1:d1daf54a55b5 14:1957042d8c7e
       
     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     mEngine.GetRestoreInfoArray( drivesAndOperationList, restoreInfoList );
       
    64     
       
    65 
       
    66     // fetch info list from engine, and then init the entry list for display
       
    67 
       
    68     int count( restoreInfoList.count() );
       
    69     quint32 mask( FmBkupEngineCommon::EFileManagerBackupContentFirst);
       
    70     while ( mask <= FmBkupEngineCommon::EFileManagerBackupContentLast )
       
    71         {
       
    72         for ( int i( 0 ); i < count; ++i )
       
    73             {
       
    74             FmRestoreInfo& info( restoreInfoList[ i ] );
       
    75             if ( info.content() & mask )
       
    76                 {
       
    77                 FmRestoreEntry* entry = CreateEntry( info );
       
    78                 mRestoreEntryList.push_back( entry );
       
    79                 }
       
    80             }
       
    81         mask <<= 1;
       
    82         }
       
    83 }
       
    84 
       
    85 
       
    86 FmRestoreEntry *FmRestoreSettings::CreateEntry( const FmRestoreInfo &info )
       
    87 {
       
    88     QString text = FmBackupSettings::contentToString( info.content() );
       
    89 
       
    90     FmRestoreEntry *entry = new FmRestoreEntry( text, info );
       
    91     return entry;
       
    92 }
       
    93 
       
    94 void FmRestoreSettings::SetSelection(
       
    95         const quint64& aSelection )
       
    96     {
       
    97     iSelection = aSelection;
       
    98     }
       
    99 
       
   100 void FmRestoreSettings::GetSelectionL(
       
   101         QList< FmRestoreInfo >& infoArray ) const
       
   102 {
       
   103     infoArray.clear();
       
   104 
       
   105     int count( mRestoreEntryList.count() );
       
   106 
       
   107     for ( int i( 0 ); i < count; ++i )
       
   108     {
       
   109         if ( ( ( ( quint64 ) 1 ) << i ) & iSelection )
       
   110         {
       
   111             infoArray.append( mRestoreEntryList[ i ]->restoreInfo() );
       
   112         }
       
   113     }
       
   114 }