Skip to content

Commit

Permalink
transformed a class method into a generic function
Browse files Browse the repository at this point in the history
  • Loading branch information
Flavio Castelli committed Nov 6, 2009
1 parent 72e71f9 commit 3fc7e5d
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 16 deletions.
14 changes: 1 addition & 13 deletions src/app/devicewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ void DeviceWidget::slotRefresh()

foreach (const Device &device, Device::listFromType(DeviceInterface::StorageDrive, QString()))
{
StorageDrive* storage = (StorageDrive*) device.asDeviceInterface(DeviceInterface::StorageDrive);
if (isStorageDeviceValid(storage))
if (isDeviceInteresting(device.udi()))
addDevice(&device);
}
}
Expand All @@ -62,17 +61,6 @@ void DeviceWidget::slotDeviceRemoved(QString udi)
slotRefresh();
}

bool DeviceWidget::isStorageDeviceValid(StorageDrive* storage)
{
if (storage == 0) {
return false;
} else {
return (storage->driveType() == StorageDrive::HardDisk) &&
((storage->bus() == StorageDrive::Usb) ||
(storage->bus() == StorageDrive::Ieee1394));
}
}

void DeviceWidget::slotCurrentItemChanged(QTreeWidgetItem* curr,QTreeWidgetItem* prev)
{
Q_UNUSED(prev)
Expand Down
2 changes: 0 additions & 2 deletions src/app/devicewidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

namespace Solid {
class Device;
class StorageDrive;
}

class DeviceWidget : public QWidget, private Ui::DeviceWidget {
Expand All @@ -25,7 +24,6 @@ class DeviceWidget : public QWidget, private Ui::DeviceWidget {
void slotItemSelectionChanged();

private:
bool isStorageDeviceValid(Solid::StorageDrive* storage);
void addDevice(const Solid::Device* device);

signals:
Expand Down
22 changes: 22 additions & 0 deletions src/utils/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@
#include <QtCore/QMap>
#include <QtNetwork/QHostInfo>

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

using namespace Solid;

const QString bytesToHuman(qulonglong bytes)
{
QString size;
Expand Down Expand Up @@ -218,3 +227,16 @@ const QStringList findBackupDirectoriesToDelete(const QStringList& dirs)
return directoriesToRemove;
}

bool isDeviceInteresting(const QString& udi)
{
Device device (udi);
StorageDrive* storage = (StorageDrive*) device.asDeviceInterface(DeviceInterface::StorageDrive);
if (storage == 0) {
return false;
} else {
return (storage->driveType() == StorageDrive::HardDisk) &&
((storage->bus() == StorageDrive::Usb) ||
(storage->bus() == StorageDrive::Ieee1394));
}
}

9 changes: 8 additions & 1 deletion src/utils/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,19 @@ const QString calculateBackupDestination(const QString& mount, const QString& re
const QString calculateBackupDestination(const QString& mount);

/*!
Function used for finding the old backup directories to remove.
Function used to find the old backup directories to remove.
Kaveau keeps:
\li hourly backups for the past 24 hours
\li daily backups for the past month
\li weekly backups until the external disk is full
*/
const QStringList findBackupDirectoriesToDelete(const QStringList& dirs);


/*!
Function used to check if a certain device can be used by kaveau.
\param udi the udi of the device to check
*/
bool isDeviceInteresting(const QString& udi);

#endif // COMMON_H

0 comments on commit 3fc7e5d

Please sign in to comment.