filemanager/src/filemanager/src/backuprestore/fmbackupwidget.cpp
changeset 25 b7bfdea70ca2
parent 16 ada7962b4308
child 27 df183af6b92f
equal deleted inserted replaced
16:ada7962b4308 25:b7bfdea70ca2
    33 #include <hbdataformmodel.h>
    33 #include <hbdataformmodel.h>
    34 #include <hbdataformmodelitem.h>
    34 #include <hbdataformmodelitem.h>
    35 #include <hbdataformviewitem.h>
    35 #include <hbdataformviewitem.h>
    36 
    36 
    37 
    37 
    38 
       
    39 FmBackupWidget::FmBackupWidget( QGraphicsItem *parent )
    38 FmBackupWidget::FmBackupWidget( QGraphicsItem *parent )
    40 : HbWidget( parent ), mLastPressedItem( 0 ), mScrolled( 0 )
    39 : HbWidget( parent ), mLastPressedItem( 0 ), mScrolled( 0 ), mListReleased( false )
    41 {
    40 {
    42     init();
    41     init();
    43 }
    42 }
    44 
    43 
    45 FmBackupWidget::~FmBackupWidget()
    44 FmBackupWidget::~FmBackupWidget()
    56         return;
    55         return;
    57     }
    56     }
    58     mScrolled = false;
    57     mScrolled = false;
    59 
    58 
    60     if( item == mContentsItem ){
    59     if( item == mContentsItem ){
    61         ChangeContents();
    60         emit changeContents();
    62     } else if( item == mTargetItem ){
    61     } else if( item == mTargetItem ){
    63         ChangeTargetDrive();
    62         emit changeTargetDrive();
    64     } else if( item == mSchedulingItem ){
    63     } else if( item == mSchedulingItem ){
    65         ChangeScheduling();
    64         emit changeScheduling();
    66     } else if( item == mWeekdayItem ){
    65     } else if( item == mWeekdayItem ){
    67         ChangeWeekday();
    66         emit changeWeekday();
    68     } else if( item == mTimeItem ){
    67     } else if( item == mTimeItem ){
    69         ChangeTime();
    68         emit changeTime();
    70     }
    69     }
    71 }
    70 }
    72 
    71 
    73 void FmBackupWidget::on_list_pressed( const QModelIndex &index )
    72 void FmBackupWidget::on_list_pressed( const QModelIndex &index )
    74 {
    73 {
    91 
    90 
    92     mDataForm = new HbDataForm( this );
    91     mDataForm = new HbDataForm( this );
    93     mDataForm->setModel( mModel );
    92     mDataForm->setModel( mModel );
    94     vLayout->addItem( mDataForm );
    93     vLayout->addItem( mDataForm );
    95     
    94     
       
    95     
    96     connect( mDataForm, SIGNAL( released( const QModelIndex & ) ),
    96     connect( mDataForm, SIGNAL( released( const QModelIndex & ) ),
    97              this, SLOT( on_list_released( const QModelIndex & ) ) );
    97              this, SLOT( on_list_released( const QModelIndex & ) ) );
    98 
    98 
    99     connect( mDataForm, SIGNAL( pressed( const QModelIndex & ) ),
    99     connect( mDataForm, SIGNAL( pressed( const QModelIndex & ) ),
   100              this, SLOT( on_list_pressed( const QModelIndex & ) ) );
   100              this, SLOT( on_list_pressed( const QModelIndex & ) ) );
   102     connect( mDataForm, SIGNAL( scrollingStarted() ),
   102     connect( mDataForm, SIGNAL( scrollingStarted() ),
   103              this, SLOT( on_list_scrollingStarted() ) );
   103              this, SLOT( on_list_scrollingStarted() ) );
   104 
   104 
   105     connect( this, SIGNAL( doModelRefresh() ),
   105     connect( this, SIGNAL( doModelRefresh() ),
   106              this, SLOT( refreshModel() ), Qt::QueuedConnection );
   106              this, SLOT( refreshModel() ), Qt::QueuedConnection );
   107 
   107     
       
   108     connect( this, SIGNAL(changeContents()), this, SLOT(on_changeContents()), Qt::QueuedConnection);
       
   109     connect( this, SIGNAL(changeScheduling()), this, SLOT(on_changeScheduling()), Qt::QueuedConnection);
       
   110     connect( this, SIGNAL(changeWeekday()), this, SLOT(on_changeWeekday()), Qt::QueuedConnection);
       
   111     connect( this, SIGNAL(changeTime()), this, SLOT(on_changeTime()), Qt::QueuedConnection);
       
   112     connect( this, SIGNAL(changeTargetDrive()), this, SLOT(on_changeTargetDrive()), Qt::QueuedConnection);
       
   113     
   108     //mBackupSettings = new FmBackupSettings();
   114     //mBackupSettings = new FmBackupSettings();
   109     mBackupSettings = FmViewManager::viewManager()->operationService()->backupRestoreHandler()->bkupEngine()->BackupSettingsL();
   115     mBackupSettings = FmViewManager::viewManager()->operationService()->backupRestoreHandler()->bkupEngine()->BackupSettingsL();
   110     mBackupSettings->load();
   116     mBackupSettings->load();
   111 
   117 
   112     emit doModelRefresh();
   118     emit doModelRefresh();
   139 }
   145 }
   140 
   146 
   141 void FmBackupWidget::initModel()
   147 void FmBackupWidget::initModel()
   142 {
   148 {
   143     mContentsGroup = mModel->appendDataFormGroup(
   149     mContentsGroup = mModel->appendDataFormGroup(
   144         QString( tr( "Contents" ) ), mModel->invisibleRootItem());
   150         QString( hbTrId( "Contents" ) ), mModel->invisibleRootItem());
   145 
   151 
   146     mContentsItem = mModel->appendDataFormItem(
   152     mContentsItem = mModel->appendDataFormItem(
   147         HbDataFormModelItem::TextItem, QString( "" ), mContentsGroup );
   153         HbDataFormModelItem::TextItem, QString( "" ), mContentsGroup );
   148     mContentsItem->setContentWidgetData( QString("readOnly"), QString("true") );
   154     mContentsItem->setContentWidgetData( QString("readOnly"), QString("true") );
   149 
   155 
   150     mTargetItem = mModel->appendDataFormItem(
   156     mTargetItem = mModel->appendDataFormItem(
   151         HbDataFormModelItem::TextItem, QString( "" ), mContentsGroup );
   157         HbDataFormModelItem::TextItem, QString( "" ), mContentsGroup );
   152     mTargetItem->setContentWidgetData( QString("readOnly"), QString("true") );
   158     mTargetItem->setContentWidgetData( QString("readOnly"), QString("true") );
   153 
   159 
   154     mSchedulingGroup = mModel->appendDataFormGroup(
   160     mSchedulingGroup = mModel->appendDataFormGroup(
   155         QString( tr( "Scheduling" ) ), mModel->invisibleRootItem());
   161         QString( hbTrId( "Scheduling" ) ), mModel->invisibleRootItem());
   156 
   162 
   157     mSchedulingItem = mModel->appendDataFormItem(
   163     mSchedulingItem = mModel->appendDataFormItem(
   158         HbDataFormModelItem::TextItem, QString( "" ), mSchedulingGroup );
   164         HbDataFormModelItem::TextItem, QString( "" ), mSchedulingGroup );
   159     mSchedulingItem->setContentWidgetData( QString("readOnly"), QString("true") );
   165     mSchedulingItem->setContentWidgetData( QString("readOnly"), QString("true") );
   160 
   166 
   163     mWeekdayItem->setContentWidgetData( QString("readOnly"), QString("true") );
   169     mWeekdayItem->setContentWidgetData( QString("readOnly"), QString("true") );
   164 
   170 
   165     mTimeItem = mModel->appendDataFormItem(
   171     mTimeItem = mModel->appendDataFormItem(
   166         HbDataFormModelItem::TextItem, QString( "" ), mSchedulingGroup );
   172         HbDataFormModelItem::TextItem, QString( "" ), mSchedulingGroup );
   167     mTimeItem->setContentWidgetData( QString("readOnly"), QString("true") );
   173     mTimeItem->setContentWidgetData( QString("readOnly"), QString("true") );
   168 }
   174     
       
   175     mLastBackupDateItem = mModel->appendDataFormItem(
       
   176         HbDataFormModelItem::TextItem, QString( ( "" )), mModel->invisibleRootItem() );
       
   177     mLastBackupDateItem->setContentWidgetData( QString("readOnly"), QString("true") );   
       
   178     
       
   179 }
       
   180 
   169 
   181 
   170 
   182 
   171 void FmBackupWidget::refreshModel()
   183 void FmBackupWidget::refreshModel()
   172 {
   184 {
   173     mDataForm->setModel( 0 );
   185     mDataForm->setModel( 0 );
   244             mTimeItem->setContentWidgetData( QString("readOnly"), QString("true") );
   256             mTimeItem->setContentWidgetData( QString("readOnly"), QString("true") );
   245             mTimeItem->setLabel(title);
   257             mTimeItem->setLabel(title);
   246             mTimeItem->setContentWidgetData( QString("text"), tips );
   258             mTimeItem->setContentWidgetData( QString("text"), tips );
   247             break;
   259             break;
   248             }
   260             }
       
   261         case FmBackupEntry::EBackupdate:
       
   262             {            
       
   263             mLastBackupDateItem->setContentWidgetData( QString("text"), tips );
       
   264             break;
       
   265             }
   249         }
   266         }
   250     }
   267     }
   251 
   268 
   252     mDataForm->setModel( mModel );
   269     mDataForm->setModel( mModel );
   253 
   270 
   254     expandAllGroup();
   271     expandAllGroup();
   255 }
   272 }
   256 
   273 
   257 
   274 void FmBackupWidget::on_changeContents()
   258 
   275 {
   259 void FmBackupWidget::ChangeContents()
   276     
   260 {
   277     QString title = mContentsItem->label();  
   261     
       
   262     QString title = constFileManagerBackupSettingsTitleContents;  
       
   263     QStringList queryStringList;
   278     QStringList queryStringList;
   264     quint32 contentMask = FmBackupSettings::EFileManagerBackupContentAll;
   279     quint32 contentMask = FmBackupSettings::EFileManagerBackupContentAll;
   265     while ( contentMask <= FmBackupSettings::EFileManagerBackupContentLast)
   280     while ( contentMask <= FmBackupSettings::EFileManagerBackupContentLast)
   266     {
   281     {
   267         queryStringList.push_back( mBackupSettings->contentToString( contentMask ) );
   282         queryStringList.push_back( mBackupSettings->contentToString( contentMask ) );
   275     }
   290     }
   276     
   291     
   277 } 
   292 } 
   278 
   293 
   279 
   294 
   280 void FmBackupWidget::ChangeScheduling()
   295 void FmBackupWidget::on_changeScheduling()
   281 {
   296 {
   282     QString title = constFileManagerBackupSettingsTitleScheduling;  
   297     QString title = mSchedulingItem->label();  
   283     QStringList queryStringList;
   298     QStringList queryStringList;
   284 
   299 
   285     FmBackupSettings::TFileManagerBackupSchedule schedule = FmBackupSettings::EFileManagerBackupScheduleNever;
   300     FmBackupSettings::TFileManagerBackupSchedule schedule = FmBackupSettings::EFileManagerBackupScheduleNever;
   286     while ( schedule <= FmBackupSettings::EFileManagerBackupScheduleWeekly )
   301     while ( schedule <= FmBackupSettings::EFileManagerBackupScheduleWeekly )
   287     {
   302     {
   297         mBackupSettings->setScheduling( ( FmBackupSettings::TFileManagerBackupSchedule )selectIndex );
   312         mBackupSettings->setScheduling( ( FmBackupSettings::TFileManagerBackupSchedule )selectIndex );
   298         emit doModelRefresh();
   313         emit doModelRefresh();
   299     }
   314     }
   300 }
   315 }
   301 
   316 
   302 void FmBackupWidget::ChangeWeekday()
   317 void FmBackupWidget::on_changeWeekday()
   303 {
   318 {
   304     QString title = constFileManagerBackupSettingsTitleWeekday;  
   319     QString title = mWeekdayItem->label();
   305     QStringList queryStringList;
   320     QStringList queryStringList;
   306 
   321 
   307     FmBackupSettings::TFileManagerBackupWeekday weekday = FmBackupSettings::EFileManagerBackupWeekdayMonday;
   322     FmBackupSettings::TFileManagerBackupWeekday weekday = FmBackupSettings::EFileManagerBackupWeekdayMonday;
   308     while ( weekday <= FmBackupSettings::EFileManagerBackupWeekdaySunday )
   323     while ( weekday <= FmBackupSettings::EFileManagerBackupWeekdaySunday )
   309     {
   324     {
   319         mBackupSettings->setWeekday( (FmBackupSettings::TFileManagerBackupWeekday)selectIndex );
   334         mBackupSettings->setWeekday( (FmBackupSettings::TFileManagerBackupWeekday)selectIndex );
   320         emit doModelRefresh();
   335         emit doModelRefresh();
   321     }
   336     }
   322 }
   337 }
   323 
   338 
   324 void FmBackupWidget::ChangeTime()
   339 void FmBackupWidget::on_changeTime()
   325 {
   340 {
   326     QString title = constFileManagerBackupSettingsTitleTime;  
   341     QString title = mTimeItem->label();  
   327     QTime queryTime = mBackupSettings->time();
   342     QTime queryTime = mBackupSettings->time();
   328 
   343 
   329     if( FmDlgUtils::showTimeSettingQuery( title, queryTime ) )
   344     if( FmDlgUtils::showTimeSettingQuery( title, queryTime ) )
   330     {
   345     {
   331         mBackupSettings->setTime( queryTime );
   346         mBackupSettings->setTime( queryTime );
   332         emit doModelRefresh();
   347         emit doModelRefresh();
   333     }
   348     }
   334 }
   349 }
   335 
   350 
   336 
   351 
   337 void FmBackupWidget::ChangeTargetDrive()
   352 void FmBackupWidget::on_changeTargetDrive()
   338 {
   353 {
   339     QString title = constFileManagerBackupSettingsTitleTargetDrive;  
   354     QString title = mTargetItem->label();  
   340     QStringList queryStringList;
   355     QString drive = FmDlgUtils::showBackupDriveQuery( title );
   341     QStringList driveStringList;
   356     if( ( !drive.isEmpty() ) && 
   342 
   357             ( mBackupSettings->targetDrive().compare( drive, Qt::CaseInsensitive ) != 0 ) ) {
   343     QStringList driveList;
   358         mBackupSettings->setTargetDrive( drive );
   344     //FmUtils::getDriveList( driveList, true );
   359         emit doModelRefresh();
   345     FmViewManager::viewManager()->operationService()->backupRestoreHandler()->getBackupDriveList( driveList );
   360     }
   346     QString targetDrive =  mBackupSettings->targetDrive();
   361 }
   347     int selectIndex = -1;
   362 
   348 
   363 void FmBackupWidget::updateBackupDate()
   349     int currentIndex = 0;
   364 {
   350     QString associatedDrives;
   365     mBackupSettings->updateBackupDate();
   351     for( QStringList::const_iterator it = driveList.begin(); it != driveList.end(); ++it )
   366     emit doModelRefresh();
   352     {
   367 }
   353         QString drive = (*it);
       
   354         drive = FmUtils::removePathSplash( drive );
       
   355         QString driveWithVolume = FmUtils::fillDriveVolume( drive, true );
       
   356 
       
   357         driveStringList.push_back( drive );
       
   358         queryStringList.push_back( driveWithVolume );
       
   359         associatedDrives += FmUtils::getDriveLetterFromPath(drive);
       
   360 
       
   361         if( drive == targetDrive )
       
   362         {
       
   363             // adjust index offset against drive.
       
   364             selectIndex = currentIndex;
       
   365         }
       
   366         ++currentIndex;
       
   367     }
       
   368     
       
   369     if( FmDlgUtils::showSingleSettingQuery( title, queryStringList, selectIndex, associatedDrives ) )
       
   370     {
       
   371         mBackupSettings->setTargetDrive( driveStringList.at( selectIndex ) );
       
   372         emit doModelRefresh();
       
   373     }
       
   374 }