Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
moved to the device widget class
  • Loading branch information
Flavio Castelli committed Oct 5, 2009
1 parent 8113c2d commit 6937ae7
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 78 deletions.
62 changes: 9 additions & 53 deletions src/app/addbackupwizardpage1.cpp
Expand Up @@ -27,12 +27,7 @@
#include <QtCore/QList>
#include <QtGui/QTreeWidgetItem>

//solid specific includes
#include <solid/devicenotifier.h>
#include <solid/device.h>
#include <solid/deviceinterface.h>
#include <solid/storagedrive.h>
#include <solid/storagevolume.h>
#include "devicewidget.h"

AddBackupWizardPage1::AddBackupWizardPage1(QWidget* parent)
: QWizardPage (parent)
Expand All @@ -45,9 +40,12 @@ AddBackupWizardPage1::AddBackupWizardPage1(QWidget* parent)
layout->addWidget(widget);
setLayout(layout);

connect (m_view->btnRefresh, SIGNAL(clicked()), this, SLOT(slotRefresh()));
connect (m_view->devicesWidget, SIGNAL(itemSelectionChanged()), this, SLOT(slotDeviceItemSelectionChanged()));
populateDeviceView();
m_deviceWidget = new DeviceWidget(this);

connect (m_view->btnRefresh, SIGNAL(clicked()),
m_deviceWidget, SLOT(slotRefresh()));
connect (m_deviceWidget, SIGNAL(itemSelectionChanged()),
this, SLOT(slotDeviceItemSelectionChanged()));

// this item is used just for accessing the selected UDI from other pages
m_view->selectedUDI->hide();
Expand All @@ -60,54 +58,12 @@ AddBackupWizardPage1::~AddBackupWizardPage1()
}

void AddBackupWizardPage1::slotRefresh() {
populateDeviceView();
}

void AddBackupWizardPage1::populateDeviceView()
{
m_view->devicesWidget->clear();

QList<QTreeWidgetItem *> items;
foreach (const Solid::Device &device, Solid::Device::listFromType(Solid::DeviceInterface::StorageDrive, QString()))
{
Solid::StorageDrive* storage = (Solid::StorageDrive*) device.asDeviceInterface(Solid::DeviceInterface::StorageDrive);
if ((storage->driveType() == Solid::StorageDrive::HardDisk) && ((storage->bus() == Solid::StorageDrive::Usb) || (storage->bus() == Solid::StorageDrive::Ieee1394))) {
QTreeWidgetItem* deviceItem = new QTreeWidgetItem((QTreeWidget*)0, QStringList(device.product()));
items.append(deviceItem);

foreach (const Solid::Device &volumeDevice, Solid::Device::listFromType(Solid::DeviceInterface::StorageVolume, device.udi())) {
Solid::StorageVolume* storage = (Solid::StorageVolume*) volumeDevice.asDeviceInterface(Solid::DeviceInterface::StorageVolume);
QStringList columns;
columns << QString() << storage->fsType();
if (storage->label().isEmpty())
columns << i18n("Undefined");
else
columns << storage->label();

columns << bytesToHuman(storage->size());

// this column is not displayed
columns << volumeDevice.udi();

QTreeWidgetItem* item = new QTreeWidgetItem(deviceItem, columns);

if ((storage->fsType() == "vfat") || (storage->fsType() == "ntfs"))
item->setIcon(1,KIcon("security-low"));
else if (storage->fsType().startsWith("ext"))
item->setIcon(1,KIcon("security-high"));

items.append(item);
}
}
}

m_view->devicesWidget->insertTopLevelItems(0, items);

m_deviceWidget->slotRefresh();
}

bool AddBackupWizardPage1::isComplete () const
{
QList<QTreeWidgetItem*> items = m_view->devicesWidget->selectedItems();
QList<QTreeWidgetItem*> items = m_deviceWidget->selectedItems();
if (items.isEmpty()) {
m_view->selectedUDI->clear();
return false;
Expand Down
6 changes: 4 additions & 2 deletions src/app/addbackupwizardpage1.h
Expand Up @@ -23,6 +23,8 @@

#include <QtGui/QWizardPage>

class DeviceWidget;

namespace Ui {
class AddBackupWizardPage1View;
}
Expand All @@ -45,9 +47,9 @@ class AddBackupWizardPage1 : public QWizardPage
void completeChanged();

private:
void populateDeviceView();

Ui::AddBackupWizardPage1View* m_view;

DeviceWidget* m_deviceWidget;
};

#endif // ADDBACKUPWIZARDPAGE1_H
29 changes: 6 additions & 23 deletions src/app/addbackupwizardpage1view.ui
Expand Up @@ -22,30 +22,13 @@
</widget>
</item>
<item>
<widget class="QTreeWidget" name="devicesWidget">
<property name="columnCount">
<number>4</number>
<widget class="QFrame" name="deviceFrame">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<column>
<property name="text">
<string>Device</string>
</property>
</column>
<column>
<property name="text">
<string>File System</string>
</property>
</column>
<column>
<property name="text">
<string>Label</string>
</property>
</column>
<column>
<property name="text">
<string>Size</string>
</property>
</column>
</widget>
</item>
<item>
Expand Down

0 comments on commit 6937ae7

Please sign in to comment.