1
/* BEGIN_COMMON_COPYRIGHT_HEADER
4
* LXQt - The Lightweight Desktop Environment
7
* Copyright: 2012 Razor team
10
* Alexander Sokoloff <sokoloff.a@gmail.com>
12
* This program or library is free software; you can redistribute it
13
* and/or modify it under the terms of the GNU Lesser General Public
14
* License as published by the Free Software Foundation; either
15
* version 2.1 of the License, or (at your option) any later version.
17
* This library is distributed in the hope that it will be useful,
18
* but WITHOUT ANY WARRANTY; without even the implied warranty of
19
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20
* Lesser General Public License for more details.
22
* You should have received a copy of the GNU Lesser General
23
* Public License along with this library; if not, write to the
24
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
25
* Boston, MA 02110-1301 USA
27
* END_COMMON_COPYRIGHT_HEADER */
30
#include "providers.h"
31
#include <QtCore/QDebug>
35
MountDevice::MountDevice():
44
QString MountDevice::sizeToString(qulonglong size)
47
n = size / (1024.0 * 1024 * 1024);
49
return QObject::tr("%1 GB").arg(n, 0, 'f', 1);
51
n = size / (1024.0 * 1024);
53
return QObject::tr("%1 MB").arg(n, 0, 'f', 1);
57
return QObject::tr("%1 kB").arg(n, 0, 'f', 1);
59
return QObject::tr("%1 B").arg(size);
63
MountManager::MountManager(QObject *parent):
67
mProvider = new UDisks2Provider(this);
68
if (!mProvider->isValid())
73
mProvider = new UDiskProvider(this);
74
if (!mProvider->isValid())
87
connect(mProvider, SIGNAL(deviceAdded(LxQt::MountDevice*)),
88
this, SIGNAL(deviceAdded(LxQt::MountDevice*)));
90
connect(mProvider, SIGNAL(deviceChanged(LxQt::MountDevice*)),
91
this, SIGNAL(deviceChanged(LxQt::MountDevice*)));
93
connect(mProvider, SIGNAL(deviceRemoved(LxQt::MountDevice*)),
94
this, SIGNAL(deviceRemoved(LxQt::MountDevice*)));
98
MountManager::~MountManager()
104
void MountManager::update()
109
qDebug() << "MountDeviceList MountManager::update() no valid provider in use";
114
const MountDeviceList MountManager::devices() const
118
//qDebug() << "MountManager::devices" << mProvider->devices();
119
return mProvider->devices();
123
qWarning() << "MountDeviceList MountManager::devices() no valid provider in use";
124
return MountDeviceList();
130
QDebug operator<<(QDebug dbg, const LxQt::MountDevice &device)
132
dbg << device.devFile();
134
switch (device.mediaType())
136
case LxQt::MountDevice::MediaTypeUnknown: dbg<<"Type: MediaTypeUnknown"; break;
137
case LxQt::MountDevice::MediaTypeDrive: dbg<<"Type: MediaTypeDrive"; break;
138
case LxQt::MountDevice::MediaTypePartition: dbg<<"Type: MediaTypePartition";break;
139
case LxQt::MountDevice::MediaTypeFdd: dbg<<"Type: MediaTypeFdd"; break;
140
case LxQt::MountDevice::MediaTypeOptical: dbg<<"Type: MediaTypeOptical"; break;
141
default: dbg<<"Type: "<<device.mediaType();break;
143
dbg << "Label: " << device.label();
144
dbg << "Mount path:" << device.mountPath();
149
QDebug operator<<(QDebug dbg, const LxQt::MountDevice *device)
151
return operator<<(dbg, *device);