filemanager/src/filemanager/src/backuprestore/fmrestoreview.cpp
changeset 37 15bc28c9dd51
parent 16 ada7962b4308
child 46 d58987eac7e8
equal deleted inserted replaced
16:ada7962b4308 37:15bc28c9dd51
    18 
    18 
    19 #include "fmrestoreview.h"
    19 #include "fmrestoreview.h"
    20 #include "fmrestorewidget.h"
    20 #include "fmrestorewidget.h"
    21 #include "fmviewmanager.h"
    21 #include "fmviewmanager.h"
    22 #include "fmoperationbase.h"
    22 #include "fmoperationbase.h"
       
    23 #include "fmdlgutils.h"
    23 
    24 
    24 #include <QApplication>
    25 #include <QApplication>
    25 
    26 
    26 #include <hbaction.h>
    27 #include <hbaction.h>
    27 #include <hbtoolbar.h>
    28 #include <hbtoolbar.h>
    28 #include <hbmenu.h>
    29 #include <hbmenu.h>
    29 #include <hbmainwindow.h>
    30 #include <hbmainwindow.h>
    30 #include <hbmessagebox.h>
       
    31 
       
    32 
       
    33 
    31 
    34 FmRestoreView::FmRestoreView(): FmViewBase( ERestoreView )
    32 FmRestoreView::FmRestoreView(): FmViewBase( ERestoreView )
    35 {
    33 {
    36 	setTitle( hbTrId( "Restore" ) );
    34 	setTitle( hbTrId( "Restore" ) );
    37 
    35 
    38 	initMainWidget();
    36 	initMainWidget();
    39 	initToolBar();
    37 	initToolBar();
    40 	initMenu();
    38 	initMenu();  
    41     adjustActions();
       
    42 	mOperationService = FmViewManager::viewManager()->operationService();
    39 	mOperationService = FmViewManager::viewManager()->operationService();
    43 
       
    44 	QMetaObject::connectSlotsByName( this );
       
    45 }
    40 }
    46 
    41 
    47 FmRestoreView::~FmRestoreView()
    42 FmRestoreView::~FmRestoreView()
    48 {
    43 {
    49     removeToolBarAction();
    44     removeToolBarAction();
    55     HbAction *action = 0;
    50     HbAction *action = 0;
    56 	action = new HbAction( this );
    51 	action = new HbAction( this );
    57     action->setObjectName( "rotateAction" );
    52     action->setObjectName( "rotateAction" );
    58     action->setText( hbTrId( "Change orientation" ) );
    53     action->setText( hbTrId( "Change orientation" ) );
    59     menu()->addAction( action );
    54     menu()->addAction( action );
       
    55     connect( action, SIGNAL(triggered()), this, SLOT( on_rotateAction_triggered() ), Qt::QueuedConnection );
    60 #endif
    56 #endif
    61 
    57 
    62 	mRestoreAction = new HbAction( this );
    58 	mRestoreAction = new HbAction( this );
    63     mRestoreAction->setObjectName( "restoreAction" );
    59     mRestoreAction->setObjectName( "restoreAction" );
    64     mRestoreAction->setText( hbTrId( "Restore data" ) );
    60     mRestoreAction->setText( hbTrId( "Restore data" ) );
    65     menu()->addAction( mRestoreAction );
    61     menu()->addAction( mRestoreAction );
       
    62     mRestoreAction->setEnabled(false);
       
    63     connect( mRestoreAction, SIGNAL(triggered()), this, SLOT( on_restoreAction_triggered() ), Qt::QueuedConnection );
    66 }
    64 }
    67 
    65 
    68 void FmRestoreView::initMainWidget()
    66 void FmRestoreView::initMainWidget()
    69 {
    67 {
    70 	mRestoreWigdet = new FmRestoreWigdet( this );
    68 	mRestoreWigdet = new FmRestoreWigdet( this );
    71 
    69 
    72     setWidget( mRestoreWigdet );
    70     setWidget( mRestoreWigdet );
       
    71     connect(mRestoreWigdet, SIGNAL(stateChanged(int)), this, SLOT(onCheckBoxStateChange()));
    73 
    72 
    74 }
    73 }
    75 
    74 
    76 void FmRestoreView::initToolBar()
    75 void FmRestoreView::initToolBar()
    77 {
    76 {
    78 	mLeftAction = new HbAction( this );
    77 	mLeftAction = new HbAction( this );
    79     mLeftAction->setObjectName( "leftAction" );
    78     mLeftAction->setObjectName( "leftAction" );
    80     mLeftAction->setText( hbTrId( "Restore" ) );
    79     mLeftAction->setText( hbTrId( "Restore" ) );
    81     toolBar()->addAction( mLeftAction );
    80     toolBar()->addAction( mLeftAction );
    82     
    81     connect( mLeftAction, SIGNAL(triggered()), this, SLOT( on_leftAction_triggered() ), Qt::QueuedConnection );
       
    82 
       
    83     mLeftAction->setEnabled(false);
    83     toolBar()->setOrientation( Qt::Horizontal );
    84     toolBar()->setOrientation( Qt::Horizontal );
    84 }
    85 }
    85 
    86 
    86 void FmRestoreView::on_leftAction_triggered()
    87 void FmRestoreView::on_leftAction_triggered()
    87 {
    88 {
    96     switch( ret )
    97     switch( ret )
    97     {
    98     {
    98     case FmErrNone:
    99     case FmErrNone:
    99         break;
   100         break;
   100     case FmErrWrongParam:
   101     case FmErrWrongParam:
   101         HbMessageBox::information( QString( hbTrId("Operation canceled with wrong param!") ) );
   102         FmDlgUtils::information( QString( hbTrId("Operation canceled with wrong param!") ) );
   102         break;
   103         break;
   103     case FmErrAlreadyStarted:
   104     case FmErrAlreadyStarted:
   104         HbMessageBox::information( QString( hbTrId("Operation canceled because already started!") ) );
   105         FmDlgUtils::information( QString( hbTrId("Operation canceled because already started!") ) );
   105         break;
   106         break;
   106     default:
   107     default:
   107         HbMessageBox::information(tr("restore failed"));
   108         FmDlgUtils::information(hbTrId("restore failed"));
   108         break;
   109         break;
   109     }
   110     }
   110 }
   111 }
   111 
   112 
   112 #ifdef FM_CHANGE_ORIENT_ENABLE
   113 #ifdef FM_CHANGE_ORIENT_ENABLE
   124 void FmRestoreView::on_restoreAction_triggered()
   125 void FmRestoreView::on_restoreAction_triggered()
   125 {
   126 {
   126     on_leftAction_triggered();
   127     on_leftAction_triggered();
   127 }
   128 }
   128 
   129 
   129 void FmRestoreView::adjustActions()
       
   130 {
       
   131     if( mRestoreWigdet->backupDataCount() > 0 ) {
       
   132         mRestoreAction->setDisabled( false );
       
   133         mLeftAction->setDisabled( false );
       
   134     } else {
       
   135         mRestoreAction->setDisabled( true );
       
   136         mLeftAction->setDisabled( true );
       
   137     }
       
   138 }
       
   139 
       
   140 void FmRestoreView::removeToolBarAction()
   130 void FmRestoreView::removeToolBarAction()
   141 {
   131 {
   142     toolBar()->removeAction( mLeftAction );
   132     toolBar()->removeAction( mLeftAction );
   143 }
   133 }
   144 
   134 
       
   135 void FmRestoreView::onCheckBoxStateChange()
       
   136 {
       
   137     QList<int> items = mRestoreWigdet->selectionIndexes();
       
   138     if (items.count() > 0) {
       
   139         mLeftAction->setEnabled(true);
       
   140         mRestoreAction->setEnabled(true);
       
   141     } else {
       
   142         mLeftAction->setEnabled(false);
       
   143         mRestoreAction->setEnabled(false);
       
   144     }
       
   145 }
       
   146 
       
   147 void FmRestoreView::refreshRestoreView()
       
   148 {
       
   149     mRestoreWigdet->refresh();
       
   150 }