filemanager/src/filemanager/src/backuprestore/fmbackupwidget.cpp
changeset 37 15bc28c9dd51
parent 16 ada7962b4308
--- a/filemanager/src/filemanager/src/backuprestore/fmbackupwidget.cpp	Mon May 03 12:24:39 2010 +0300
+++ b/filemanager/src/filemanager/src/backuprestore/fmbackupwidget.cpp	Tue Aug 24 10:24:14 2010 +0800
@@ -35,9 +35,8 @@
 #include <hbdataformviewitem.h>
 
 
-
 FmBackupWidget::FmBackupWidget( QGraphicsItem *parent )
-: HbWidget( parent ), mLastPressedItem( 0 ), mScrolled( 0 )
+: HbWidget( parent )
 {
     init();
 }
@@ -48,38 +47,24 @@
     delete mModel;
 }
 
-void FmBackupWidget::on_list_released( const QModelIndex &index )
-{
-    HbDataFormModelItem *item = mModel->itemFromIndex(index);
-    if( item != mLastPressedItem || mDataForm->isScrolling() || mScrolled ) {
-        mScrolled = false;
-        return;
-    }
-    mScrolled = false;
 
-    if( item == mContentsItem ){
-        ChangeContents();
+void FmBackupWidget::on_list_activated( const QModelIndex &index )
+{    
+    // change item data when receive activated signal
+	HbDataFormModelItem *item = mModel->itemFromIndex(index);
+	if( item == mContentsItem ){
+        emit changeContents();
     } else if( item == mTargetItem ){
-        ChangeTargetDrive();
+        emit changeTargetDrive();
     } else if( item == mSchedulingItem ){
-        ChangeScheduling();
+        emit changeScheduling();
     } else if( item == mWeekdayItem ){
-        ChangeWeekday();
+        emit changeWeekday();
     } else if( item == mTimeItem ){
-        ChangeTime();
+        emit changeTime();
     }
 }
 
-void FmBackupWidget::on_list_pressed( const QModelIndex &index )
-{
-    mLastPressedItem = mModel->itemFromIndex(index);
-}
-
-void FmBackupWidget::on_list_scrollingStarted()
-{
-    mScrolled = true;
-}
-
 void FmBackupWidget::init()
 {
     QGraphicsLinearLayout *vLayout = new QGraphicsLinearLayout( this );
@@ -92,19 +77,19 @@
     mDataForm = new HbDataForm( this );
     mDataForm->setModel( mModel );
     vLayout->addItem( mDataForm );
-    
-    connect( mDataForm, SIGNAL( released( const QModelIndex & ) ),
-             this, SLOT( on_list_released( const QModelIndex & ) ) );
-
-    connect( mDataForm, SIGNAL( pressed( const QModelIndex & ) ),
-             this, SLOT( on_list_pressed( const QModelIndex & ) ) );
-
-    connect( mDataForm, SIGNAL( scrollingStarted() ),
-             this, SLOT( on_list_scrollingStarted() ) );
+        
+    connect( mDataForm, SIGNAL( activated( const QModelIndex & ) ),
+             this, SLOT( on_list_activated( const QModelIndex & ) ) );
 
     connect( this, SIGNAL( doModelRefresh() ),
              this, SLOT( refreshModel() ), Qt::QueuedConnection );
-
+    
+    connect( this, SIGNAL(changeContents()), this, SLOT(on_changeContents()), Qt::QueuedConnection);
+    connect( this, SIGNAL(changeScheduling()), this, SLOT(on_changeScheduling()), Qt::QueuedConnection);
+    connect( this, SIGNAL(changeWeekday()), this, SLOT(on_changeWeekday()), Qt::QueuedConnection);
+    connect( this, SIGNAL(changeTime()), this, SLOT(on_changeTime()), Qt::QueuedConnection);
+    connect( this, SIGNAL(changeTargetDrive()), this, SLOT(on_changeTargetDrive()), Qt::QueuedConnection);
+    
     //mBackupSettings = new FmBackupSettings();
     mBackupSettings = FmViewManager::viewManager()->operationService()->backupRestoreHandler()->bkupEngine()->BackupSettingsL();
     mBackupSettings->load();
@@ -115,7 +100,7 @@
 
 void FmBackupWidget::expandAllGroup()
 {
-    FmLogger::log( QString( "function expandAllGroup start" ) );
+    FM_LOG( QString( "function expandAllGroup start" ) );
     
     mDataForm->setModel( 0 );
     mDataForm->setModel( mModel );
@@ -123,51 +108,62 @@
     HbDataFormViewItem *itemScheduling = 
         (HbDataFormViewItem *)(mDataForm->itemByIndex(mModel->indexFromItem(mSchedulingGroup)));
     if( itemScheduling ){
-        FmLogger::log( QString( "expand itemScheduling start" ) );
+        FM_LOG( QString( "expand itemScheduling start" ) );
         itemScheduling->setExpanded( true );
-        FmLogger::log( QString( "expand itemScheduling end" ) );
+        FM_LOG( QString( "expand itemScheduling end" ) );
     }
 
     HbDataFormViewItem *itemGroup = 
         (HbDataFormViewItem *)(mDataForm->itemByIndex(mModel->indexFromItem(mContentsGroup)));
     if( itemGroup ){
-        FmLogger::log( QString( "expand itemGroup start" ) );
+        FM_LOG( QString( "expand itemGroup start" ) );
         itemGroup->setExpanded( true );
-        FmLogger::log( QString( "expand itemGroup end" ) );
+        FM_LOG( QString( "expand itemGroup end" ) );
     }
-    FmLogger::log( QString( "function expandAllGroup end" ) );
+    FM_LOG( QString( "function expandAllGroup end" ) );
 }
 
 void FmBackupWidget::initModel()
 {
     mContentsGroup = mModel->appendDataFormGroup(
-        QString( tr( "Contents" ) ), mModel->invisibleRootItem());
+        QString( hbTrId( "Contents" ) ), mModel->invisibleRootItem());
 
     mContentsItem = mModel->appendDataFormItem(
         HbDataFormModelItem::TextItem, QString( "" ), mContentsGroup );
     mContentsItem->setContentWidgetData( QString("readOnly"), QString("true") );
+    mContentsItem->setContentWidgetData( QString("objectName"), QString("backupContentItem") );
 
     mTargetItem = mModel->appendDataFormItem(
         HbDataFormModelItem::TextItem, QString( "" ), mContentsGroup );
     mTargetItem->setContentWidgetData( QString("readOnly"), QString("true") );
+    mTargetItem->setContentWidgetData( QString("objectName"), QString("backupTargetItem") );
 
     mSchedulingGroup = mModel->appendDataFormGroup(
-        QString( tr( "Scheduling" ) ), mModel->invisibleRootItem());
+        QString( hbTrId( "Scheduling" ) ), mModel->invisibleRootItem());
 
     mSchedulingItem = mModel->appendDataFormItem(
         HbDataFormModelItem::TextItem, QString( "" ), mSchedulingGroup );
     mSchedulingItem->setContentWidgetData( QString("readOnly"), QString("true") );
+    mSchedulingItem->setContentWidgetData( QString("objectName"), QString("backupSchedulingItem") );
 
     mWeekdayItem = mModel->appendDataFormItem(
         HbDataFormModelItem::TextItem, QString( "" ), mSchedulingGroup );
     mWeekdayItem->setContentWidgetData( QString("readOnly"), QString("true") );
+    mWeekdayItem->setContentWidgetData( QString("objectName"), QString("backupWeekdayItem") );
 
     mTimeItem = mModel->appendDataFormItem(
         HbDataFormModelItem::TextItem, QString( "" ), mSchedulingGroup );
     mTimeItem->setContentWidgetData( QString("readOnly"), QString("true") );
+    mTimeItem->setContentWidgetData( QString("objectName"), QString("backupTimeItem") );
+    
+    mLastBackupDateItem = mModel->appendDataFormItem(
+        HbDataFormModelItem::TextItem, QString( ( "" )), mModel->invisibleRootItem() );
+    mLastBackupDateItem->setContentWidgetData( QString("readOnly"), QString("true") );   
+    mLastBackupDateItem->setContentWidgetData( QString("objectName"), QString("backupLastBackupDateItem") );
 }
 
 
+
 void FmBackupWidget::refreshModel()
 {
     mDataForm->setModel( 0 );
@@ -246,6 +242,11 @@
             mTimeItem->setContentWidgetData( QString("text"), tips );
             break;
             }
+        case FmBackupEntry::EBackupdate:
+            {            
+            mLastBackupDateItem->setContentWidgetData( QString("text"), tips );
+            break;
+            }
         }
     }
 
