Port away from KDiskFreeSpaceInfo to QStorageInfo.
This commit is contained in:
parent
1889b9e8fa
commit
2404689dd0
|
@ -34,7 +34,7 @@ set (pmlibpartedbackendplugin_SRCS
|
||||||
|
|
||||||
add_library(pmlibpartedbackendplugin SHARED ${pmlibpartedbackendplugin_SRCS})
|
add_library(pmlibpartedbackendplugin SHARED ${pmlibpartedbackendplugin_SRCS})
|
||||||
|
|
||||||
target_link_libraries(pmlibpartedbackendplugin kpmcore ${LIBPARTED_LIBS} KF5::KIOCore KF5::I18n)
|
target_link_libraries(pmlibpartedbackendplugin kpmcore ${LIBPARTED_LIBS} KF5::I18n)
|
||||||
|
|
||||||
install(TARGETS pmlibpartedbackendplugin DESTINATION ${KDE_INSTALL_PLUGINDIR})
|
install(TARGETS pmlibpartedbackendplugin DESTINATION ${KDE_INSTALL_PLUGINDIR})
|
||||||
kcoreaddons_desktop_to_json(pmlibpartedbackendplugin pmlibpartedbackendplugin.desktop DEFAULT_SERVICE_TYPE)
|
kcoreaddons_desktop_to_json(pmlibpartedbackendplugin pmlibpartedbackendplugin.desktop DEFAULT_SERVICE_TYPE)
|
||||||
|
|
|
@ -49,11 +49,11 @@
|
||||||
#include <QJsonArray>
|
#include <QJsonArray>
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
|
#include <QStorageInfo>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
|
||||||
#include <KLocalizedString>
|
#include <KLocalizedString>
|
||||||
#include <KDiskFreeSpaceInfo>
|
|
||||||
#include <KPluginFactory>
|
#include <KPluginFactory>
|
||||||
|
|
||||||
#include <parted/parted.h>
|
#include <parted/parted.h>
|
||||||
|
@ -198,11 +198,9 @@ static qint64 readSectorsUsedLibParted(PedDisk* pedDisk, const Partition& p)
|
||||||
static void readSectorsUsed(PedDisk* pedDisk, const Device& d, Partition& p, const QString& mountPoint)
|
static void readSectorsUsed(PedDisk* pedDisk, const Device& d, Partition& p, const QString& mountPoint)
|
||||||
{
|
{
|
||||||
if (!mountPoint.isEmpty() && p.fileSystem().type() != FileSystem::LinuxSwap && p.fileSystem().type() != FileSystem::Lvm2_PV) {
|
if (!mountPoint.isEmpty() && p.fileSystem().type() != FileSystem::LinuxSwap && p.fileSystem().type() != FileSystem::Lvm2_PV) {
|
||||||
const KDiskFreeSpaceInfo freeSpaceInfo = KDiskFreeSpaceInfo::freeSpaceInfo(mountPoint);
|
const QStorageInfo storage = QStorageInfo(mountPoint);
|
||||||
|
if (p.isMounted() && storage.isValid())
|
||||||
// KDiskFreeSpaceInfo does not work with swap
|
p.fileSystem().setSectorsUsed( (storage.bytesTotal() - storage.bytesFree()) / d.logicalSize());
|
||||||
if (p.isMounted() && freeSpaceInfo.isValid())
|
|
||||||
p.fileSystem().setSectorsUsed(freeSpaceInfo.used() / d.logicalSize());
|
|
||||||
}
|
}
|
||||||
else if (p.fileSystem().supportGetUsed() == FileSystem::cmdSupportFileSystem)
|
else if (p.fileSystem().supportGetUsed() == FileSystem::cmdSupportFileSystem)
|
||||||
p.fileSystem().setSectorsUsed(p.fileSystem().readUsedCapacity(p.deviceNode()) / d.logicalSize());
|
p.fileSystem().setSectorsUsed(p.fileSystem().readUsedCapacity(p.deviceNode()) / d.logicalSize());
|
||||||
|
|
Loading…
Reference in New Issue