filemanager/src/filemanager/src/backuprestore/fmrestorewidget.cpp
changeset 25 b7bfdea70ca2
parent 14 1957042d8c7e
child 49 81668a704644
equal deleted inserted replaced
16:ada7962b4308 25:b7bfdea70ca2
    15  * Description:
    15  * Description:
    16  *     The header file of the restore widget of file manager
    16  *     The header file of the restore widget of file manager
    17  */
    17  */
    18 #include "fmrestorewidget.h"
    18 #include "fmrestorewidget.h"
    19 #include "fmrestoresettings.h"
    19 #include "fmrestoresettings.h"
       
    20 #include "fmbackupsettings.h"
    20 #include "fmrestoreviewitem.h"
    21 #include "fmrestoreviewitem.h"
    21 #include "fmoperationservice.h"
    22 #include "fmoperationservice.h"
    22 #include "fmviewmanager.h"
    23 #include "fmviewmanager.h"
    23 
    24 
    24 #include "fmbackupconfigloader.h"
    25 #include "fmbackupconfigloader.h"
    70     mListView->setSelectionMode( HbAbstractItemView::MultiSelection );
    71     mListView->setSelectionMode( HbAbstractItemView::MultiSelection );
    71 
    72 
    72     vLayout->addItem( mListView );
    73     vLayout->addItem( mListView );
    73 
    74 
    74     mModel = new QStringListModel();
    75     mModel = new QStringListModel();
    75     mListView->setModel( mModel );
    76     mListView->setModel( mModel );    
    76 
       
    77     mRestoreSettings = FmViewManager::viewManager()->operationService()->backupRestoreHandler()->bkupEngine()->RestoreSettingsL();
    77     mRestoreSettings = FmViewManager::viewManager()->operationService()->backupRestoreHandler()->bkupEngine()->RestoreSettingsL();
    78     mBackupConfigLoader = FmViewManager::viewManager()->operationService()->backupRestoreHandler()->backupConfigLoader();
    78     mBackupConfigLoader = FmViewManager::viewManager()->operationService()->backupRestoreHandler()->backupConfigLoader();
       
    79     
       
    80     // load backup settings to refresh default target drive
       
    81     FmViewManager::viewManager()->operationService()->backupRestoreHandler()->bkupEngine()->BackupSettingsL()->load();
    79     mRestoreSettings->load( mBackupConfigLoader->driversAndOperationList() );
    82     mRestoreSettings->load( mBackupConfigLoader->driversAndOperationList() );
    80 
    83 
    81     int index = 0;
    84     int index = 0;
    82 
    85 
    83     QList< FmRestoreEntry* > retoreEntryList = mRestoreSettings->restoreEntryList();
    86     QList< FmRestoreEntry* > retoreEntryList = mRestoreSettings->restoreEntryList();
    87          it != retoreEntryList.end(); ++it ){
    90          it != retoreEntryList.end(); ++it ){
    88              QString string = ( *it )->text();
    91              QString string = ( *it )->text();
    89              QDateTime datetime = ( *it )->restoreInfo().dateTime();
    92              QDateTime datetime = ( *it )->restoreInfo().dateTime();
    90              string.append( '\t' );
    93              string.append( '\t' );
    91              string.append( datetime.toString( "hh:mm ap dd/MM/yyyy") );
    94              string.append( datetime.toString( "hh:mm ap dd/MM/yyyy") );
       
    95              QString drive = ( *it )->restoreInfo().drive();             
       
    96              string.append( '\t' );
       
    97              string.append( drive );
    92              QVariant variant( string );
    98              QVariant variant( string );
    93 
    99 
    94              mModel->setData( mModel->index( index ), variant, Qt::DisplayRole );
   100              mModel->setData( mModel->index( index ), variant, Qt::DisplayRole );
    95 
   101 
    96              ++index;
   102              ++index;
    97     }
   103     }
    98 
   104 
    99     mListView->setItemPrototype( new FmRestoreViewItem( this ) );
   105     mListView->setItemPrototype( new FmRestoreViewItem(this) );
   100 
       
   101 }
   106 }
   102 
   107 
   103 void FmRestoreWigdet::on_list_activated( const QModelIndex &index )
   108 void FmRestoreWigdet::on_list_activated( const QModelIndex &index )
   104 {
   109 {
   105     FmRestoreViewItem *restoreViewItem = static_cast< FmRestoreViewItem* >
   110     FmRestoreViewItem *restoreViewItem = static_cast< FmRestoreViewItem* >
   106                                          ( mListView->itemByIndex( index ) );
   111                                          ( mListView->itemByIndex( index ) );
   107 
   112 
   108     restoreViewItem->setCheckBoxState();
   113     restoreViewItem->setCheckBoxState();    
   109     emit checkStatusChanged();
       
   110 }
   114 }
   111 
   115 
   112 int FmRestoreWigdet::backupDataCount()
   116 int FmRestoreWigdet::backupDataCount()
   113 {
   117 {
   114     return mModel->rowCount();
   118     return mModel->rowCount();
   115 }
   119 }
       
   120 
       
   121 void FmRestoreWigdet::refresh()
       
   122 {
       
   123     mListView->setModel( 0 );
       
   124     if( !mModel ) {
       
   125             mModel = new QStringListModel();
       
   126         }
       
   127     mModel->removeRows( 0, mModel->rowCount() );
       
   128 
       
   129     mRestoreSettings = FmViewManager::viewManager()->operationService()->backupRestoreHandler()->bkupEngine()->RestoreSettingsL();
       
   130     mBackupConfigLoader = FmViewManager::viewManager()->operationService()->backupRestoreHandler()->backupConfigLoader();
       
   131     mRestoreSettings->load( mBackupConfigLoader->driversAndOperationList() );
       
   132 
       
   133     int index = 0;
       
   134     QList< FmRestoreEntry* > retoreEntryList = mRestoreSettings->restoreEntryList();
       
   135     mModel->insertRows( 0, retoreEntryList.count() );
       
   136     for ( QList< FmRestoreEntry* >::iterator it = retoreEntryList.begin(); 
       
   137         it != retoreEntryList.end(); ++it ){
       
   138             QString string = ( *it )->text();
       
   139             QDateTime datetime = ( *it )->restoreInfo().dateTime();
       
   140             QString drive = ( *it )->restoreInfo().drive();
       
   141             string.append( '\t' );
       
   142             string.append( datetime.toString( "hh:mm ap dd/MM/yyyy") );
       
   143             string.append( '\t' );
       
   144             string.append( drive );
       
   145             QVariant variant( string );             
       
   146             mModel->setData( mModel->index( index ), variant, Qt::DisplayRole );
       
   147             ++index;
       
   148         }   
       
   149     mListView->setModel( mModel );   
       
   150     mListView->setItemPrototype( new FmRestoreViewItem( this ) );
       
   151       
       
   152     for (int i = 0; i < mModel->rowCount(); ++i) {
       
   153         QModelIndex index = mModel->index(i);
       
   154         FmRestoreViewItem* restoreViewItem = static_cast< FmRestoreViewItem* >
       
   155                                                  (mListView->itemByIndex(index));
       
   156         connect(restoreViewItem, SIGNAL(stateChanged(int)), this, SIGNAL(stateChanged(int)));               
       
   157     }
       
   158     emit stateChanged(0);
       
   159     
       
   160 }