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 header file of the delete backup widget of file manager |
|
17 */ |
|
18 #include "fmdeletebackupwidget.h" |
|
19 #include "fmrestoresettings.h" |
|
20 #include "fmrestoreviewitem.h" |
|
21 #include "fmoperationservice.h" |
|
22 #include "fmviewmanager.h" |
|
23 #include "fmbackupconfigloader.h" |
|
24 #include "fmbkupengine.h" |
|
25 #include "fmbackuprestorehandler.h" |
|
26 |
|
27 #include <QGraphicsLinearLayout> |
|
28 #include <QStringListModel> |
|
29 #include <QDateTime> |
|
30 #include <hblistview.h> |
|
31 |
|
32 FmDeleteBackupWidget::FmDeleteBackupWidget( HbWidget *parent ) |
|
33 : HbWidget( parent ), mModel( 0 ) |
|
34 { |
|
35 init(); |
|
36 } |
|
37 |
|
38 FmDeleteBackupWidget::~FmDeleteBackupWidget() |
|
39 { |
|
40 mListView->setModel( 0 ); |
|
41 delete mModel; |
|
42 } |
|
43 |
|
44 void FmDeleteBackupWidget::refresh() |
|
45 { |
|
46 mListView->setModel( 0 ); |
|
47 loadData(); |
|
48 mListView->setModel( mModel ); |
|
49 for (int i = 0; i < mModel->rowCount(); ++i) { |
|
50 QModelIndex index = mModel->index(i); |
|
51 FmRestoreViewItem* restoreViewItem = static_cast< FmRestoreViewItem* > |
|
52 (mListView->itemByIndex(index)); |
|
53 connect(restoreViewItem, SIGNAL(stateChanged(int)), this, SIGNAL(stateChanged(int))); |
|
54 } |
|
55 emit stateChanged(0); |
|
56 } |
|
57 |
|
58 QList<int> FmDeleteBackupWidget::selectionIndexes() |
|
59 { |
|
60 QList<int> selectionList; |
|
61 |
|
62 for ( int i=0; i<mModel->rowCount(); i++ ) { |
|
63 FmRestoreViewItem *item = static_cast<FmRestoreViewItem*>( |
|
64 mListView->itemByIndex( mModel->index( i ) ) ); |
|
65 if( item && item->getCheckBoxState() ) { |
|
66 selectionList.push_back( i ); |
|
67 } |
|
68 } |
|
69 |
|
70 return selectionList; |
|
71 } |
|
72 |
|
73 void FmDeleteBackupWidget::loadData() |
|
74 { |
|
75 if( !mModel ) { |
|
76 mModel = new QStringListModel(); |
|
77 } |
|
78 mModel->removeRows( 0, mModel->rowCount() ); |
|
79 |
|
80 mRestoreSettings = FmViewManager::viewManager()->operationService()->backupRestoreHandler()->bkupEngine()->RestoreSettingsL(); |
|
81 mBackupConfigLoader = FmViewManager::viewManager()->operationService()->backupRestoreHandler()->backupConfigLoader(); |
|
82 mRestoreSettings->load( mBackupConfigLoader->driversAndOperationList() ); |
|
83 |
|
84 int index = 0; |
|
85 |
|
86 QList< FmRestoreEntry* > retoreEntryList = mRestoreSettings->restoreEntryList(); |
|
87 mModel->insertRows( 0, retoreEntryList.count() ); |
|
88 |
|
89 for ( QList< FmRestoreEntry* >::iterator it = retoreEntryList.begin(); |
|
90 it != retoreEntryList.end(); ++it ){ |
|
91 QString string = ( *it )->text(); |
|
92 QDateTime datetime = ( *it )->restoreInfo().dateTime(); |
|
93 QString drive = ( *it )->restoreInfo().drive(); |
|
94 string.append( '\t' ); |
|
95 string.append( datetime.toString( "hh:mm ap dd/MM/yyyy") ); |
|
96 string.append( '\t' ); |
|
97 string.append( drive ); |
|
98 QVariant variant( string ); |
|
99 mModel->setData( mModel->index( index ), variant, Qt::DisplayRole ); |
|
100 ++index; |
|
101 } |
|
102 |
|
103 } |
|
104 |
|
105 void FmDeleteBackupWidget::init() |
|
106 { |
|
107 QGraphicsLinearLayout *vLayout = new QGraphicsLinearLayout( this ); |
|
108 vLayout->setOrientation( Qt::Vertical ); |
|
109 |
|
110 mListView = new HbListView( this ); |
|
111 connect( mListView, SIGNAL( activated( const QModelIndex & ) ), |
|
112 this, SLOT( on_list_activated( const QModelIndex & ) ) ); |
|
113 |
|
114 mListView->setSelectionMode( HbAbstractItemView::MultiSelection ); |
|
115 |
|
116 vLayout->addItem( mListView ); |
|
117 |
|
118 loadData(); |
|
119 mListView->setModel( mModel ); |
|
120 |
|
121 mListView->setItemPrototype( new FmRestoreViewItem( this ) ); |
|
122 |
|
123 |
|
124 } |
|
125 |
|
126 void FmDeleteBackupWidget::on_list_activated( const QModelIndex &index ) |
|
127 { |
|
128 FmRestoreViewItem *restoreViewItem = static_cast< FmRestoreViewItem* > |
|
129 ( mListView->itemByIndex( index ) ); |
|
130 |
|
131 restoreViewItem->setCheckBoxState(); |
|
132 } |
|
133 |
|
134 int FmDeleteBackupWidget::backupDataCount() |
|
135 { |
|
136 return mModel->rowCount(); |
|
137 } |
|