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 the back up view list item of file manager |
|
17 */ |
|
18 |
|
19 #include "fmbackupviewitem.h" |
|
20 |
|
21 #include <QGraphicsLinearLayout> |
|
22 |
|
23 #include <hblabel.h> |
|
24 #include <hbcheckbox.h> |
|
25 #include <hbwidget.h> |
|
26 #include <hblineedit.h> |
|
27 |
|
28 |
|
29 FmBackupViewItem::FmBackupViewItem( QGraphicsItem *parent ) |
|
30 : mTitleLabel( 0 ), |
|
31 //mTipsLabel( 0 ), |
|
32 mTipsLineEdit( 0 ), |
|
33 HbListViewItem( parent ) |
|
34 { |
|
35 init(); |
|
36 } |
|
37 |
|
38 FmBackupViewItem::~FmBackupViewItem() |
|
39 { |
|
40 } |
|
41 |
|
42 void FmBackupViewItem::polish(HbStyleParameters& params) |
|
43 { |
|
44 Q_UNUSED(params); |
|
45 } |
|
46 |
|
47 HbAbstractViewItem *FmBackupViewItem::createItem() |
|
48 { |
|
49 return new FmBackupViewItem( parentItem() ); |
|
50 } |
|
51 |
|
52 void FmBackupViewItem::updateChildItems() |
|
53 { |
|
54 QString string = modelIndex().data( Qt::DisplayRole ).toString(); |
|
55 |
|
56 QStringList stringList = string.split( '\t' ); |
|
57 |
|
58 if( stringList.count() == 0 ){ |
|
59 return; |
|
60 } |
|
61 |
|
62 mTitleLabel->setText( stringList.first() ); |
|
63 |
|
64 if( stringList.first() != stringList.last() ){ |
|
65 //mTipsLabel->setText( stringList.last() ); |
|
66 mTipsLineEdit->setText( stringList.last() ); |
|
67 } |
|
68 } |
|
69 |
|
70 |
|
71 void FmBackupViewItem::init() |
|
72 { |
|
73 QGraphicsLinearLayout *vLayout = new QGraphicsLinearLayout(); |
|
74 vLayout->setOrientation( Qt::Vertical ); |
|
75 |
|
76 mTitleLabel = new HbLabel( "" ); |
|
77 mTitleLabel->setFontSpec( HbFontSpec( HbFontSpec::Primary ) ); |
|
78 vLayout->addItem( mTitleLabel ); |
|
79 vLayout->setAlignment( mTitleLabel, Qt::AlignLeft ); |
|
80 |
|
81 //mTipsLabel = new HbLabel( "" ); |
|
82 //mTipsLabel->setFontSpec( HbFontSpec( HbFontSpec::Secondary ) ); |
|
83 //mTipsLabel->setAlignment( Qt::AlignHCenter ); |
|
84 |
|
85 //vLayout->addItem( mTipsLabel ); |
|
86 //vLayout->setAlignment( mTipsLabel, Qt::AlignLeft ); |
|
87 |
|
88 mTipsLineEdit = new HbLineEdit( "" ); |
|
89 mTipsLineEdit->setFontSpec( HbFontSpec( HbFontSpec::Secondary ) ); |
|
90 //mTipsLineEdit->setAlignment( Qt::AlignHCenter ); |
|
91 mTipsLineEdit->setReadOnly( true ); |
|
92 |
|
93 vLayout->addItem( mTipsLineEdit ); |
|
94 vLayout->setAlignment( mTipsLineEdit, Qt::AlignLeft ); |
|
95 |
|
96 setLayout( vLayout ); |
|
97 } |
|
98 |
|
99 //FmRestoreViewItem |
|
100 FmRestoreViewItem::FmRestoreViewItem( QGraphicsItem *parent ) |
|
101 : mRestoreContentLabel( 0 ), |
|
102 mDateTimeLabel( 0 ), |
|
103 mCheckBox( 0 ), |
|
104 HbListViewItem( parent ) |
|
105 { |
|
106 init(); |
|
107 } |
|
108 |
|
109 FmRestoreViewItem::~FmRestoreViewItem() |
|
110 { |
|
111 } |
|
112 |
|
113 |
|
114 HbAbstractViewItem *FmRestoreViewItem::createItem() |
|
115 { |
|
116 return new FmRestoreViewItem( parentItem() ); |
|
117 } |
|
118 |
|
119 void FmRestoreViewItem::polish(HbStyleParameters& params) |
|
120 { |
|
121 Q_UNUSED(params); |
|
122 } |
|
123 |
|
124 void FmRestoreViewItem::updateChildItems() |
|
125 { |
|
126 QString string = modelIndex().data( Qt::DisplayRole ).toString(); |
|
127 |
|
128 QStringList stringList = string.split( '\t' ); |
|
129 |
|
130 if( stringList.count() == 0 ){ |
|
131 return; |
|
132 } |
|
133 |
|
134 mRestoreContentLabel->setText( stringList.first() ); |
|
135 |
|
136 if( stringList.first() != stringList.last() ){ |
|
137 mDateTimeLabel->setText( stringList.last() ); |
|
138 } |
|
139 |
|
140 } |
|
141 |
|
142 |
|
143 void FmRestoreViewItem::init() |
|
144 { |
|
145 QGraphicsLinearLayout *hLayout = new QGraphicsLinearLayout(); |
|
146 hLayout->setOrientation( Qt::Horizontal ); |
|
147 |
|
148 mCheckBox = new HbCheckBox( this ); |
|
149 hLayout->addItem( mCheckBox ); |
|
150 hLayout->setAlignment( mCheckBox, Qt::AlignVCenter ); |
|
151 |
|
152 QGraphicsLinearLayout *vLayout = new QGraphicsLinearLayout(); |
|
153 vLayout->setOrientation( Qt::Vertical ); |
|
154 |
|
155 mRestoreContentLabel = new HbLabel(""); |
|
156 mRestoreContentLabel->setFontSpec( HbFontSpec( HbFontSpec::Primary ) ); |
|
157 vLayout->addItem( mRestoreContentLabel ); |
|
158 vLayout->setAlignment( mRestoreContentLabel, Qt::AlignLeft ); |
|
159 |
|
160 mDateTimeLabel = new HbLabel(""); |
|
161 mDateTimeLabel->setFontSpec( HbFontSpec( HbFontSpec::Secondary ) ); |
|
162 vLayout->addItem( mDateTimeLabel ); |
|
163 vLayout->setAlignment( mDateTimeLabel, Qt::AlignLeft ); |
|
164 |
|
165 HbWidget *textWidget = new HbWidget(); |
|
166 textWidget->setLayout(vLayout); |
|
167 |
|
168 hLayout->addItem( textWidget ); |
|
169 hLayout->setAlignment( textWidget, Qt::AlignVCenter ); |
|
170 |
|
171 setLayout( hLayout ); |
|
172 |
|
173 } |
|
174 |
|
175 void FmRestoreViewItem::setCheckBoxState() |
|
176 { |
|
177 if ( mCheckBox->checkState() == Qt::Unchecked ){ |
|
178 mCheckBox->setCheckState( Qt::Checked ); |
|
179 setSelected( true ); |
|
180 } |
|
181 else if( mCheckBox->checkState() == Qt::Checked ){ |
|
182 mCheckBox->setCheckState( Qt::Unchecked ); |
|
183 setSelected( false ); |
|
184 } |
|
185 } |
|