filemanager/src/fmbkupenginewrapper/src/fmrestoresettings.cpp
changeset 14 1957042d8c7e
child 18 edd66bde63a4
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/filemanager/src/fmbkupenginewrapper/src/fmrestoresettings.cpp	Fri Apr 16 14:53:38 2010 +0300
@@ -0,0 +1,114 @@
+/*
+ * 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 source file of the restore settings of file manager
+ */
+
+#include "fmrestoresettings.h"
+#include "fmbackupsettings.h"
+#include "fmbkupengine.h"
+#include "fmbkupcommon.h"
+
+#include <QString>
+#include <QDateTime>
+#include <QSettings>
+
+FmRestoreSettings::FmRestoreSettings( FmBkupEngine& engine ) : mEngine( engine )
+{
+
+}
+
+FmRestoreSettings::~FmRestoreSettings()
+{
+    resetAndDestoryRestoreEntry();
+}
+
+void FmRestoreSettings::load( QList<FmBkupDrivesAndOperation* > drivesAndOperationList )
+{
+    refreshList( drivesAndOperationList );
+}
+
+QList< FmRestoreEntry* > FmRestoreSettings::restoreEntryList()
+{
+    return mRestoreEntryList;
+}
+
+void FmRestoreSettings::resetAndDestoryRestoreEntry()
+{
+    for( QList< FmRestoreEntry* >::iterator it = mRestoreEntryList.begin(); 
+        it!= mRestoreEntryList.end(); ++it ){
+        delete *it;
+    }
+    mRestoreEntryList.clear();
+}
+
+void FmRestoreSettings::refreshList( QList<FmBkupDrivesAndOperation* > &drivesAndOperationList )
+{
+    resetAndDestoryRestoreEntry();
+
+    QList< FmRestoreInfo > restoreInfoList;
+    
+    mEngine.GetRestoreInfoArray( drivesAndOperationList, restoreInfoList );
+    
+
+    // fetch info list from engine, and then init the entry list for display
+
+    int count( restoreInfoList.count() );
+    quint32 mask( FmBkupEngineCommon::EFileManagerBackupContentFirst);
+    while ( mask <= FmBkupEngineCommon::EFileManagerBackupContentLast )
+        {
+        for ( int i( 0 ); i < count; ++i )
+            {
+            FmRestoreInfo& info( restoreInfoList[ i ] );
+            if ( info.content() & mask )
+                {
+                FmRestoreEntry* entry = CreateEntry( info );
+                mRestoreEntryList.push_back( entry );
+                }
+            }
+        mask <<= 1;
+        }
+}
+
+
+FmRestoreEntry *FmRestoreSettings::CreateEntry( const FmRestoreInfo &info )
+{
+    QString text = FmBackupSettings::contentToString( info.content() );
+
+    FmRestoreEntry *entry = new FmRestoreEntry( text, info );
+    return entry;
+}
+
+void FmRestoreSettings::SetSelection(
+        const quint64& aSelection )
+    {
+    iSelection = aSelection;
+    }
+
+void FmRestoreSettings::GetSelectionL(
+        QList< FmRestoreInfo >& infoArray ) const
+{
+    infoArray.clear();
+
+    int count( mRestoreEntryList.count() );
+
+    for ( int i( 0 ); i < count; ++i )
+    {
+        if ( ( ( ( quint64 ) 1 ) << i ) & iSelection )
+        {
+            infoArray.append( mRestoreEntryList[ i ]->restoreInfo() );
+        }
+    }
+}