|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * |
|
15 * Description: |
|
16 * The source file of the back up view of file manager |
|
17 */ |
|
18 |
|
19 #include "fmbackupview.h" |
|
20 #include "fmbackupwidget.h" |
|
21 #include "fmviewmanager.h" |
|
22 #include "fmoperationbase.h" |
|
23 #include "fmdlgutils.h" |
|
24 |
|
25 #include <QApplication> |
|
26 |
|
27 #include <hbaction.h> |
|
28 #include <hbtoolbar.h> |
|
29 #include <hbmenu.h> |
|
30 #include <hbmainwindow.h> |
|
31 |
|
32 FmBackupView::FmBackupView() : FmViewBase( EBackupView ) |
|
33 { |
|
34 setTitle( hbTrId( "Backup" ) ); |
|
35 |
|
36 initToolBar(); |
|
37 initMainWidget(); |
|
38 initMenu(); |
|
39 mOperationService = FmViewManager::viewManager()->operationService(); |
|
40 |
|
41 } |
|
42 |
|
43 FmBackupView::~FmBackupView() |
|
44 { |
|
45 removeToolBarAction(); |
|
46 } |
|
47 |
|
48 void FmBackupView::initMenu() |
|
49 { |
|
50 HbAction *action = 0; |
|
51 |
|
52 #ifdef FM_CHANGE_ORIENT_ENABLE |
|
53 action = new HbAction( this ); |
|
54 action->setObjectName( "rotateAction" ); |
|
55 action->setText( hbTrId( "Change orientation" ) ); |
|
56 menu()->addAction( action ); |
|
57 connect( action, SIGNAL(triggered()), this, SLOT( on_rotateAction_triggered() ), Qt::QueuedConnection ); |
|
58 #endif |
|
59 |
|
60 action = new HbAction( this ); |
|
61 action->setObjectName( "backupAction" ); |
|
62 action->setText( hbTrId( "Start backup" ) ); |
|
63 menu()->addAction( action ); |
|
64 connect( action, SIGNAL(triggered()), this, SLOT( on_backupAction_triggered() ), Qt::QueuedConnection ); |
|
65 |
|
66 action = new HbAction( this ); |
|
67 action->setObjectName( "deleteBackupAction" ); |
|
68 action->setText( hbTrId( "Delete backup" ) ); |
|
69 menu()->addAction( action ); |
|
70 connect( action, SIGNAL(triggered()), this, SLOT( on_deleteBackupAction_triggered() ), Qt::QueuedConnection ); |
|
71 } |
|
72 |
|
73 void FmBackupView::initMainWidget() |
|
74 { |
|
75 mMainWidget = new FmBackupWidget( this ); |
|
76 setWidget( mMainWidget ); |
|
77 |
|
78 } |
|
79 |
|
80 void FmBackupView::initToolBar() |
|
81 { |
|
82 mToolBarAction = new HbAction( this ); |
|
83 mToolBarAction->setObjectName( "leftAction" ); |
|
84 mToolBarAction->setText( hbTrId("Start backup") ); |
|
85 toolBar()->addAction( mToolBarAction ); |
|
86 connect( mToolBarAction, SIGNAL(triggered()), this, SLOT( on_leftAction_triggered() ), Qt::QueuedConnection ); |
|
87 |
|
88 toolBar()->setOrientation( Qt::Horizontal ); |
|
89 } |
|
90 |
|
91 void FmBackupView::on_leftAction_triggered() |
|
92 { |
|
93 int ret = mOperationService->asyncBackup(); |
|
94 FM_LOG( "FmBackupView_asyncBackup: ret= " + QString::number(ret) ); |
|
95 switch( ret ) |
|
96 { |
|
97 case FmErrNone: |
|
98 break; |
|
99 case FmErrWrongParam: |
|
100 FmDlgUtils::information( QString( hbTrId("Operation canceled with wrong param!") ) ); |
|
101 break; |
|
102 case FmErrAlreadyStarted: |
|
103 FmDlgUtils::information( QString( hbTrId("Operation canceled because already started!") ) ); |
|
104 break; |
|
105 case FmErrPathNotFound: |
|
106 FmDlgUtils::information( QString( hbTrId("Operation canceled because can not find target path or drive is not available!") ) ); |
|
107 break; |
|
108 case FmErrAlreadyExists: |
|
109 FmDlgUtils::information( QString( hbTrId("backup canceled") ) ); |
|
110 break; |
|
111 default: |
|
112 FmDlgUtils::information( QString( hbTrId("backup failed") ) ); |
|
113 break; |
|
114 } |
|
115 } |
|
116 #ifdef FM_CHANGE_ORIENT_ENABLE |
|
117 void FmBackupView::on_rotateAction_triggered() |
|
118 { |
|
119 if ( mainWindow()->orientation() == Qt::Vertical ) { |
|
120 mainWindow()->setOrientation( Qt::Horizontal ); |
|
121 } |
|
122 else { |
|
123 mainWindow()->setOrientation( Qt::Vertical ); |
|
124 } |
|
125 } |
|
126 #endif //FM_CHANGE_ORIENT_ENABLE |
|
127 |
|
128 void FmBackupView::on_backupAction_triggered() |
|
129 { |
|
130 on_leftAction_triggered(); |
|
131 } |
|
132 |
|
133 void FmBackupView::on_deleteBackupAction_triggered() |
|
134 { |
|
135 FmViewManager::viewManager()->createDeleteBackupView(); |
|
136 } |
|
137 |
|
138 void FmBackupView::removeToolBarAction() |
|
139 { |
|
140 toolBar()->removeAction( mToolBarAction ); |
|
141 } |
|
142 |
|
143 void FmBackupView::refreshBackupDate() |
|
144 { |
|
145 mMainWidget->updateBackupDate(); |
|
146 } |
|
147 |
|
148 void FmBackupView::refreshModel() |
|
149 { |
|
150 mMainWidget->refreshModel(); |
|
151 } |