35 #include <hbtoolbar.h> |
35 #include <hbtoolbar.h> |
36 #include <hblineedit.h> |
36 #include <hblineedit.h> |
37 #include <hbmessagebox.h> |
37 #include <hbmessagebox.h> |
38 #include <hbpushbutton.h> |
38 #include <hbpushbutton.h> |
39 #include <hbmainwindow.h> |
39 #include <hbmainwindow.h> |
40 #include <hbinputdialog.h> |
|
41 #include <hbprogressnote.h> |
|
42 |
|
43 |
|
44 |
40 |
45 FmFileView::FmFileView() : FmViewBase( EFileView ), mWidget( 0 ), |
41 FmFileView::FmFileView() : FmViewBase( EFileView ), mWidget( 0 ), |
46 mUpButton( 0 ), mStyleAction( 0 ), mSelectableAction( 0 ), |
42 mUpButton( 0 ), mStyleAction( 0 ), mSelectableAction( 0 ), |
47 mFindAction( 0 ), mOperationService( 0 ) |
43 mFindAction( 0 ), mOperationService( 0 ), mMenu( 0 ) |
48 { |
44 { |
49 mOperationService = FmViewManager::viewManager()->operationService(); |
45 mOperationService = FmViewManager::viewManager()->operationService(); |
50 initMenu(); |
46 initMenu(); |
51 initMainWidget(); |
47 initMainWidget(); |
52 initToolBar(); |
48 initToolBar(); |
64 if( pathName.isEmpty() ) { |
60 if( pathName.isEmpty() ) { |
65 return; |
61 return; |
66 } |
62 } |
67 mWidget->setRootPath( pathName ); |
63 mWidget->setRootPath( pathName ); |
68 QString driveName = FmUtils::getDriveNameFromPath( pathName ); |
64 QString driveName = FmUtils::getDriveNameFromPath( pathName ); |
|
65 /* |
69 FmDriverInfo driverInfo = FmUtils::queryDriverInfo( driveName ); |
66 FmDriverInfo driverInfo = FmUtils::queryDriverInfo( driveName ); |
70 QString volumeName = driverInfo.volumeName(); |
67 QString volumeName = driverInfo.volumeName(); |
71 if( volumeName.isEmpty() ){ |
68 if( volumeName.isEmpty() ){ |
72 quint32 driveState = FmUtils::getDriverState( driveName ); |
69 FmDriverInfo::DriveState driveState = FmUtils::queryDriverInfo( driveName ).driveState(); |
73 if( !( driveState & FmDriverInfo::EDriveNotPresent ) ){ |
70 if( !( driveState & FmDriverInfo::EDriveNotPresent ) ){ |
74 if( driveState & FmDriverInfo::EDriveRemovable ) { |
71 if( driveState & FmDriverInfo::EDriveRemovable ) { |
75 if( driveState & FmDriverInfo::EDriveMassStorage ) { |
72 if( driveState & FmDriverInfo::EDriveMassStorage ) { |
76 volumeName.append( tr( "Mass Storage" ) ); |
73 volumeName.append( hbTrId( "Mass Storage" ) ); |
77 } |
74 } |
78 else{ |
75 else{ |
79 volumeName.append( tr( "Memory Card" ) ); |
76 volumeName.append( hbTrId( "Memory Card" ) ); |
80 } |
77 } |
81 } |
78 } |
82 else{ |
79 else{ |
83 volumeName.append( tr( "Phone Memory" ) ); |
80 volumeName.append( hbTrId( "Phone Memory" ) ); |
84 } |
81 } |
85 } |
82 } |
86 } |
83 } |
87 |
84 */ |
88 QString titleText = FmUtils::removePathSplash( driverInfo.name() ) + ' ' + volumeName; |
85 //QString titleText = FmUtils::removePathSplash( driverInfo.name() ) + ' ' + volumeName; |
|
86 QString titleText( FmUtils::fillDriveVolume( driveName, true ) ); |
89 setTitle( titleText ); |
87 setTitle( titleText ); |
90 } |
88 } |
91 |
89 |
92 void FmFileView::setRootLevelPath( const QString &pathName ) |
90 void FmFileView::setRootLevelPath( const QString &pathName ) |
93 { |
91 { |
105 { |
103 { |
106 HbAction *action = 0; |
104 HbAction *action = 0; |
107 #ifdef FM_CHANGE_ORIENT_ENABLE |
105 #ifdef FM_CHANGE_ORIENT_ENABLE |
108 action = new HbAction( this ); |
106 action = new HbAction( this ); |
109 action->setObjectName( "rotateAction" ); |
107 action->setObjectName( "rotateAction" ); |
110 action->setText( tr( "Change orientation" ) ); |
108 action->setText( hbTrId( "Change orientation" ) ); |
111 menu()->addAction( action ); |
109 menu()->addAction( action ); |
112 #endif |
110 #endif |
113 |
111 |
114 mStyleAction = new HbAction( this ); |
112 mStyleAction = new HbAction( this ); |
115 mStyleAction->setObjectName( "switchStyle" ); |
113 mStyleAction->setObjectName( "switchStyle" ); |
119 mSelectableAction->setObjectName( "setSelectable" ); |
117 mSelectableAction->setObjectName( "setSelectable" ); |
120 menu()->addAction( mSelectableAction ); |
118 menu()->addAction( mSelectableAction ); |
121 |
119 |
122 action = new HbAction( this ); |
120 action = new HbAction( this ); |
123 action->setObjectName( "delete" ); |
121 action->setObjectName( "delete" ); |
124 action->setText( tr( "delete" ) ); |
122 action->setText( hbTrId( "txt_fmgr_menu_delete" ) ); |
125 menu()->addAction( action ); |
123 menu()->addAction( action ); |
126 |
124 |
127 action = new HbAction( this ); |
125 action = new HbAction( this ); |
128 action->setObjectName( "copy" ); |
126 action->setObjectName( "copy" ); |
129 action->setText( tr( "copy to" ) ); |
127 action->setText( hbTrId( "txt_fmgr_menu_copy" ) ); |
130 menu()->addAction( action ); |
128 menu()->addAction( action ); |
131 |
129 |
132 action = new HbAction( this ); |
130 action = new HbAction( this ); |
133 action->setObjectName( "move" ); |
131 action->setObjectName( "move" ); |
134 action->setText( tr( "move to" ) ); |
132 action->setText( hbTrId( "txt_fmgr_menu_move" ) ); |
135 menu()->addAction( action ); |
133 menu()->addAction( action ); |
136 |
134 |
137 |
135 action = new HbAction( this ); |
138 HbMenu *subMenu = new HbMenu( "Sort" ); |
136 action->setObjectName( "newFolder" ); |
|
137 action->setText( hbTrId( "New Folder" ) ); |
|
138 menu()->addAction( action ); |
|
139 |
|
140 HbMenu *subMenu = new HbMenu( hbTrId( "Sort" ) ); |
139 HbAction *sortNameAction = new HbAction( subMenu ); |
141 HbAction *sortNameAction = new HbAction( subMenu ); |
140 sortNameAction->setObjectName( "sortNameAction" ); |
142 sortNameAction->setObjectName( "sortNameAction" ); |
141 sortNameAction->setText( tr( "Sort by name" ) ); |
143 sortNameAction->setText( hbTrId( "Sort by name" ) ); |
142 subMenu->addAction( sortNameAction ); |
144 subMenu->addAction( sortNameAction ); |
143 |
145 |
144 HbAction *sortTimeAction = new HbAction( subMenu ); |
146 HbAction *sortTimeAction = new HbAction( subMenu ); |
145 sortTimeAction->setObjectName( "sortTimeAction" ); |
147 sortTimeAction->setObjectName( "sortTimeAction" ); |
146 sortTimeAction->setText( tr( "Sort by time" ) ); |
148 sortTimeAction->setText( hbTrId( "Sort by time" ) ); |
147 subMenu->addAction( sortTimeAction ); |
149 subMenu->addAction( sortTimeAction ); |
148 |
150 |
149 HbAction *sortSizeAction = new HbAction( subMenu ); |
151 HbAction *sortSizeAction = new HbAction( subMenu ); |
150 sortSizeAction->setObjectName( "sortSizeAction" ); |
152 sortSizeAction->setObjectName( "sortSizeAction" ); |
151 sortSizeAction->setText( tr( "Sort by size" ) ); |
153 sortSizeAction->setText( hbTrId( "Sort by size" ) ); |
152 subMenu->addAction( sortSizeAction ); |
154 subMenu->addAction( sortSizeAction ); |
153 |
155 |
154 HbAction* sortTypeAction = new HbAction( subMenu ); |
156 HbAction* sortTypeAction = new HbAction( subMenu ); |
155 sortTypeAction->setObjectName( "sortTypeAction" ); |
157 sortTypeAction->setObjectName( "sortTypeAction" ); |
156 sortTypeAction->setText( tr( "Sort by type" ) ); |
158 sortTypeAction->setText( hbTrId( "Sort by type" ) ); |
157 subMenu->addAction( sortTypeAction ); |
159 subMenu->addAction( sortTypeAction ); |
158 |
160 |
159 menu()->addMenu( subMenu ); |
161 menu()->addMenu( subMenu ); |
160 |
162 |
161 connect( sortNameAction, SIGNAL( triggered() ), |
163 connect( sortNameAction, SIGNAL( triggered() ), |
164 this, SLOT( on_sortTimeAction_triggered() ) ); |
166 this, SLOT( on_sortTimeAction_triggered() ) ); |
165 connect( sortSizeAction, SIGNAL( triggered() ), |
167 connect( sortSizeAction, SIGNAL( triggered() ), |
166 this, SLOT( on_sortSizeAction_triggered() ) ); |
168 this, SLOT( on_sortSizeAction_triggered() ) ); |
167 connect( sortTypeAction, SIGNAL( triggered() ), |
169 connect( sortTypeAction, SIGNAL( triggered() ), |
168 this, SLOT( on_sortTypeAction_triggered() ) ); |
170 this, SLOT( on_sortTypeAction_triggered() ) ); |
|
171 |
|
172 mMenu = takeMenu(); |
169 } |
173 } |
170 |
174 |
171 void FmFileView::initMainWidget() |
175 void FmFileView::initMainWidget() |
172 { |
176 { |
173 QGraphicsLinearLayout *vLayout = new QGraphicsLinearLayout( this ); |
177 QGraphicsLinearLayout *vLayout = new QGraphicsLinearLayout( this ); |
174 vLayout->setOrientation( Qt::Vertical ); |
178 vLayout->setOrientation( Qt::Vertical ); |
175 |
179 |
176 mWidget = new FmFileBrowseWidget( this ); |
180 mWidget = new FmFileBrowseWidget( this ); |
|
181 mWidget->setObjectName( "mainWidget" ); |
177 setStyle( FmFileBrowseWidget::ListStyle ); |
182 setStyle( FmFileBrowseWidget::ListStyle ); |
178 setSelectable( false ); |
183 setSelectable( false ); |
179 |
184 |
180 vLayout->addItem( mWidget ); |
185 vLayout->addItem( mWidget ); |
181 //set stretch factor to file browser widget, so that it could fully cover the client area. |
186 //set stretch factor to file browser widget, so that it could fully cover the client area. |
183 |
188 |
184 setLayout( vLayout ); |
189 setLayout( vLayout ); |
185 |
190 |
186 connect( mWidget, SIGNAL( startSearch( const QString&, const QString& ) ), |
191 connect( mWidget, SIGNAL( startSearch( const QString&, const QString& ) ), |
187 this, SLOT( startSearch( const QString&, const QString& ) ) ); |
192 this, SLOT( startSearch( const QString&, const QString& ) ) ); |
|
193 connect( mWidget, SIGNAL( setEmptyMenu( bool ) ), |
|
194 this, SLOT( on_mainWidget_setEmptyMenu( bool ) ) ); |
|
195 connect( mWidget, SIGNAL( setTitle( const QString & ) ), |
|
196 this, SLOT( on_mainWidget_setTitle( const QString & ) ) ); |
188 } |
197 } |
189 |
198 |
190 void FmFileView::initToolBar() |
199 void FmFileView::initToolBar() |
191 { |
200 { |
|
201 toolBar()->clearActions(); |
192 mFindAction = new HbAction( this ); |
202 mFindAction = new HbAction( this ); |
193 mFindAction->setObjectName( "leftAction" ); |
203 mFindAction->setObjectName( "leftAction" ); |
194 mFindAction->setText( tr("find") ); |
204 mFindAction->setText( hbTrId("txt_fmgr_opt_find") ); |
195 toolBar()->addAction( mFindAction ); |
205 toolBar()->addAction( mFindAction ); |
196 |
206 |
197 mToolBarRightAction = new HbAction( this ); |
207 mToolBarRightAction = new HbAction( this ); |
198 mToolBarRightAction->setObjectName( "rightAction" ); |
208 mToolBarRightAction->setObjectName( "rightAction" ); |
199 mToolBarRightAction->setText( hbTrId( "up" ) ); |
209 mToolBarRightAction->setText( hbTrId( "up" ) ); |
200 toolBar()->addAction( mToolBarRightAction ); |
210 toolBar()->addAction( mToolBarRightAction ); |
201 |
211 |
202 toolBar()->setOrientation( Qt::Horizontal ); |
212 toolBar()->setOrientation( Qt::Horizontal ); |
|
213 |
|
214 //mToolBar = takeToolBar(); |
|
215 connect( mFindAction, SIGNAL( triggered() ), |
|
216 this, SLOT( on_leftAction_triggered() ) ); |
|
217 connect( mToolBarRightAction, SIGNAL( triggered() ), |
|
218 this, SLOT( on_rightAction_triggered() ) ); |
|
219 |
203 } |
220 } |
204 |
221 |
205 void FmFileView::setStyle( FmFileBrowseWidget::Style style ) |
222 void FmFileView::setStyle( FmFileBrowseWidget::Style style ) |
206 { |
223 { |
207 if ( style == FmFileBrowseWidget::ListStyle ) { |
224 if ( style == FmFileBrowseWidget::ListStyle ) { |
208 mStyleAction->setText( tr("Tree") ); |
225 mStyleAction->setText( hbTrId("Tree") ); |
209 } else if ( style == FmFileBrowseWidget::TreeStyle ) { |
226 } else if ( style == FmFileBrowseWidget::TreeStyle ) { |
210 mStyleAction->setText( tr("List") ); |
227 mStyleAction->setText( hbTrId("List") ); |
211 } |
228 } |
212 |
229 |
213 mWidget->setStyle( style ); |
230 mWidget->setStyle( style ); |
214 } |
231 } |
215 |
232 |
216 void FmFileView::setSelectable( bool enable ) |
233 void FmFileView::setSelectable( bool enable ) |
217 { |
234 { |
218 if (enable) { |
235 if (enable) { |
219 mSelectableAction->setText( tr("No Select") ); |
236 mSelectableAction->setText( hbTrId("No Select") ); |
220 } else { |
237 } else { |
221 mSelectableAction->setText( tr("Select") ); |
238 mSelectableAction->setText( hbTrId("Select") ); |
222 } |
239 } |
223 |
240 |
224 mWidget->setSelectable( enable ); |
241 mWidget->setSelectable( enable ); |
225 } |
242 } |
226 |
243 |
271 case FmErrNone: |
288 case FmErrNone: |
272 // no error, do not show note to user |
289 // no error, do not show note to user |
273 break; |
290 break; |
274 case FmErrAlreadyStarted: |
291 case FmErrAlreadyStarted: |
275 // last operation have not finished |
292 // last operation have not finished |
276 HbMessageBox::information( tr( "Operatin already started!" ) ); |
293 HbMessageBox::information( hbTrId( "Operatin already started!" ) ); |
277 break; |
294 break; |
278 case FmErrWrongParam: |
295 case FmErrWrongParam: |
279 HbMessageBox::information( tr( "Wrong parameters!" ) ); |
296 HbMessageBox::information( hbTrId( "Wrong parameters!" ) ); |
280 break; |
297 break; |
281 default: |
298 default: |
282 HbMessageBox::information( tr( "Operation fail to start!" ) ); |
299 HbMessageBox::information( hbTrId( "Operation fail to start!" ) ); |
283 } |
300 } |
284 setSelectable( false ); |
301 setSelectable( false ); |
285 } |
302 } |
286 } |
303 } |
287 } |
304 } |
292 QStringList srcFileList; |
309 QStringList srcFileList; |
293 |
310 |
294 if (files.size() == 0) { |
311 if (files.size() == 0) { |
295 infoNoFileSelected(); |
312 infoNoFileSelected(); |
296 } else { |
313 } else { |
297 QString targetPathName = FmFileDialog::getExistingDirectory( 0, tr( "copy to" ), |
314 QString targetPathName = FmFileDialog::getExistingDirectory( 0, hbTrId( "copy to" ), |
298 QString(""), QStringList() ); |
315 QString(""), QStringList() ); |
299 if( !targetPathName.isEmpty() && files.size() > 0 ) { |
316 if( !targetPathName.isEmpty() && files.size() > 0 ) { |
300 targetPathName = FmUtils::fillPathWithSplash( targetPathName ); |
317 targetPathName = FmUtils::fillPathWithSplash( targetPathName ); |
301 |
318 |
302 foreach( QFileInfo fileInfo, files ){ |
319 foreach( QFileInfo fileInfo, files ){ |
309 case FmErrNone: |
326 case FmErrNone: |
310 // no error, do not show note to user |
327 // no error, do not show note to user |
311 break; |
328 break; |
312 case FmErrAlreadyStarted: |
329 case FmErrAlreadyStarted: |
313 // last operation have not finished |
330 // last operation have not finished |
314 HbMessageBox::information( tr( "Operatin already started!" ) ); |
331 HbMessageBox::information( hbTrId( "Operatin already started!" ) ); |
315 break; |
332 break; |
316 case FmErrWrongParam: |
333 case FmErrWrongParam: |
317 HbMessageBox::information( tr( "Wrong parameters!" ) ); |
334 HbMessageBox::information( hbTrId( "Wrong parameters!" ) ); |
318 break; |
335 break; |
319 default: |
336 default: |
320 HbMessageBox::information( tr( "Operation fail to start!" ) ); |
337 HbMessageBox::information( hbTrId( "Operation fail to start!" ) ); |
321 } |
338 } |
322 setSelectable( false ); |
339 setSelectable( false ); |
323 } |
340 } |
324 } |
341 } |
325 |
342 |
360 setSelectable( false ); |
377 setSelectable( false ); |
361 } |
378 } |
362 } |
379 } |
363 } |
380 } |
364 |
381 |
|
382 void FmFileView::on_newFolder_triggered() |
|
383 { |
|
384 QString dirName; |
|
385 QString path = FmUtils::fillPathWithSplash( mWidget->currentPath().absoluteFilePath() ); |
|
386 QDir dir( path ); |
|
387 if( dir.exists() ) { |
|
388 while( FmDlgUtils::showTextQuery( hbTrId( "Enter name for " ), dirName, true ) ){ |
|
389 QString newTargetPath = FmUtils::fillPathWithSplash( |
|
390 dir.absolutePath() ) + dirName; |
|
391 QFileInfo newFileInfo( newTargetPath ); |
|
392 if( newFileInfo.exists() ) { |
|
393 HbMessageBox::information( hbTrId( "%1 already exist!" ).arg( dirName ) ); |
|
394 continue; |
|
395 } |
|
396 |
|
397 if( !dir.mkdir( dirName ) ) { |
|
398 HbMessageBox::information( hbTrId("Operation failed!") ); |
|
399 } |
|
400 refreshModel( path ); |
|
401 break; |
|
402 } |
|
403 |
|
404 } |
|
405 } |
365 void FmFileView::on_upAction_triggered() |
406 void FmFileView::on_upAction_triggered() |
366 { |
407 { |
367 mWidget->cdUp(); |
408 mWidget->cdUp(); |
368 } |
409 } |
369 |
410 |