25
|
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 backup drive query of file manager
|
|
17 |
*/
|
|
18 |
|
|
19 |
#include "fmdrivequery.h"
|
|
20 |
#include "fmviewmanager.h"
|
|
21 |
#include "fmbackuprestorehandler.h"
|
|
22 |
|
|
23 |
#include <QGraphicsLinearLayout>
|
|
24 |
#include "hblistview.h"
|
|
25 |
|
|
26 |
FmDriveQuery::FmDriveQuery( QGraphicsItem *parent ) : FmDialog( parent )
|
|
27 |
{
|
33
|
28 |
setObjectName( "driveQueryDialog" );
|
25
|
29 |
mContentWidget = new QGraphicsWidget();
|
33
|
30 |
mContentWidget->setObjectName( "driveQueryContentWidget" );
|
25
|
31 |
setContentWidget(mContentWidget);
|
|
32 |
|
|
33 |
QGraphicsLinearLayout *vLayout = new QGraphicsLinearLayout();
|
|
34 |
vLayout->setOrientation( Qt::Vertical );
|
|
35 |
|
|
36 |
mListView = new HbListView();
|
33
|
37 |
mListView->setObjectName( "driveQueryListView" );
|
25
|
38 |
vLayout->addItem( mListView );
|
|
39 |
|
|
40 |
mListView->setFontSpec( HbFontSpec( HbFontSpec::Primary ) );
|
|
41 |
|
|
42 |
this->setTimeout( NoTimeout );
|
|
43 |
mContentWidget->setLayout( vLayout );
|
|
44 |
|
|
45 |
connect( mListView, SIGNAL( activated ( const QModelIndex& ) ), this, SLOT( activated( const QModelIndex& ) ) );
|
|
46 |
this->setDismissPolicy( NoDismiss );
|
|
47 |
|
|
48 |
|
|
49 |
mDriveModel = new FmDriveModel( this,
|
|
50 |
FmDriveModel::FillWithVolume | FmDriveModel::FillWithDefaultVolume, this );
|
|
51 |
mListView->setModel( mDriveModel );
|
|
52 |
|
|
53 |
// connect refreshModel signal of viewmanager for drive insert/remove event.
|
|
54 |
connect( FmViewManager::viewManager(), SIGNAL( refreshModel( QString ) ),
|
|
55 |
this, SLOT( refreshModel( QString ) ) );
|
|
56 |
}
|
|
57 |
|
|
58 |
FmDriveQuery::~FmDriveQuery(void)
|
|
59 |
{
|
|
60 |
delete mDriveModel;
|
|
61 |
mDriveModel = 0;
|
|
62 |
}
|
|
63 |
|
|
64 |
void FmDriveQuery::getDriveList( QStringList &driveList )
|
|
65 |
{
|
|
66 |
// provide drive list which is got from backup engine wrapper.
|
|
67 |
FmViewManager::viewManager()->operationService()->backupRestoreHandler()->getBackupDriveList( driveList );
|
|
68 |
}
|
|
69 |
|
|
70 |
void FmDriveQuery::activated( const QModelIndex &index )
|
|
71 |
{
|
|
72 |
QString driveName( mDriveModel->driveName( index ) );
|
|
73 |
|
|
74 |
// if drive is not available, ignore activate signal.
|
|
75 |
FmDriverInfo driveInfo = FmUtils::queryDriverInfo( driveName );
|
|
76 |
if( !( driveInfo.driveState() & FmDriverInfo::EDriveAvailable ) ) {
|
|
77 |
return;
|
|
78 |
}
|
|
79 |
|
|
80 |
mSelectedDrive = driveName;
|
|
81 |
close();
|
|
82 |
}
|
|
83 |
|
|
84 |
QString FmDriveQuery::selectedDrive() const
|
|
85 |
{
|
|
86 |
return mSelectedDrive;
|
|
87 |
}
|
|
88 |
|
|
89 |
void FmDriveQuery::refreshModel( QString path )
|
|
90 |
{
|
|
91 |
if( !path.isEmpty() ) {
|
|
92 |
// ignore non-empty refresh signal as it means change of folder/file, not drive.
|
|
93 |
return;
|
|
94 |
}
|
|
95 |
mDriveModel->refresh();
|
|
96 |
}
|