33 #include <hbdataformmodel.h> |
33 #include <hbdataformmodel.h> |
34 #include <hbdataformmodelitem.h> |
34 #include <hbdataformmodelitem.h> |
35 #include <hbdataformviewitem.h> |
35 #include <hbdataformviewitem.h> |
36 |
36 |
37 |
37 |
38 |
|
39 FmBackupWidget::FmBackupWidget( QGraphicsItem *parent ) |
38 FmBackupWidget::FmBackupWidget( QGraphicsItem *parent ) |
40 : HbWidget( parent ), mLastPressedItem( 0 ), mScrolled( 0 ) |
39 : HbWidget( parent ) |
41 { |
40 { |
42 init(); |
41 init(); |
43 } |
42 } |
44 |
43 |
45 FmBackupWidget::~FmBackupWidget() |
44 FmBackupWidget::~FmBackupWidget() |
46 { |
45 { |
47 mDataForm->setModel( 0 ); |
46 mDataForm->setModel( 0 ); |
48 delete mModel; |
47 delete mModel; |
49 } |
48 } |
50 |
49 |
51 void FmBackupWidget::on_list_released( const QModelIndex &index ) |
50 |
52 { |
51 void FmBackupWidget::on_list_activated( const QModelIndex &index ) |
53 HbDataFormModelItem *item = mModel->itemFromIndex(index); |
52 { |
54 if( item != mLastPressedItem || mDataForm->isScrolling() || mScrolled ) { |
53 // change item data when receive activated signal |
55 mScrolled = false; |
54 HbDataFormModelItem *item = mModel->itemFromIndex(index); |
56 return; |
55 if( item == mContentsItem ){ |
57 } |
56 emit changeContents(); |
58 mScrolled = false; |
|
59 |
|
60 if( item == mContentsItem ){ |
|
61 ChangeContents(); |
|
62 } else if( item == mTargetItem ){ |
57 } else if( item == mTargetItem ){ |
63 ChangeTargetDrive(); |
58 emit changeTargetDrive(); |
64 } else if( item == mSchedulingItem ){ |
59 } else if( item == mSchedulingItem ){ |
65 ChangeScheduling(); |
60 emit changeScheduling(); |
66 } else if( item == mWeekdayItem ){ |
61 } else if( item == mWeekdayItem ){ |
67 ChangeWeekday(); |
62 emit changeWeekday(); |
68 } else if( item == mTimeItem ){ |
63 } else if( item == mTimeItem ){ |
69 ChangeTime(); |
64 emit changeTime(); |
70 } |
65 } |
71 } |
|
72 |
|
73 void FmBackupWidget::on_list_pressed( const QModelIndex &index ) |
|
74 { |
|
75 mLastPressedItem = mModel->itemFromIndex(index); |
|
76 } |
|
77 |
|
78 void FmBackupWidget::on_list_scrollingStarted() |
|
79 { |
|
80 mScrolled = true; |
|
81 } |
66 } |
82 |
67 |
83 void FmBackupWidget::init() |
68 void FmBackupWidget::init() |
84 { |
69 { |
85 QGraphicsLinearLayout *vLayout = new QGraphicsLinearLayout( this ); |
70 QGraphicsLinearLayout *vLayout = new QGraphicsLinearLayout( this ); |
90 initModel(); |
75 initModel(); |
91 |
76 |
92 mDataForm = new HbDataForm( this ); |
77 mDataForm = new HbDataForm( this ); |
93 mDataForm->setModel( mModel ); |
78 mDataForm->setModel( mModel ); |
94 vLayout->addItem( mDataForm ); |
79 vLayout->addItem( mDataForm ); |
95 |
80 |
96 connect( mDataForm, SIGNAL( released( const QModelIndex & ) ), |
81 connect( mDataForm, SIGNAL( activated( const QModelIndex & ) ), |
97 this, SLOT( on_list_released( const QModelIndex & ) ) ); |
82 this, SLOT( on_list_activated( const QModelIndex & ) ) ); |
98 |
|
99 connect( mDataForm, SIGNAL( pressed( const QModelIndex & ) ), |
|
100 this, SLOT( on_list_pressed( const QModelIndex & ) ) ); |
|
101 |
|
102 connect( mDataForm, SIGNAL( scrollingStarted() ), |
|
103 this, SLOT( on_list_scrollingStarted() ) ); |
|
104 |
83 |
105 connect( this, SIGNAL( doModelRefresh() ), |
84 connect( this, SIGNAL( doModelRefresh() ), |
106 this, SLOT( refreshModel() ), Qt::QueuedConnection ); |
85 this, SLOT( refreshModel() ), Qt::QueuedConnection ); |
107 |
86 |
|
87 connect( this, SIGNAL(changeContents()), this, SLOT(on_changeContents()), Qt::QueuedConnection); |
|
88 connect( this, SIGNAL(changeScheduling()), this, SLOT(on_changeScheduling()), Qt::QueuedConnection); |
|
89 connect( this, SIGNAL(changeWeekday()), this, SLOT(on_changeWeekday()), Qt::QueuedConnection); |
|
90 connect( this, SIGNAL(changeTime()), this, SLOT(on_changeTime()), Qt::QueuedConnection); |
|
91 connect( this, SIGNAL(changeTargetDrive()), this, SLOT(on_changeTargetDrive()), Qt::QueuedConnection); |
|
92 |
108 //mBackupSettings = new FmBackupSettings(); |
93 //mBackupSettings = new FmBackupSettings(); |
109 mBackupSettings = FmViewManager::viewManager()->operationService()->backupRestoreHandler()->bkupEngine()->BackupSettingsL(); |
94 mBackupSettings = FmViewManager::viewManager()->operationService()->backupRestoreHandler()->bkupEngine()->BackupSettingsL(); |
110 mBackupSettings->load(); |
95 mBackupSettings->load(); |
111 |
96 |
112 emit doModelRefresh(); |
97 emit doModelRefresh(); |
113 |
98 |
114 } |
99 } |
115 |
100 |
116 void FmBackupWidget::expandAllGroup() |
101 void FmBackupWidget::expandAllGroup() |
117 { |
102 { |
118 FmLogger::log( QString( "function expandAllGroup start" ) ); |
103 FM_LOG( QString( "function expandAllGroup start" ) ); |
119 |
104 |
120 mDataForm->setModel( 0 ); |
105 mDataForm->setModel( 0 ); |
121 mDataForm->setModel( mModel ); |
106 mDataForm->setModel( mModel ); |
122 |
107 |
123 HbDataFormViewItem *itemScheduling = |
108 HbDataFormViewItem *itemScheduling = |
124 (HbDataFormViewItem *)(mDataForm->itemByIndex(mModel->indexFromItem(mSchedulingGroup))); |
109 (HbDataFormViewItem *)(mDataForm->itemByIndex(mModel->indexFromItem(mSchedulingGroup))); |
125 if( itemScheduling ){ |
110 if( itemScheduling ){ |
126 FmLogger::log( QString( "expand itemScheduling start" ) ); |
111 FM_LOG( QString( "expand itemScheduling start" ) ); |
127 itemScheduling->setExpanded( true ); |
112 itemScheduling->setExpanded( true ); |
128 FmLogger::log( QString( "expand itemScheduling end" ) ); |
113 FM_LOG( QString( "expand itemScheduling end" ) ); |
129 } |
114 } |
130 |
115 |
131 HbDataFormViewItem *itemGroup = |
116 HbDataFormViewItem *itemGroup = |
132 (HbDataFormViewItem *)(mDataForm->itemByIndex(mModel->indexFromItem(mContentsGroup))); |
117 (HbDataFormViewItem *)(mDataForm->itemByIndex(mModel->indexFromItem(mContentsGroup))); |
133 if( itemGroup ){ |
118 if( itemGroup ){ |
134 FmLogger::log( QString( "expand itemGroup start" ) ); |
119 FM_LOG( QString( "expand itemGroup start" ) ); |
135 itemGroup->setExpanded( true ); |
120 itemGroup->setExpanded( true ); |
136 FmLogger::log( QString( "expand itemGroup end" ) ); |
121 FM_LOG( QString( "expand itemGroup end" ) ); |
137 } |
122 } |
138 FmLogger::log( QString( "function expandAllGroup end" ) ); |
123 FM_LOG( QString( "function expandAllGroup end" ) ); |
139 } |
124 } |
140 |
125 |
141 void FmBackupWidget::initModel() |
126 void FmBackupWidget::initModel() |
142 { |
127 { |
143 mContentsGroup = mModel->appendDataFormGroup( |
128 mContentsGroup = mModel->appendDataFormGroup( |
144 QString( tr( "Contents" ) ), mModel->invisibleRootItem()); |
129 QString( hbTrId( "Contents" ) ), mModel->invisibleRootItem()); |
145 |
130 |
146 mContentsItem = mModel->appendDataFormItem( |
131 mContentsItem = mModel->appendDataFormItem( |
147 HbDataFormModelItem::TextItem, QString( "" ), mContentsGroup ); |
132 HbDataFormModelItem::TextItem, QString( "" ), mContentsGroup ); |
148 mContentsItem->setContentWidgetData( QString("readOnly"), QString("true") ); |
133 mContentsItem->setContentWidgetData( QString("readOnly"), QString("true") ); |
|
134 mContentsItem->setContentWidgetData( QString("objectName"), QString("backupContentItem") ); |
149 |
135 |
150 mTargetItem = mModel->appendDataFormItem( |
136 mTargetItem = mModel->appendDataFormItem( |
151 HbDataFormModelItem::TextItem, QString( "" ), mContentsGroup ); |
137 HbDataFormModelItem::TextItem, QString( "" ), mContentsGroup ); |
152 mTargetItem->setContentWidgetData( QString("readOnly"), QString("true") ); |
138 mTargetItem->setContentWidgetData( QString("readOnly"), QString("true") ); |
|
139 mTargetItem->setContentWidgetData( QString("objectName"), QString("backupTargetItem") ); |
153 |
140 |
154 mSchedulingGroup = mModel->appendDataFormGroup( |
141 mSchedulingGroup = mModel->appendDataFormGroup( |
155 QString( tr( "Scheduling" ) ), mModel->invisibleRootItem()); |
142 QString( hbTrId( "Scheduling" ) ), mModel->invisibleRootItem()); |
156 |
143 |
157 mSchedulingItem = mModel->appendDataFormItem( |
144 mSchedulingItem = mModel->appendDataFormItem( |
158 HbDataFormModelItem::TextItem, QString( "" ), mSchedulingGroup ); |
145 HbDataFormModelItem::TextItem, QString( "" ), mSchedulingGroup ); |
159 mSchedulingItem->setContentWidgetData( QString("readOnly"), QString("true") ); |
146 mSchedulingItem->setContentWidgetData( QString("readOnly"), QString("true") ); |
|
147 mSchedulingItem->setContentWidgetData( QString("objectName"), QString("backupSchedulingItem") ); |
160 |
148 |
161 mWeekdayItem = mModel->appendDataFormItem( |
149 mWeekdayItem = mModel->appendDataFormItem( |
162 HbDataFormModelItem::TextItem, QString( "" ), mSchedulingGroup ); |
150 HbDataFormModelItem::TextItem, QString( "" ), mSchedulingGroup ); |
163 mWeekdayItem->setContentWidgetData( QString("readOnly"), QString("true") ); |
151 mWeekdayItem->setContentWidgetData( QString("readOnly"), QString("true") ); |
|
152 mWeekdayItem->setContentWidgetData( QString("objectName"), QString("backupWeekdayItem") ); |
164 |
153 |
165 mTimeItem = mModel->appendDataFormItem( |
154 mTimeItem = mModel->appendDataFormItem( |
166 HbDataFormModelItem::TextItem, QString( "" ), mSchedulingGroup ); |
155 HbDataFormModelItem::TextItem, QString( "" ), mSchedulingGroup ); |
167 mTimeItem->setContentWidgetData( QString("readOnly"), QString("true") ); |
156 mTimeItem->setContentWidgetData( QString("readOnly"), QString("true") ); |
168 } |
157 mTimeItem->setContentWidgetData( QString("objectName"), QString("backupTimeItem") ); |
|
158 |
|
159 mLastBackupDateItem = mModel->appendDataFormItem( |
|
160 HbDataFormModelItem::TextItem, QString( ( "" )), mModel->invisibleRootItem() ); |
|
161 mLastBackupDateItem->setContentWidgetData( QString("readOnly"), QString("true") ); |
|
162 mLastBackupDateItem->setContentWidgetData( QString("objectName"), QString("backupLastBackupDateItem") ); |
|
163 } |
|
164 |
169 |
165 |
170 |
166 |
171 void FmBackupWidget::refreshModel() |
167 void FmBackupWidget::refreshModel() |
172 { |
168 { |
173 mDataForm->setModel( 0 ); |
169 mDataForm->setModel( 0 ); |
319 mBackupSettings->setWeekday( (FmBackupSettings::TFileManagerBackupWeekday)selectIndex ); |
318 mBackupSettings->setWeekday( (FmBackupSettings::TFileManagerBackupWeekday)selectIndex ); |
320 emit doModelRefresh(); |
319 emit doModelRefresh(); |
321 } |
320 } |
322 } |
321 } |
323 |
322 |
324 void FmBackupWidget::ChangeTime() |
323 void FmBackupWidget::on_changeTime() |
325 { |
324 { |
326 QString title = constFileManagerBackupSettingsTitleTime; |
325 QString title = mTimeItem->label(); |
327 QTime queryTime = mBackupSettings->time(); |
326 QTime queryTime = mBackupSettings->time(); |
328 |
327 |
329 if( FmDlgUtils::showTimeSettingQuery( title, queryTime ) ) |
328 if( FmDlgUtils::showTimeSettingQuery( title, queryTime ) ) |
330 { |
329 { |
331 mBackupSettings->setTime( queryTime ); |
330 mBackupSettings->setTime( queryTime ); |
332 emit doModelRefresh(); |
331 emit doModelRefresh(); |
333 } |
332 } |
334 } |
333 } |
335 |
334 |
336 |
335 |
337 void FmBackupWidget::ChangeTargetDrive() |
336 void FmBackupWidget::on_changeTargetDrive() |
338 { |
337 { |
339 QString title = constFileManagerBackupSettingsTitleTargetDrive; |
338 QString title = mTargetItem->label(); |
340 QStringList queryStringList; |
339 QString drive = FmDlgUtils::showBackupDriveQuery( title ); |
341 QStringList driveStringList; |
340 if( ( !drive.isEmpty() ) && |
342 |
341 ( mBackupSettings->targetDrive().compare( drive, Qt::CaseInsensitive ) != 0 ) ) { |
343 QStringList driveList; |
342 mBackupSettings->setTargetDrive( drive ); |
344 //FmUtils::getDriveList( driveList, true ); |
343 emit doModelRefresh(); |
345 FmViewManager::viewManager()->operationService()->backupRestoreHandler()->getBackupDriveList( driveList ); |
344 } |
346 QString targetDrive = mBackupSettings->targetDrive(); |
345 } |
347 int selectIndex = -1; |
346 |
348 |
347 void FmBackupWidget::updateBackupDate() |
349 int currentIndex = 0; |
348 { |
350 QString associatedDrives; |
349 mBackupSettings->updateBackupDate(); |
351 for( QStringList::const_iterator it = driveList.begin(); it != driveList.end(); ++it ) |
350 emit doModelRefresh(); |
352 { |
351 } |
353 QString drive = (*it); |
|
354 drive = FmUtils::removePathSplash( drive ); |
|
355 QString driveWithVolume = FmUtils::fillDriveVolume( drive, true ); |
|
356 |
|
357 driveStringList.push_back( drive ); |
|
358 queryStringList.push_back( driveWithVolume ); |
|
359 associatedDrives += FmUtils::getDriveLetterFromPath(drive); |
|
360 |
|
361 if( drive == targetDrive ) |
|
362 { |
|
363 // adjust index offset against drive. |
|
364 selectIndex = currentIndex; |
|
365 } |
|
366 ++currentIndex; |
|
367 } |
|
368 |
|
369 if( FmDlgUtils::showSingleSettingQuery( title, queryStringList, selectIndex, associatedDrives ) ) |
|
370 { |
|
371 mBackupSettings->setTargetDrive( driveStringList.at( selectIndex ) ); |
|
372 emit doModelRefresh(); |
|
373 } |
|
374 } |
|