56 } |
56 } |
57 |
57 |
58 |
58 |
59 HbAbstractViewItem *DiskListViewItem::createItem() |
59 HbAbstractViewItem *DiskListViewItem::createItem() |
60 { |
60 { |
61 return new DiskListViewItem( parentItem() ); |
61 return new DiskListViewItem( *this ); |
62 } |
62 } |
63 |
63 |
64 void DiskListViewItem::updateChildItems() |
64 void DiskListViewItem::updateChildItems() |
65 { |
65 { |
|
66 //HbListViewItem::updateChildItems(); |
|
67 if( !hLayout ) { |
|
68 init(); |
|
69 } |
66 QVariant variant = modelIndex().data( Qt::DecorationRole ); |
70 QVariant variant = modelIndex().data( Qt::DecorationRole ); |
67 QIcon icon = qvariant_cast<QIcon>( variant ); |
71 QIcon icon = qvariant_cast<QIcon>( variant ); |
68 if( icon.isNull() ) { |
72 // FmFileIconProvider in FmDriveModel already handle null icon issue |
69 QFileIconProvider fileIconProvider; |
|
70 icon = fileIconProvider.icon( QFileIconProvider::Drive ); |
|
71 } |
|
72 QString displayString = modelIndex().data( Qt::DisplayRole ).toString(); |
73 QString displayString = modelIndex().data( Qt::DisplayRole ).toString(); |
73 QString diskName = modelIndex().data( Qt::UserRole ).toString(); |
74 QString diskName = modelIndex().data( Qt::UserRole ).toString(); |
74 |
75 |
75 diskName = FmUtils::fillPathWithSplash( diskName ); |
76 diskName = FmUtils::fillPathWithSplash( diskName ); |
76 |
77 |
77 mIconLabel->setIcon( HbIcon( icon ) ); |
78 mIconLabel->setIcon( HbIcon( icon ) ); |
78 |
79 |
79 FmDriverInfo driverInfo = FmUtils::queryDriverInfo( diskName ); |
80 FmDriverInfo driverInfo = FmUtils::queryDriverInfo( diskName ); |
80 |
81 |
81 mDiskNameLabel->setPlainText( displayString ); |
82 mDiskNameLabel->setPlainText( displayString ); |
82 mSizeLabel->setPlainText( hbTrId ( "Size: " ) + FmUtils::formatStorageSize( driverInfo.size() ) ); |
83 if( driverInfo.driveState() & FmDriverInfo::EDriveAvailable ) { |
83 mFreeLabel->setPlainText( hbTrId ( "Free: " ) + FmUtils::formatStorageSize( driverInfo.freeSize() ) ); |
84 mFirstLabel->setPlainText( hbTrId ( "Size: " ) + FmUtils::formatStorageSize( driverInfo.size() ) ); |
|
85 mSecondLabel->setPlainText( hbTrId ( "Free: " ) + FmUtils::formatStorageSize( driverInfo.freeSize() ) ); |
|
86 } else if( driverInfo.driveState() & FmDriverInfo::EDriveLocked ) { |
|
87 mFirstLabel->setPlainText( hbTrId ( "Locked" ) ); |
|
88 mSecondLabel->setPlainText( QString(" ") ); |
|
89 } else if( driverInfo.driveState() & FmDriverInfo::EDriveCorrupted ) { |
|
90 mFirstLabel->setPlainText( hbTrId ( "Corrupted" ) ); |
|
91 mSecondLabel->setPlainText( QString(" ") ); |
|
92 } else if( driverInfo.driveState() & FmDriverInfo::EDriveNotPresent ) { |
|
93 mFirstLabel->setPlainText( hbTrId ( "Not Ready" ) ); |
|
94 mSecondLabel->setPlainText( QString(" ") ); |
|
95 } |
84 |
96 |
85 // mCheckBox->setCheckState( checkState() ); |
97 // mCheckBox->setCheckState( checkState() ); |
86 } |
98 } |
87 |
99 |
88 void DiskListViewItem::setCheckedState( int state ) |
100 void DiskListViewItem::setCheckedState( int state ) |
90 HbAbstractViewItem::setCheckState( static_cast<Qt::CheckState>(state) ); |
102 HbAbstractViewItem::setCheckState( static_cast<Qt::CheckState>(state) ); |
91 } |
103 } |
92 |
104 |
93 void DiskListViewItem::init() |
105 void DiskListViewItem::init() |
94 { |
106 { |
95 QGraphicsLinearLayout *hLayout = new QGraphicsLinearLayout(); |
107 hLayout = new QGraphicsLinearLayout(); |
|
108 |
96 hLayout->setOrientation( Qt::Horizontal ); |
109 hLayout->setOrientation( Qt::Horizontal ); |
97 |
110 hLayout->addItem(layout()); |
|
111 |
98 mIconLabel = new HbLabel(); |
112 mIconLabel = new HbLabel(); |
99 mIconLabel->setMinimumWidth(32); |
113 mIconLabel->setMinimumWidth(32); |
100 hLayout->addItem( mIconLabel ); |
114 hLayout->addItem( mIconLabel ); |
101 hLayout->setAlignment( mIconLabel, Qt::AlignTop ); |
115 hLayout->setAlignment( mIconLabel, Qt::AlignTop ); |
102 hLayout->setStretchFactor( mIconLabel, 1 ); |
116 hLayout->setStretchFactor( mIconLabel, 1 ); |
107 mDiskNameLabel = new HbLabel(); |
121 mDiskNameLabel = new HbLabel(); |
108 mDiskNameLabel->setFontSpec( HbFontSpec( HbFontSpec::Primary ) ); |
122 mDiskNameLabel->setFontSpec( HbFontSpec( HbFontSpec::Primary ) ); |
109 vLayout->addItem( mDiskNameLabel ); |
123 vLayout->addItem( mDiskNameLabel ); |
110 vLayout->setAlignment( mDiskNameLabel, Qt::AlignLeft ); |
124 vLayout->setAlignment( mDiskNameLabel, Qt::AlignLeft ); |
111 |
125 |
112 mSizeLabel = new HbLabel(); |
126 mFirstLabel = new HbLabel(); |
113 mSizeLabel->setFontSpec( HbFontSpec( HbFontSpec::Secondary ) ); |
127 mFirstLabel->setFontSpec( HbFontSpec( HbFontSpec::Secondary ) ); |
114 vLayout->addItem( mSizeLabel ); |
128 vLayout->addItem( mFirstLabel ); |
115 vLayout->setAlignment( mSizeLabel, Qt::AlignLeft ); |
129 vLayout->setAlignment( mFirstLabel, Qt::AlignLeft ); |
116 |
130 |
117 mFreeLabel = new HbLabel(); |
131 mSecondLabel = new HbLabel(); |
118 mFreeLabel->setFontSpec( HbFontSpec( HbFontSpec::Secondary ) ); |
132 mSecondLabel->setFontSpec( HbFontSpec( HbFontSpec::Secondary ) ); |
119 vLayout->addItem( mFreeLabel ); |
133 vLayout->addItem( mSecondLabel ); |
120 vLayout->setAlignment( mFreeLabel, Qt::AlignLeft ); |
134 vLayout->setAlignment( mSecondLabel, Qt::AlignLeft ); |
121 |
135 |
122 HbWidget *labelsWidget = new HbWidget(); |
136 HbWidget *labelsWidget = new HbWidget(); |
123 labelsWidget->setLayout(vLayout); |
137 labelsWidget->setLayout(vLayout); |
124 |
138 |
125 hLayout->addItem( labelsWidget ); |
139 hLayout->addItem( labelsWidget ); |
126 hLayout->setStretchFactor( labelsWidget, 5 ); |
140 hLayout->setStretchFactor( labelsWidget, 5 ); |
127 |
141 |
128 setLayout( hLayout ); |
142 setLayout( hLayout ); |
129 } |
143 } |
130 |
|
131 //file list item, not used. |
|
132 /* |
|
133 FileListViewItem::FileListViewItem( QGraphicsItem *parent ) |
|
134 : HbListViewItem( parent ), |
|
135 mIconLabel( 0 ), |
|
136 mNameLabel( 0 ), |
|
137 mCheckBox( 0 ) |
|
138 { |
|
139 init(); |
|
140 } |
|
141 |
|
142 FileListViewItem::~FileListViewItem() |
|
143 { |
|
144 } |
|
145 |
|
146 void FileListViewItem::polish(HbStyleParameters& params) |
|
147 { |
|
148 Q_UNUSED(params); |
|
149 } |
|
150 |
|
151 bool FileListViewItem::canSetModelIndex( const QModelIndex &index ) const |
|
152 { |
|
153 Q_UNUSED( index ); |
|
154 return true; |
|
155 |
|
156 // do not used |
|
157 // const QFileSystemModel *model = dynamic_cast<const QFileSystemModel *>(index.model()); |
|
158 // QFileInfo info = model->fileInfo( index ); |
|
159 // QString path = info.path(); |
|
160 |
|
161 // return (path.right(1) != ":"); |
|
162 |
|
163 } |
|
164 |
|
165 |
|
166 HbAbstractViewItem *FileListViewItem::createItem() |
|
167 { |
|
168 return new FileListViewItem( parentItem() ); |
|
169 } |
|
170 |
|
171 void FileListViewItem::updateChildItems() |
|
172 { |
|
173 QVariant variant = modelIndex().data( Qt::DecorationRole ); |
|
174 QIcon icon = qvariant_cast<QIcon>( variant ); |
|
175 QString diskName = modelIndex().data( Qt::DisplayRole ).toString(); |
|
176 |
|
177 QString debugString = "updateChindItems: diskName = " + diskName; |
|
178 FmLogger::log(debugString); |
|
179 mIconLabel->setIcon( HbIcon( icon ) ); |
|
180 mNameLabel->setPlainText( diskName ); |
|
181 mCheckBox->setCheckState( checkState() ); |
|
182 } |
|
183 |
|
184 void FileListViewItem::setCheckedState( int state ) |
|
185 { |
|
186 HbAbstractViewItem::setCheckState( static_cast<Qt::CheckState>(state) ); |
|
187 } |
|
188 |
|
189 void FileListViewItem::init() |
|
190 { |
|
191 QGraphicsLinearLayout *hLayout = new QGraphicsLinearLayout(); |
|
192 hLayout->setOrientation( Qt::Horizontal ); |
|
193 |
|
194 mIconLabel = new HbLabel(); |
|
195 mIconLabel->setMinimumWidth(32); |
|
196 hLayout->addItem( mIconLabel ); |
|
197 hLayout->setAlignment( mIconLabel, Qt::AlignTop ); |
|
198 hLayout->setStretchFactor( mIconLabel, 1 ); |
|
199 |
|
200 mNameLabel = new HbLabel(); |
|
201 mNameLabel->setFontSpec( HbFontSpec( HbFontSpec::Primary ) ); |
|
202 mNameLabel->setAlignment( Qt::AlignVCenter ); |
|
203 hLayout->addItem( mNameLabel ); |
|
204 hLayout->setAlignment( mNameLabel, Qt::AlignLeft ); |
|
205 hLayout->setStretchFactor( mNameLabel, 20 ); |
|
206 |
|
207 mCheckBox = new HbCheckBox( this ); |
|
208 connect( mCheckBox, SIGNAL(stateChanged(int)), this, SLOT(setCheckedState(int)) ); |
|
209 hLayout->addItem( mCheckBox ); |
|
210 hLayout->setAlignment( mCheckBox, Qt::AlignLeft ); |
|
211 |
|
212 setLayout( hLayout ); |
|
213 } |
|
214 */ |
|