filemanager/src/filemanager/src/backuprestore/fmbackupwidget.cpp
changeset 16 ada7962b4308
parent 14 1957042d8c7e
child 18 edd66bde63a4
child 25 b7bfdea70ca2
child 37 15bc28c9dd51
equal deleted inserted replaced
14:1957042d8c7e 16:ada7962b4308
   113 
   113 
   114 }
   114 }
   115 
   115 
   116 void FmBackupWidget::expandAllGroup()
   116 void FmBackupWidget::expandAllGroup()
   117 {
   117 {
       
   118     FmLogger::log( QString( "function expandAllGroup start" ) );
       
   119     
   118     mDataForm->setModel( 0 );
   120     mDataForm->setModel( 0 );
   119     mDataForm->setModel( mModel );
   121     mDataForm->setModel( mModel );
   120 
   122 
   121     HbDataFormViewItem *itemScheduling = 
   123     HbDataFormViewItem *itemScheduling = 
   122         (HbDataFormViewItem *)(mDataForm->itemByIndex(mModel->indexFromItem(mSchedulingGroup)));
   124         (HbDataFormViewItem *)(mDataForm->itemByIndex(mModel->indexFromItem(mSchedulingGroup)));
   123     if( itemScheduling ){
   125     if( itemScheduling ){
       
   126         FmLogger::log( QString( "expand itemScheduling start" ) );
   124         itemScheduling->setExpanded( true );
   127         itemScheduling->setExpanded( true );
       
   128         FmLogger::log( QString( "expand itemScheduling end" ) );
   125     }
   129     }
   126 
   130 
   127     HbDataFormViewItem *itemGroup = 
   131     HbDataFormViewItem *itemGroup = 
   128         (HbDataFormViewItem *)(mDataForm->itemByIndex(mModel->indexFromItem(mContentsGroup)));
   132         (HbDataFormViewItem *)(mDataForm->itemByIndex(mModel->indexFromItem(mContentsGroup)));
   129     if( itemGroup ){
   133     if( itemGroup ){
       
   134         FmLogger::log( QString( "expand itemGroup start" ) );
   130         itemGroup->setExpanded( true );
   135         itemGroup->setExpanded( true );
   131     }
   136         FmLogger::log( QString( "expand itemGroup end" ) );
       
   137     }
       
   138     FmLogger::log( QString( "function expandAllGroup end" ) );
   132 }
   139 }
   133 
   140 
   134 void FmBackupWidget::initModel()
   141 void FmBackupWidget::initModel()
   135 {
   142 {
   136     mContentsGroup = mModel->appendDataFormGroup(
   143     mContentsGroup = mModel->appendDataFormGroup(
   165 {
   172 {
   166     mDataForm->setModel( 0 );
   173     mDataForm->setModel( 0 );
   167 
   174 
   168     mBackupSettings->load();
   175     mBackupSettings->load();
   169     
   176     
   170     bool isWeekdayExist = false;
   177     int index = 0;
   171     bool isTimeExist = false;
   178 
       
   179     index = mSchedulingGroup->indexOf(  mWeekdayItem );
       
   180     if( index >=0 ){
       
   181         mSchedulingGroup->removeChild( index );
       
   182         mWeekdayItem = 0;
       
   183     }
       
   184 
       
   185     index = mSchedulingGroup->indexOf(  mTimeItem );
       
   186     if( index >=0 ){
       
   187         mSchedulingGroup->removeChild( index );
       
   188         mTimeItem = 0;
       
   189     }
       
   190     
       
   191     index = mContentsGroup->indexOf(  mTargetItem );
       
   192     if( index >=0 ){
       
   193         mContentsGroup->removeChild( index );
       
   194         mTargetItem = 0;
       
   195     }
   172    
   196    
   173     QList< FmBackupEntry* > backupEntryList = mBackupSettings->backupEntryList();
   197     QList< FmBackupEntry* > backupEntryList = mBackupSettings->backupEntryList();
   174 
   198 
   175     QList< FmBackupEntry* >::iterator it;
   199     QList< FmBackupEntry* >::iterator it;
   176 
   200 
   189             mContentsItem->setContentWidgetData( QString("text"), tips );
   213             mContentsItem->setContentWidgetData( QString("text"), tips );
   190             break;
   214             break;
   191             }
   215             }
   192         case FmBackupEntry::ETarget:
   216         case FmBackupEntry::ETarget:
   193             {
   217             {
       
   218             mTargetItem = mModel->appendDataFormItem(
       
   219                 HbDataFormModelItem::TextItem, QString( "" ), mContentsGroup );
       
   220             mTargetItem->setContentWidgetData( QString("readOnly"), QString("true") );        
   194             mTargetItem->setLabel(title);
   221             mTargetItem->setLabel(title);
   195             mTargetItem->setContentWidgetData( QString("text"), tips );
   222             mTargetItem->setContentWidgetData( QString("text"), tips );
   196             break;
   223             break;
   197             }
   224             }
   198         case FmBackupEntry::EScheduling:
   225         case FmBackupEntry::EScheduling:
   201             mSchedulingItem->setContentWidgetData( QString("text"), tips );
   228             mSchedulingItem->setContentWidgetData( QString("text"), tips );
   202             break;
   229             break;
   203             }
   230             }
   204         case FmBackupEntry::EWeekday:
   231         case FmBackupEntry::EWeekday:
   205             {
   232             {
       
   233             mWeekdayItem = mModel->appendDataFormItem(
       
   234                 HbDataFormModelItem::TextItem, QString( "" ), mSchedulingGroup );
       
   235             mWeekdayItem->setContentWidgetData( QString("readOnly"), QString("true") );
   206             mWeekdayItem->setLabel(title);
   236             mWeekdayItem->setLabel(title);
   207             mWeekdayItem->setContentWidgetData( QString("text"), tips );
   237             mWeekdayItem->setContentWidgetData( QString("text"), tips );
   208             isWeekdayExist = true;
       
   209             break;
   238             break;
   210             }
   239             }
   211         case FmBackupEntry::ETime:
   240         case FmBackupEntry::ETime:
   212             {
   241             {
       
   242             mTimeItem = mModel->appendDataFormItem(
       
   243                 HbDataFormModelItem::TextItem, QString( "" ), mSchedulingGroup );
       
   244             mTimeItem->setContentWidgetData( QString("readOnly"), QString("true") );
   213             mTimeItem->setLabel(title);
   245             mTimeItem->setLabel(title);
   214             mTimeItem->setContentWidgetData( QString("text"), tips );
   246             mTimeItem->setContentWidgetData( QString("text"), tips );
   215             isTimeExist = true;
       
   216             break;
   247             break;
   217             }
   248             }
   218         }
   249         }
   219     }
   250     }
   220     int index = 0;
       
   221 
       
   222     index = mSchedulingGroup->indexOf(  mWeekdayItem );
       
   223     if( index >=0 ){
       
   224         mSchedulingGroup->removeChild( index );
       
   225     }
       
   226 
       
   227     index = mSchedulingGroup->indexOf(  mTimeItem );
       
   228     if( index >=0 ){
       
   229         mSchedulingGroup->removeChild( index );
       
   230     }
       
   231 
       
   232     if( isWeekdayExist ) {
       
   233             mSchedulingGroup->appendChild( mWeekdayItem );
       
   234         }
       
   235 
       
   236     if( isTimeExist ){
       
   237             mSchedulingGroup->appendChild( mTimeItem );
       
   238         }
       
   239 
   251 
   240     mDataForm->setModel( mModel );
   252     mDataForm->setModel( mModel );
   241 
   253 
   242     expandAllGroup();
   254     expandAllGroup();
   243 }
   255 }
   327     QString title = constFileManagerBackupSettingsTitleTargetDrive;  
   339     QString title = constFileManagerBackupSettingsTitleTargetDrive;  
   328     QStringList queryStringList;
   340     QStringList queryStringList;
   329     QStringList driveStringList;
   341     QStringList driveStringList;
   330 
   342 
   331     QStringList driveList;
   343     QStringList driveList;
   332     FmUtils::getDriveList( driveList, true );
   344     //FmUtils::getDriveList( driveList, true );
       
   345     FmViewManager::viewManager()->operationService()->backupRestoreHandler()->getBackupDriveList( driveList );
   333     QString targetDrive =  mBackupSettings->targetDrive();
   346     QString targetDrive =  mBackupSettings->targetDrive();
   334     int selectIndex = -1;
   347     int selectIndex = -1;
   335 
   348 
   336     int currentIndex = 0;
   349     int currentIndex = 0;
       
   350     QString associatedDrives;
   337     for( QStringList::const_iterator it = driveList.begin(); it != driveList.end(); ++it )
   351     for( QStringList::const_iterator it = driveList.begin(); it != driveList.end(); ++it )
   338     {
   352     {
   339         QString drive = (*it);
   353         QString drive = (*it);
   340         drive = FmUtils::removePathSplash( drive );
   354         drive = FmUtils::removePathSplash( drive );
   341         QString driveWithVolume = FmUtils::fillDriveVolume( drive, true );
   355         QString driveWithVolume = FmUtils::fillDriveVolume( drive, true );
   342 
   356 
   343         driveStringList.push_back( drive );
   357         driveStringList.push_back( drive );
   344         queryStringList.push_back( driveWithVolume );
   358         queryStringList.push_back( driveWithVolume );
   345 
   359         associatedDrives += FmUtils::getDriveLetterFromPath(drive);
   346 
   360 
   347         if( drive == targetDrive )
   361         if( drive == targetDrive )
   348         {
   362         {
   349             // adjust index offset against drive.
   363             // adjust index offset against drive.
   350             selectIndex = currentIndex;
   364             selectIndex = currentIndex;
   351         }
   365         }
   352         ++currentIndex;
   366         ++currentIndex;
   353     }
   367     }
   354     
   368     
   355     if( FmDlgUtils::showSingleSettingQuery( title, queryStringList, selectIndex ) )
   369     if( FmDlgUtils::showSingleSettingQuery( title, queryStringList, selectIndex, associatedDrives ) )
   356     {
   370     {
   357         mBackupSettings->setTargetDrive( driveStringList.at( selectIndex ) );
   371         mBackupSettings->setTargetDrive( driveStringList.at( selectIndex ) );
   358         emit doModelRefresh();
   372         emit doModelRefresh();
   359     }
   373     }
   360 }
   374 }