@@ -254,12 +255,10 @@
     expandAllGroup();
 }
 
-
-
-void FmBackupWidget::ChangeContents()
+void FmBackupWidget::on_changeContents()
 {
     
-    QString title = constFileManagerBackupSettingsTitleContents;  
+    QString title = mContentsItem->label();  
     QStringList queryStringList;
     quint32 contentMask = FmBackupSettings::EFileManagerBackupContentAll;
     while ( contentMask <= FmBackupSettings::EFileManagerBackupContentLast)
@@ -277,9 +276,9 @@
 } 
 
 
-void FmBackupWidget::ChangeScheduling()
+void FmBackupWidget::on_changeScheduling()
 {
-    QString title = constFileManagerBackupSettingsTitleScheduling;  
+    QString title = mSchedulingItem->label();  
     QStringList queryStringList;
 
     FmBackupSettings::TFileManagerBackupSchedule schedule = FmBackupSettings::EFileManagerBackupScheduleNever;
@@ -299,9 +298,9 @@
     }
 }
 
-void FmBackupWidget::ChangeWeekday()
+void FmBackupWidget::on_changeWeekday()
 {
-    QString title = constFileManagerBackupSettingsTitleWeekday;  
+    QString title = mWeekdayItem->label();
     QStringList queryStringList;
 
     FmBackupSettings::TFileManagerBackupWeekday weekday = FmBackupSettings::EFileManagerBackupWeekdayMonday;
@@ -321,9 +320,9 @@
     }
 }
 
