Commit 6cf06f02 authored by Simon Persson's avatar Simon Persson
Browse files

Clean up code in DriveSelection widget, show more info.

Now it will remember and show file system label of selected backup destination, also shows device description and total capacity. Only shows partition number if there is more than one partition.
Swedish translation also updated with the new strings.
parent cb9fc0e5
......@@ -13,8 +13,6 @@
- Figure out a file format for backup exclude config files, maybe system-wide under something like /etc/backup-exclude.d/10-firefox-cache.exclude
and user specific could be under ~/.config/fd.o/backup-exclude.d/
- Make an "Advanced" page of backup plan configuration to tweak behaviors. Like whether to respect those exclude lists or not.
- Clean up code for driveselection/driveselectiondelegate. Ugly to ask solid for devices from a paint() funtion!
- Make it possible to select/deselect hidden folders.
- Add a kauth-based runner for running a backup job as root.
- Make use of nice and ionice for running the backups.
- Fix driveselection to also show partition label for disconnected drive.
\ No newline at end of file
......@@ -55,12 +55,21 @@ void EDExecutor::checkStatus() {
void EDExecutor::deviceAdded(const QString &pUdi) {
Solid::Device lDevice(pUdi);
if(!lDevice.isValid() || !lDevice.is<Solid::StorageVolume>()) {
if(!lDevice.is<Solid::StorageVolume>()) {
return;
}
Solid::StorageVolume *lVolume = lDevice.as<Solid::StorageVolume>();
if(mPlan->mExternalUUID == lVolume->uuid())
{
QString lUUID = lVolume->uuid();
if(lUUID.isEmpty()) { //seems to happen for vfat partitions
Solid::Device lDriveDevice;
if(lDevice.is<Solid::StorageDrive>()) {
lDriveDevice = lDevice;
} else {
lDriveDevice = lDevice.parent();
}
lUUID = lDriveDevice.description() + "|" + lVolume->label();
}
if(mPlan->mExternalUUID == lUUID) {
mCurrentUdi = pUdi;
mStorageAccess = lDevice.as<Solid::StorageAccess>();
enterAvailableState();
......
......@@ -133,7 +133,7 @@ KPageWidgetItem *BackupPlanWidget::createSourcePage(QWidget *pParent) {
return lPage;
}
KPageWidgetItem *BackupPlanWidget::createDestinationPage(QWidget *pParent) {
KPageWidgetItem *BackupPlanWidget::createDestinationPage(BackupPlan *pBackupPlan, QWidget *pParent) {
KButtonGroup *lButtonGroup = new KButtonGroup(pParent);
lButtonGroup->setObjectName("kcfg_Destination type");
lButtonGroup->setFlat(true);
......@@ -152,9 +152,9 @@ KPageWidgetItem *BackupPlanWidget::createDestinationPage(QWidget *pParent) {
lDriveWidget->setVisible(false);
QObject::connect(lDriveRadio, SIGNAL(toggled(bool)), lDriveWidget, SLOT(setVisible(bool)));
QVBoxLayout *lDriveLayout = new QVBoxLayout;
DriveSelection *lDriveSelection = new DriveSelection;
lDriveSelection->setObjectName("kcfg_External drive UUID");
lDriveLayout->addWidget(lDriveSelection);
mDriveSelection = new DriveSelection(pBackupPlan);
mDriveSelection->setObjectName("kcfg_External drive UUID");
lDriveLayout->addWidget(mDriveSelection);
QHBoxLayout *lDriveHoriLayout = new QHBoxLayout;
QLabel *lDriveDestLabel = new QLabel(i18nc("@label:textbox", "Folder on Destination Drive:"));
KLineEdit *lDriveDestination = new KLineEdit;
......@@ -298,7 +298,7 @@ KPageWidgetItem *BackupPlanWidget::createSchedulePage(QWidget *pParent) {
return lPage;
}
BackupPlanWidget::BackupPlanWidget(bool pCreatePages, QWidget *pParent)
BackupPlanWidget::BackupPlanWidget(BackupPlan *pBackupPlan, bool pCreatePages, QWidget *pParent)
: QWidget(pParent)
{
QVBoxLayout *lVLayout1 = new QVBoxLayout;
......@@ -315,7 +315,7 @@ BackupPlanWidget::BackupPlanWidget(bool pCreatePages, QWidget *pParent)
mConfigPages = new KPageWidget;
if(pCreatePages) {
mConfigPages->addPage(createSourcePage(this));
mConfigPages->addPage(createDestinationPage(this));
mConfigPages->addPage(createDestinationPage(pBackupPlan, this));
mConfigPages->addPage(createSchedulePage(this));
}
......@@ -330,3 +330,7 @@ BackupPlanWidget::BackupPlanWidget(bool pCreatePages, QWidget *pParent)
setLayout(lVLayout1);
}
void BackupPlanWidget::saveExtraData() {
mDriveSelection->saveExtraData();
}
......@@ -24,6 +24,7 @@
#include <QWidget>
class BackupPlan;
class DriveSelection;
class FolderSelectionModel;
class KLineEdit;
......@@ -63,15 +64,18 @@ class BackupPlanWidget : public QWidget
{
Q_OBJECT
public:
explicit BackupPlanWidget(bool pCreatePages = true, QWidget *pParent = 0);
explicit BackupPlanWidget(BackupPlan *pBackupPlan, bool pCreatePages = true, QWidget *pParent = 0);
static KPageWidgetItem *createSourcePage(QWidget *pParent = NULL);
static KPageWidgetItem *createDestinationPage(QWidget *pParent = NULL);
static KPageWidgetItem *createSchedulePage(QWidget *pParent = NULL);
void saveExtraData();
KPageWidgetItem *createSourcePage(QWidget *pParent = NULL);
KPageWidgetItem *createDestinationPage(BackupPlan *pBackupPlan, QWidget *pParent = NULL);
KPageWidgetItem *createSchedulePage(QWidget *pParent = NULL);
KLineEdit *mDescriptionEdit;
KPushButton *mConfigureButton;
KPageWidget *mConfigPages;
DriveSelection *mDriveSelection;
signals:
void requestOverviewReturn();
......
/***************************************************************************
* Copyright Simon Persson *
* simonpersson1@gmail.com *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include "driveselection.h"
#include "driveselectiondelegate.h"
#include "backupplan.h"
#include <QStringList>
#include <QList>
#include <Solid/Device>
#include <Solid/DeviceNotifier>
#include <Solid/StorageDrive>
#include <Solid/StorageVolume>
#include <Solid/StorageAccess>
#include <QItemSelectionModel>
#include <QList>
#include <QStandardItemModel>
#include <QTimer>
#include <KConfigDialogManager>
#include <KDiskFreeSpaceInfo>
#include <KLocale>
#include <Solid/Device>
#include <Solid/DeviceNotifier>
#include <Solid/StorageAccess>
#include <Solid/StorageDrive>
#include <Solid/StorageVolume>
bool deviceLessThan(const Solid::Device &a, const Solid::Device &b) {
return a.udi() < b.udi();
}
DriveSelection::DriveSelection(QWidget *parent)
: QListView(parent)
DriveSelection::DriveSelection(BackupPlan *pBackupPlan, QWidget *parent)
: QListView(parent), mBackupPlan(pBackupPlan)
{
KConfigDialogManager::changedMap()->insert("DriveSelection", SIGNAL(driveSelectionChanged()));
m_drivesModel = new QStandardItemModel(this);
setModel(m_drivesModel);
m_drivesDelegate = new DriveSelectionDelegate;
setItemDelegate(m_drivesDelegate);
mDrivesModel = new QStandardItemModel(this);
setModel(mDrivesModel);
setItemDelegate(new DriveSelectionDelegate(this));
setSelectionMode(QAbstractItemView::SingleSelection);
reloadDrives();
QList<Solid::Device> lDeviceList = Solid::Device::listFromType(Solid::DeviceInterface::StorageDrive);
foreach (const Solid::Device &lDevice, lDeviceList) {
deviceAdded(lDevice.udi());
}
connect(Solid::DeviceNotifier::instance(), SIGNAL(deviceAdded(QString)), SLOT(deviceAdded(QString)));
connect(Solid::DeviceNotifier::instance(), SIGNAL(deviceRemoved(QString)), SLOT(deviceRemoved(QString)));
connect(selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
this, SLOT(updateSelectedDrive(QItemSelection,QItemSelection)));
connect(Solid::DeviceNotifier::instance(), SIGNAL(deviceAdded(QString)), SLOT(reloadDrives()));
connect(Solid::DeviceNotifier::instance(), SIGNAL(deviceRemoved(QString)), SLOT(reloadDrives()));
this, SLOT(updateSelection(QItemSelection,QItemSelection)));
}
void DriveSelection::reloadDrives()
{
m_drivesModel->clear();
QStandardItem *selected = 0;
QList<Solid::Device> drives = Solid::Device::listFromType(Solid::DeviceInterface::StorageDrive, QString());
for (int vNum=0;vNum < drives.size();vNum++) {
Solid::StorageDrive *drive = drives[vNum].as<Solid::StorageDrive>();
if (!drive || !drive->isHotpluggable()) {
continue;
void DriveSelection::deviceAdded(const QString &pUdi) {
Solid::Device lDevice(pUdi);
if(!lDevice.is<Solid::StorageDrive>()) {
return;
}
Solid::StorageDrive *lDrive = lDevice.as<Solid::StorageDrive>();
if(!lDrive->isHotpluggable()) {
return;
}
if(mDrivesToAdd.contains(pUdi)) {
return;
}
mDrivesToAdd.append(pUdi);
QTimer::singleShot(2000, this, SLOT(delayedDeviceAdded()));
}
void DriveSelection::delayedDeviceAdded() {
if(mDrivesToAdd.isEmpty()) {
return;
}
Solid::Device lParentDevice(mDrivesToAdd.takeFirst());
QList<Solid::Device> lDeviceList = Solid::Device::listFromType(Solid::DeviceInterface::StorageVolume,
lParentDevice.udi());
// check for when there is no partitioning scheme, then the drive is also the storage volume
if(lParentDevice.is<Solid::StorageVolume>()) {
lDeviceList.append(lParentDevice);
}
// filter out some volumes that should not be visible
QList<Solid::Device> lVolumeDeviceList;
foreach(Solid::Device lVolumeDevice, lDeviceList) {
Solid::StorageVolume *lVolume = lVolumeDevice.as<Solid::StorageVolume>();
if (lVolume && lVolume->usage() == Solid::StorageVolume::FileSystem && !lVolume->isIgnored()) {
lVolumeDeviceList.append(lVolumeDevice);
}
QList<Solid::Device> storageVolumes = Solid::Device::listFromType(Solid::DeviceInterface::StorageVolume, drives[vNum].udi());
for (int svNum=0;svNum < storageVolumes.size();svNum++) {
Solid::StorageVolume *storageVolume = storageVolumes[svNum].as<Solid::StorageVolume>();
if (!storageVolume || storageVolume->usage() != Solid::StorageVolume::FileSystem) {
continue;
}
QStandardItem *item = new QStandardItem();
item->setText(storageVolume->label());
if (item->text().isEmpty())
item->setText(drives[vNum].description());
Solid::StorageAccess *access = storageVolumes[svNum].as<Solid::StorageAccess>();
if(!access->isAccessible()) {
access->setup();
item->setData(0, Qt::UserRole + 3);
item->setData(0, Qt::UserRole + 4);
}
else {
KDiskFreeSpaceInfo info = KDiskFreeSpaceInfo::freeSpaceInfo(access->filePath());
if (info.isValid()) {
item->setData(info.size(), Qt::UserRole + 3);
item->setData(info.used(), Qt::UserRole + 4);
} else {
item->setData(0, Qt::UserRole + 3);
item->setData(0, Qt::UserRole + 4);
}
}
// simplest attempt at getting the same partition numbering every time a device is plugged in
qSort(lVolumeDeviceList.begin(), lVolumeDeviceList.end(), deviceLessThan);
int lPartitionNumber = 1;
foreach(Solid::Device lVolumeDevice, lVolumeDeviceList) {
Solid::StorageVolume *lVolume = lVolumeDevice.as<Solid::StorageVolume>();
QStandardItem *lItem = new QStandardItem();
lItem->setEditable(false);
QString lUUID = lVolume->uuid();
if(lUUID.isEmpty()) { //seems to happen for vfat partitions
lUUID = lParentDevice.description() + "|" + lVolume->label();
}
lItem->setData(lUUID, DriveSelection::UUID);
lItem->setData(lParentDevice.description(), DriveSelection::DeviceDescription);
lItem->setData(lVolume->label(), DriveSelection::Label);
lItem->setData(lVolumeDevice.udi(), DriveSelection::UDI);
lItem->setData(lPartitionNumber, DriveSelection::PartitionNumber);
lItem->setData(lVolumeDeviceList.count(), DriveSelection::PartitionsOnDrive);
lItem->setData(0, DriveSelection::TotalSpace);
lItem->setData(0, DriveSelection::UsedSpace);
Solid::StorageAccess *lAccess = lVolumeDevice.as<Solid::StorageAccess>();
if(!lAccess->isAccessible()) {
connect(lAccess, SIGNAL(accessibilityChanged(bool,QString)), SLOT(accessabilityChanged(bool,QString)));
lAccess->setup();
} else {
KDiskFreeSpaceInfo lInfo = KDiskFreeSpaceInfo::freeSpaceInfo(lAccess->filePath());
if(lInfo.isValid()) {
lItem->setData(lInfo.size(), DriveSelection::TotalSpace);
lItem->setData(lInfo.used(), DriveSelection::UsedSpace);
}
item->setData(drives.at(vNum).udi(), Qt::UserRole + 1);
item->setData(storageVolume->uuid(), Qt::UserRole + 2);
item->setEditable(false);
m_drivesModel->appendRow(item);
if (storageVolume->uuid() == mSelectedUuid) {
selected = item;
}
mDrivesModel->appendRow(lItem);
if(mSelectedUuid == lUUID) {
QModelIndex lIndex = mDrivesModel->indexFromItem(lItem);
setCurrentIndex(lIndex);
removeDisconnectedItem();
mSelectedUdi = lVolumeDevice.udi();
}
lPartitionNumber++;
}
}
void DriveSelection::deviceRemoved(const QString &pUdi) {
for(int lRow = 0; lRow < mDrivesModel->rowCount(); ++lRow) {
QStandardItem *lItem = mDrivesModel->item(lRow);
if(lItem->data(DriveSelection::UDI).toString() == pUdi) {
if(pUdi == mSelectedUdi) {
addDisconnectedItem();
}
// notifier->addDevice(storageVolume); //TODO
mDrivesModel->removeRow(lRow);
break;
}
}
if (selected) {
QModelIndex index = m_drivesModel->indexFromItem(selected);
setCurrentIndex(index);
} else if (!mSelectedUuid.isEmpty()) {
QStandardItem *item = new QStandardItem();
// QString name = daemon->getDeviceName();
// if (name.isEmpty())
item->setText(i18nc("@item", "Selected Backup Device (disconnected)"));
// else
// item->setText(i18n("%1 (disconnected)").arg(name));
item->setData("DISCONNECTED_BACKUP_DEVICE", Qt::UserRole + 1);
item->setData(mSelectedUuid, Qt::UserRole + 2);
item->setData(0, Qt::UserRole + 3);
item->setData(0, Qt::UserRole + 4);
item->setEditable(false);
m_drivesModel->appendRow(item);
QModelIndex index = m_drivesModel->indexFromItem(item);
setCurrentIndex(index);
}
void DriveSelection::accessabilityChanged(bool pAccessible, const QString &pUdi) {
if(!pAccessible) {
return;
}
Solid::Device lDevice(pUdi);
Solid::StorageAccess *lAccess = lDevice.as<Solid::StorageAccess>();
if(!lAccess) {
return;
}
KDiskFreeSpaceInfo lInfo = KDiskFreeSpaceInfo::freeSpaceInfo(lAccess->filePath());
if(!lInfo.isValid()) {
return;
}
for(int lRow = 0; lRow < mDrivesModel->rowCount(); ++lRow) {
QStandardItem *lItem = mDrivesModel->item(lRow);
if(lItem->data(DriveSelection::UDI).toString() == pUdi) {
lItem->setData(lInfo.size(), DriveSelection::TotalSpace);
lItem->setData(lInfo.used(), DriveSelection::UsedSpace);
break;
}
}
}
void DriveSelection::updateSelectedDrive(const QItemSelection &pSelected, const QItemSelection &pDeselected) {
void DriveSelection::updateSelection(const QItemSelection &pSelected, const QItemSelection &pDeselected) {
Q_UNUSED(pDeselected)
mSelectedUuid = pSelected.indexes().first().data(Qt::UserRole+2).toString();
emit driveSelectionChanged();
if(!pSelected.indexes().isEmpty()) {
mSelectedUuid = pSelected.indexes().first().data(DriveSelection::UUID).toString();
emit driveSelectionChanged();
}
}
void DriveSelection::setSelectedDrive(const QString &pUuid) {
if(pUuid == mSelectedUuid) {
return;
}
mSelectedUuid = pUuid;
reloadDrives();
for(int lRow = 0; lRow < mDrivesModel->rowCount(); ++lRow) {
QStandardItem *lItem = mDrivesModel->item(lRow);
if(lItem->data(DriveSelection::UUID).toString() == mSelectedUuid) {
QModelIndex lIndex = mDrivesModel->indexFromItem(lItem);
setCurrentIndex(lIndex);
mSelectedUdi = lIndex.data(DriveSelection::UDI).toString();
return;
}
}
addDisconnectedItem();
}
void DriveSelection::saveExtraData() {
for(int lRow = 0; lRow < mDrivesModel->rowCount(); ++lRow) {
QStandardItem *lItem = mDrivesModel->item(lRow);
if(lItem->data(DriveSelection::UUID).toString() == mSelectedUuid) {
lItem->data(DriveSelection::TotalSpace);
mBackupPlan->mExternalDeviceDescription = lItem->data(DriveSelection::DeviceDescription).toString();
mBackupPlan->mExternalPartitionNumber = lItem->data(DriveSelection::PartitionNumber).toInt();
mBackupPlan->mExternalPartitionsOnDrive = lItem->data(DriveSelection::PartitionsOnDrive).toInt();
mBackupPlan->mExternalVolumeCapacity = lItem->data(DriveSelection::TotalSpace).toULongLong();
mBackupPlan->mExternalVolumeLabel = lItem->data(DriveSelection::Label).toString();
mSelectedUdi = lItem->data(DriveSelection::UDI).toString();
return;
}
}
}
void DriveSelection::addDisconnectedItem() {
if(mSelectedUuid.isEmpty()) {
return;
}
QStandardItem *lItem = new QStandardItem();
lItem->setData(QLatin1String("DISCONNECTED_BACKUP_DEVICE"), DriveSelection::UDI);
lItem->setData(mSelectedUuid, DriveSelection::UUID);
lItem->setData(0, DriveSelection::UsedSpace);
lItem->setData(mBackupPlan->mExternalPartitionNumber, DriveSelection::PartitionNumber);
lItem->setData(mBackupPlan->mExternalPartitionsOnDrive, DriveSelection::PartitionsOnDrive);
lItem->setData(mBackupPlan->mExternalDeviceDescription, DriveSelection::DeviceDescription);
lItem->setData(mBackupPlan->mExternalVolumeCapacity, DriveSelection::TotalSpace);
lItem->setData(mBackupPlan->mExternalVolumeLabel, DriveSelection::Label);
lItem->setEditable(false);
mDrivesModel->appendRow(lItem);
QModelIndex lIndex = mDrivesModel->indexFromItem(lItem);
setCurrentIndex(lIndex);
mSelectedUdi.clear();
}
void DriveSelection::removeDisconnectedItem() {
for(int lRow = 0; lRow < mDrivesModel->rowCount(); ++lRow) {
QStandardItem *lItem = mDrivesModel->item(lRow);
if(lItem->data(DriveSelection::UDI).toString() == QLatin1String("DISCONNECTED_BACKUP_DEVICE")) {
mDrivesModel->removeRow(lRow);
break;
}
}
}
/***************************************************************************
* Copyright Simon Persson *
* simonpersson1@gmail.com *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef DRIVESELECTION_H
#define DRIVESELECTION_H
#include <QListView>
#include <QString>
class FolderSelectionModel;
class DriveSelectionDelegate;
#include <QStringList>
class QStandardItemModel;
class BackupPlan;
class DriveSelection : public QListView
{
Q_OBJECT
Q_PROPERTY(QString selectedDrive READ selectedDrive WRITE setSelectedDrive USER true)
Q_PROPERTY(QString selectedDrive READ selectedDrive WRITE setSelectedDrive NOTIFY driveSelectionChanged USER true)
public:
enum DataType {
UUID = Qt::UserRole + 1,
UDI,
TotalSpace,
UsedSpace,
Label,
DeviceDescription,
PartitionNumber,
PartitionsOnDrive
};
public:
DriveSelection(QWidget *parent=0);
DriveSelection(BackupPlan *pBackupPlan, QWidget *parent=0);
QString selectedDrive() {return mSelectedUuid;}
void setSelectedDrive(const QString &pUuid);
void saveExtraData();
signals:
void driveSelectionChanged();
protected slots:
void reloadDrives();
void updateSelectedDrive(const QItemSelection &pSelected, const QItemSelection &pDeselected);
void deviceAdded(const QString &pUdi);
void delayedDeviceAdded();
void deviceRemoved(const QString &pUdi);
void accessabilityChanged(bool pAccessible, const QString &pUdi);
void updateSelection(const QItemSelection &pSelected, const QItemSelection &pDeselected);
private:
QStandardItemModel *m_drivesModel;
DriveSelectionDelegate *m_drivesDelegate;
void addDisconnectedItem();
void removeDisconnectedItem();
QStandardItemModel *mDrivesModel;
QString mSelectedUuid;
QString mSelectedUdi; //remembered for noticing when a selected drive is disconnected.
BackupPlan *mBackupPlan;
QStringList mDrivesToAdd;
};
#endif
/*
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License version 2 as published by the Free Software Foundation.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
/***************************************************************************
* Copyright Simon Persson *
* simonpersson1@gmail.com *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include "backupplan.h"
#include "driveselectiondelegate.h"
#include "driveselection.h"
#include <QApplication>
#include <QPainter>
#include <QStyle>
#include <KDiskFreeSpaceInfo>
#include <kcapacitybar.h>
#include <KGlobal>
#include <KLocale>
#include <Solid/Device>
#include <Solid/StorageDrive>
#include <Solid/StorageVolume>
#include <Solid/StorageAccess>
#include <kio/global.h>
static const int cMargin = 6;
void DriveSelectionDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const {
painter->save();
painter->setRenderHint(QPainter::Antialiasing);
DriveSelectionDelegate::DriveSelectionDelegate(QObject *pParent)
: QStyledItemDelegate(pParent)