34 #include <hbdataformmodelitem.h> |
34 #include <hbdataformmodelitem.h> |
35 #include <hbdataformviewitem.h> |
35 #include <hbdataformviewitem.h> |
36 |
36 |
37 |
37 |
38 FmBackupWidget::FmBackupWidget( QGraphicsItem *parent ) |
38 FmBackupWidget::FmBackupWidget( QGraphicsItem *parent ) |
39 : HbWidget( parent ), mLastPressedItem( 0 ), mScrolled( 0 ), mListReleased( false ) |
39 : HbWidget( parent ) |
40 { |
40 { |
41 init(); |
41 init(); |
42 } |
42 } |
43 |
43 |
44 FmBackupWidget::~FmBackupWidget() |
44 FmBackupWidget::~FmBackupWidget() |
45 { |
45 { |
46 mDataForm->setModel( 0 ); |
46 mDataForm->setModel( 0 ); |
47 delete mModel; |
47 delete mModel; |
48 } |
48 } |
49 |
49 |
50 void FmBackupWidget::on_list_released( const QModelIndex &index ) |
50 |
51 { |
51 void FmBackupWidget::on_list_activated( const QModelIndex &index ) |
52 HbDataFormModelItem *item = mModel->itemFromIndex(index); |
52 { |
53 if( item != mLastPressedItem || mDataForm->isScrolling() || mScrolled ) { |
53 // change item data when receive activated signal |
54 mScrolled = false; |
54 HbDataFormModelItem *item = mModel->itemFromIndex(index); |
55 return; |
55 if( item == mContentsItem ){ |
56 } |
|
57 mScrolled = false; |
|
58 |
|
59 if( item == mContentsItem ){ |
|
60 emit changeContents(); |
56 emit changeContents(); |
61 } else if( item == mTargetItem ){ |
57 } else if( item == mTargetItem ){ |
62 emit changeTargetDrive(); |
58 emit changeTargetDrive(); |
63 } else if( item == mSchedulingItem ){ |
59 } else if( item == mSchedulingItem ){ |
64 emit changeScheduling(); |
60 emit changeScheduling(); |
67 } else if( item == mTimeItem ){ |
63 } else if( item == mTimeItem ){ |
68 emit changeTime(); |
64 emit changeTime(); |
69 } |
65 } |
70 } |
66 } |
71 |
67 |
72 void FmBackupWidget::on_list_pressed( const QModelIndex &index ) |
|
73 { |
|
74 mLastPressedItem = mModel->itemFromIndex(index); |
|
75 } |
|
76 |
|
77 void FmBackupWidget::on_list_scrollingStarted() |
|
78 { |
|
79 mScrolled = true; |
|
80 } |
|
81 |
|
82 void FmBackupWidget::init() |
68 void FmBackupWidget::init() |
83 { |
69 { |
84 QGraphicsLinearLayout *vLayout = new QGraphicsLinearLayout( this ); |
70 QGraphicsLinearLayout *vLayout = new QGraphicsLinearLayout( this ); |
85 vLayout->setOrientation( Qt::Vertical ); |
71 vLayout->setOrientation( Qt::Vertical ); |
86 |
72 |
89 initModel(); |
75 initModel(); |
90 |
76 |
91 mDataForm = new HbDataForm( this ); |
77 mDataForm = new HbDataForm( this ); |
92 mDataForm->setModel( mModel ); |
78 mDataForm->setModel( mModel ); |
93 vLayout->addItem( mDataForm ); |
79 vLayout->addItem( mDataForm ); |
94 |
80 |
95 |
81 connect( mDataForm, SIGNAL( activated( const QModelIndex & ) ), |
96 connect( mDataForm, SIGNAL( released( const QModelIndex & ) ), |
82 this, SLOT( on_list_activated( const QModelIndex & ) ) ); |
97 this, SLOT( on_list_released( 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 |
108 connect( this, SIGNAL(changeContents()), this, SLOT(on_changeContents()), Qt::QueuedConnection); |
87 connect( this, SIGNAL(changeContents()), this, SLOT(on_changeContents()), Qt::QueuedConnection); |