-void FmBackupWidget::ChangeTime()
+void FmBackupWidget::on_changeTime()
 {
-    QString title = constFileManagerBackupSettingsTitleTime;  
+    QString title = mTimeItem->label();  
     QTime queryTime = mBackupSettings->time();
 
     if( FmDlgUtils::showTimeSettingQuery( title, queryTime ) )
@@ -334,41 +333,19 @@
 }
 
 
-void FmBackupWidget::ChangeTargetDrive()
+void FmBackupWidget::on_changeTargetDrive()
 {
-    QString title = constFileManagerBackupSettingsTitleTargetDrive;  
-    QStringList queryStringList;
-    QStringList driveStringList;
-
-    QStringList driveList;
-    //FmUtils::getDriveList( driveList, true );
-    FmViewManager::viewManager()->operationService()->backupRestoreHandler()->getBackupDriveList( driveList );
-    QString targetDrive =  mBackupSettings->targetDrive();
-    int selectIndex = -1;
-
-    int currentIndex = 0;
-    QString associatedDrives;
-    for( QStringList::const_iterator it = driveList.begin(); it != driveList.end(); ++it )
-    {
-        QString drive = (*it);
-        drive = FmUtils::removePathSplash( drive );
-        QString driveWithVolume = FmUtils::fillDriveVolume( drive, true );
-
-        driveStringList.push_back( drive );
-        queryStringList.push_back( driveWithVolume );
-        associatedDrives += FmUtils::getDriveLetterFromPath(drive);
-
-        if( drive == targetDrive )
-        {
-            // adjust index offset against drive.
-            selectIndex = currentIndex;
-        }
-        ++currentIndex;
-    }
-    
-    if( FmDlgUtils::showSingleSettingQuery( title, queryStringList, selectIndex, associatedDrives ) )
-    {
-        mBackupSettings->setTargetDrive( driveStringList.at( selectIndex ) );
+    QString title = mTargetItem->label();  
+    QString drive = FmDlgUtils::showBackupDriveQuery( title );
+    if( ( !drive.isEmpty() ) && 
+            ( mBackupSettings->targetDrive().compare( drive, Qt::CaseInsensitive ) != 0 ) ) {
+        mBackupSettings->setTargetDrive( drive );
         emit doModelRefresh();
     }
 }
+
+void FmBackupWidget::updateBackupDate()
+{
+    mBackupSettings->updateBackupDate();
+    emit doModelRefresh();
+}