14 * |
14 * |
15 * Description: |
15 * Description: |
16 * The source file of the restore view list item of file manager |
16 * The source file of the restore view list item of file manager |
17 */ |
17 */ |
18 #include "fmrestoreviewitem.h" |
18 #include "fmrestoreviewitem.h" |
19 |
19 #include "fmfileiconprovider.h" |
20 #include <QGraphicsLinearLayout> |
20 #include <QGraphicsLinearLayout> |
21 |
21 #include <QGraphicsGridLayout> |
22 #include <hblabel.h> |
22 #include <hblabel.h> |
23 #include <hbcheckbox.h> |
23 #include <hbcheckbox.h> |
24 #include <hbwidget.h> |
24 #include <hbwidget.h> |
25 #include <hblineedit.h> |
25 #include <hblineedit.h> |
26 |
26 |
27 //FmRestoreViewItem |
27 //FmRestoreViewItem |
28 FmRestoreViewItem::FmRestoreViewItem( QGraphicsItem *parent ) |
28 FmRestoreViewItem::FmRestoreViewItem( QGraphicsItem *parent ) |
29 : HbListViewItem( parent ), |
29 : HbListViewItem( parent ), |
30 mRestoreContentLabel( 0 ), |
30 mRestoreContentLabel( 0 ), |
31 mDateTimeLabel( 0 ), |
31 mDateTimeLabel( 0 ), |
32 mCheckBox( 0 ) |
32 mCheckBox( 0 ), |
33 |
33 hLayout( 0 ), |
|
34 mParentWidget((HbWidget *)parent) |
34 { |
35 { |
35 init(); |
36 //init(); |
36 } |
37 } |
37 |
38 |
38 FmRestoreViewItem::~FmRestoreViewItem() |
39 FmRestoreViewItem::~FmRestoreViewItem() |
39 { |
40 { |
40 } |
41 } |
41 |
42 |
42 |
43 |
43 HbAbstractViewItem *FmRestoreViewItem::createItem() |
44 HbAbstractViewItem *FmRestoreViewItem::createItem() |
44 { |
45 { |
45 return new FmRestoreViewItem( parentItem() ); |
46 return new FmRestoreViewItem( *this ); |
46 } |
47 } |
47 |
48 |
48 void FmRestoreViewItem::polish(HbStyleParameters& params) |
49 void FmRestoreViewItem::polish(HbStyleParameters& params) |
49 { |
50 { |
50 Q_UNUSED(params); |
51 Q_UNUSED(params); |
51 } |
52 } |
52 |
53 |
53 void FmRestoreViewItem::updateChildItems() |
54 void FmRestoreViewItem::updateChildItems() |
54 { |
55 { |
|
56 if( !hLayout ) { |
|
57 init(); |
|
58 } |
55 QString string = modelIndex().data( Qt::DisplayRole ).toString(); |
59 QString string = modelIndex().data( Qt::DisplayRole ).toString(); |
56 |
60 |
57 QStringList stringList = string.split( '\t' ); |
61 QStringList stringList = string.split( '\t' ); |
58 |
62 |
59 if( stringList.count() == 0 ){ |
63 if( stringList.count() == 0 ){ |
60 return; |
64 return; |
61 } |
65 } |
62 |
66 |
63 mRestoreContentLabel->setPlainText( stringList.first() ); |
67 mRestoreContentLabel->setPlainText(stringList.first()); |
64 |
68 |
65 if( stringList.first() != stringList.last() ){ |
69 if (stringList.size() > 0) |
66 mDateTimeLabel->setPlainText( stringList.last() ); |
70 { |
67 } |
71 mDateTimeLabel->setPlainText(stringList.at(1)); |
|
72 } |
|
73 if (stringList.size() > 1) |
|
74 { |
|
75 QIcon icon = mIconProvider->icon(QFileInfo(stringList.at(2))); |
|
76 // FmFileIconProvider already handle null icon issue |
|
77 mIconLabel->setIcon(HbIcon(icon)); |
|
78 } |
|
79 |
|
80 connect(this, SIGNAL(stateChanged(int)), mParentWidget, |
|
81 SIGNAL(stateChanged(int))); |
68 |
82 |
69 } |
83 } |
70 |
84 |
71 |
|
72 void FmRestoreViewItem::init() |
85 void FmRestoreViewItem::init() |
73 { |
86 { |
74 QGraphicsLinearLayout *hLayout = new QGraphicsLinearLayout(); |
87 mIconProvider = new FmFileIconProvider(); |
75 hLayout->setOrientation( Qt::Horizontal ); |
88 hLayout = new QGraphicsLinearLayout(); |
|
89 hLayout->setOrientation(Qt::Horizontal); |
|
90 hLayout->addItem(layout()); |
76 |
91 |
77 mCheckBox = new HbCheckBox( this ); |
92 mCheckBox = new HbCheckBox(this); |
78 hLayout->addItem( mCheckBox ); |
93 hLayout->addItem(mCheckBox); |
79 hLayout->setAlignment( mCheckBox, Qt::AlignVCenter ); |
94 hLayout->setAlignment(mCheckBox, Qt::AlignVCenter); |
80 |
95 |
81 QGraphicsLinearLayout *vLayout = new QGraphicsLinearLayout(); |
96 QGraphicsGridLayout *vLayout = new QGraphicsGridLayout(); |
82 vLayout->setOrientation( Qt::Vertical ); |
|
83 |
97 |
84 mRestoreContentLabel = new HbLabel(""); |
98 mRestoreContentLabel = new HbLabel(""); |
85 mRestoreContentLabel->setFontSpec( HbFontSpec( HbFontSpec::Primary ) ); |
99 mRestoreContentLabel->setFontSpec(HbFontSpec(HbFontSpec::Primary)); |
86 vLayout->addItem( mRestoreContentLabel ); |
100 |
87 vLayout->setAlignment( mRestoreContentLabel, Qt::AlignLeft ); |
101 mIconLabel = new HbLabel(); |
88 |
102 |
89 mDateTimeLabel = new HbLabel(""); |
103 mDateTimeLabel = new HbLabel(""); |
90 mDateTimeLabel->setFontSpec( HbFontSpec( HbFontSpec::Secondary ) ); |
104 mDateTimeLabel->setFontSpec(HbFontSpec(HbFontSpec::Secondary)); |
91 vLayout->addItem( mDateTimeLabel ); |
|
92 vLayout->setAlignment( mDateTimeLabel, Qt::AlignLeft ); |
|
93 |
105 |
94 HbWidget *textWidget = new HbWidget(); |
106 vLayout->addItem(mRestoreContentLabel, 0, 0); |
95 textWidget->setLayout(vLayout); |
107 vLayout->addItem(mIconLabel, 0, 1); |
|
108 vLayout->addItem(mDateTimeLabel, 1, 0); |
96 |
109 |
97 hLayout->addItem( textWidget ); |
110 HbWidget *textWidget = new HbWidget(); |
98 hLayout->setAlignment( textWidget, Qt::AlignVCenter ); |
111 textWidget->setLayout(vLayout); |
99 |
112 |
100 setLayout( hLayout ); |
113 hLayout->addItem(textWidget); |
101 |
114 hLayout->setAlignment(textWidget, Qt::AlignVCenter); |
|
115 |
|
116 connect(mCheckBox, SIGNAL(stateChanged(int)), this, |
|
117 SIGNAL(stateChanged(int))); |
|
118 setLayout(hLayout); |
102 } |
119 } |
103 |
120 |
104 void FmRestoreViewItem::setCheckBoxState() |
121 void FmRestoreViewItem::setCheckBoxState() |
105 { |
122 { |
106 if ( mCheckBox->checkState() == Qt::Unchecked ){ |
123 if ( mCheckBox->checkState() == Qt::Unchecked ){ |
107 mCheckBox->setCheckState( Qt::Checked ); |
124 mCheckBox->setCheckState( Qt::Checked ); |
108 setSelected( true ); |
125 setSelected( true ); |
109 } |
126 } |
110 else if( mCheckBox->checkState() == Qt::Checked ){ |
127 else if( mCheckBox->checkState() == Qt::Checked ){ |
111 mCheckBox->setCheckState( Qt::Unchecked ); |
128 mCheckBox->setCheckState( Qt::Unchecked ); |
112 setSelected( false ); |
129 setSelected( false ); |
113 } |
130 } |
114 } |
131 } |
115 |
132 |
116 bool FmRestoreViewItem::getCheckBoxState() |
133 bool FmRestoreViewItem::getCheckBoxState() |
117 { |
134 { |
118 if( mCheckBox->checkState() == Qt::Unchecked ) { |
135 if( mCheckBox->checkState() == Qt::Unchecked ) { |
119 return false; |
136 return false; |
120 } else { |
137 } else { |
121 return true; |
138 return true; |
122 } |
139 } |
123 } |
140 } |
|
141 |