Changeset View
Changeset View
Standalone View
Standalone View
src/filewidgets/kfileplacesview.cpp
Show First 20 Lines • Show All 206 Lines • ▼ Show 20 Line(s) | 203 | if (opt.state & QStyle::State_Selected) { | |||
---|---|---|---|---|---|
207 | } else if (!(opt.state & QStyle::State_Active)) { | 207 | } else if (!(opt.state & QStyle::State_Active)) { | ||
208 | cg = QPalette::Inactive; | 208 | cg = QPalette::Inactive; | ||
209 | } | 209 | } | ||
210 | painter->setPen(opt.palette.color(cg, QPalette::HighlightedText)); | 210 | painter->setPen(opt.palette.color(cg, QPalette::HighlightedText)); | ||
211 | } | 211 | } | ||
212 | 212 | | |||
213 | QRect rectText; | 213 | QRect rectText; | ||
214 | 214 | | |||
215 | const QUrl url = placesModel->url(index); | | |||
216 | bool drawCapacityBar = false; | 215 | bool drawCapacityBar = false; | ||
217 | if (url.isLocalFile()) { | 216 | if (placesModel->data(index, KFilePlacesModel::CapacityBarRecommendedRole).toBool()) { | ||
218 | const QString mountPointPath = placesModel->url(index).toLocalFile(); | 217 | const QUrl url = placesModel->url(index); | ||
219 | const KDiskFreeSpaceInfo info = KDiskFreeSpaceInfo::freeSpaceInfo(mountPointPath); | 218 | if (url.isLocalFile() && contentsOpacity(index) > 0) { | ||
220 | drawCapacityBar = info.size() != 0 && | 219 | const QString mountPointPath = url.toLocalFile(); | ||
221 | placesModel->data(index, KFilePlacesModel::CapacityBarRecommendedRole).toBool(); | | |||
222 | 220 | | |||
223 | if (drawCapacityBar && contentsOpacity(index) > 0) { | 221 | const KDiskFreeSpaceInfo info = KDiskFreeSpaceInfo::freeSpaceInfo(mountPointPath); | ||
222 | drawCapacityBar = info.size() != 0; | ||||
223 | if (drawCapacityBar) { | ||||
224 | painter->save(); | 224 | painter->save(); | ||
225 | painter->setOpacity(painter->opacity() * contentsOpacity(index)); | 225 | painter->setOpacity(painter->opacity() * contentsOpacity(index)); | ||
226 | 226 | | |||
227 | int height = opt.fontMetrics.height() + CAPACITYBAR_HEIGHT; | 227 | int height = opt.fontMetrics.height() + CAPACITYBAR_HEIGHT; | ||
228 | rectText = QRect(isLTR ? m_iconSize + LATERAL_MARGIN * 2 + opt.rect.left() | 228 | rectText = QRect(isLTR ? m_iconSize + LATERAL_MARGIN * 2 + opt.rect.left() | ||
229 | : 0, opt.rect.top() + (opt.rect.height() / 2 - height / 2), opt.rect.width() - m_iconSize - LATERAL_MARGIN * 2, opt.fontMetrics.height()); | 229 | : 0, opt.rect.top() + (opt.rect.height() / 2 - height / 2), opt.rect.width() - m_iconSize - LATERAL_MARGIN * 2, opt.fontMetrics.height()); | ||
230 | painter->drawText(rectText, Qt::AlignLeft | Qt::AlignTop, opt.fontMetrics.elidedText(index.model()->data(index).toString(), Qt::ElideRight, rectText.width())); | 230 | painter->drawText(rectText, Qt::AlignLeft | Qt::AlignTop, opt.fontMetrics.elidedText(index.model()->data(index).toString(), Qt::ElideRight, rectText.width())); | ||
231 | QRect capacityRect(isLTR ? rectText.x() : LATERAL_MARGIN, rectText.bottom() - 1, rectText.width() - LATERAL_MARGIN, CAPACITYBAR_HEIGHT); | 231 | QRect capacityRect(isLTR ? rectText.x() : LATERAL_MARGIN, rectText.bottom() - 1, rectText.width() - LATERAL_MARGIN, CAPACITYBAR_HEIGHT); | ||
232 | KCapacityBar capacityBar(KCapacityBar::DrawTextInline); | 232 | KCapacityBar capacityBar(KCapacityBar::DrawTextInline); | ||
233 | capacityBar.setValue((info.used() * 100) / info.size()); | 233 | capacityBar.setValue((info.used() * 100) / info.size()); | ||
234 | capacityBar.drawCapacityBar(painter, capacityRect); | 234 | capacityBar.drawCapacityBar(painter, capacityRect); | ||
235 | 235 | | |||
236 | painter->restore(); | 236 | painter->restore(); | ||
237 | 237 | | |||
238 | painter->save(); | 238 | painter->save(); | ||
239 | painter->setOpacity(painter->opacity() * (1 - contentsOpacity(index))); | 239 | painter->setOpacity(painter->opacity() * (1 - contentsOpacity(index))); | ||
240 | } | 240 | } | ||
241 | } | 241 | } | ||
242 | } | ||||
242 | 243 | | |||
243 | rectText = QRect(isLTR ? m_iconSize + LATERAL_MARGIN * 2 + opt.rect.left() | 244 | rectText = QRect(isLTR ? m_iconSize + LATERAL_MARGIN * 2 + opt.rect.left() | ||
244 | : 0, opt.rect.top(), opt.rect.width() - m_iconSize - LATERAL_MARGIN * 2, opt.rect.height()); | 245 | : 0, opt.rect.top(), opt.rect.width() - m_iconSize - LATERAL_MARGIN * 2, opt.rect.height()); | ||
245 | painter->drawText(rectText, Qt::AlignLeft | Qt::AlignVCenter, opt.fontMetrics.elidedText(index.model()->data(index).toString(), Qt::ElideRight, rectText.width())); | 246 | painter->drawText(rectText, Qt::AlignLeft | Qt::AlignVCenter, opt.fontMetrics.elidedText(index.model()->data(index).toString(), Qt::ElideRight, rectText.width())); | ||
246 | 247 | | |||
247 | if (drawCapacityBar && contentsOpacity(index) > 0) { | 248 | if (drawCapacityBar) { | ||
248 | painter->restore(); | 249 | painter->restore(); | ||
249 | } | 250 | } | ||
250 | 251 | | |||
251 | painter->restore(); | 252 | painter->restore(); | ||
252 | } | 253 | } | ||
253 | 254 | | |||
254 | int KFilePlacesViewDelegate::iconSize() const | 255 | int KFilePlacesViewDelegate::iconSize() const | ||
255 | { | 256 | { | ||
▲ Show 20 Lines • Show All 1191 Lines • Show Last 20 Lines |