d-pointerize FileSystem class.
This commit is contained in:
parent
17c8772240
commit
2e5f0fbcb2
|
@ -1,7 +1,7 @@
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
* Copyright (C) 2012 by Volker Lanz <vl@fidra.de> *
|
* Copyright (C) 2012 by Volker Lanz <vl@fidra.de> *
|
||||||
* Copyright (C) 2015 by Teo Mrnjavac <teo@kde.org> *
|
* Copyright (C) 2015 by Teo Mrnjavac <teo@kde.org> *
|
||||||
* Copyright (C) 2016 by Andrius Štikonas <andrius@stikonas.eu> *
|
* Copyright (C) 2016-2018 by Andrius Štikonas <andrius@stikonas.eu> *
|
||||||
* *
|
* *
|
||||||
* This program is free software; you can redistribute it and/or *
|
* This program is free software; you can redistribute it and/or *
|
||||||
* modify it under the terms of the GNU General Public License as *
|
* modify it under the terms of the GNU General Public License as *
|
||||||
|
@ -72,21 +72,35 @@ const std::vector<QColor> FileSystem::defaultColorCode =
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct FileSystemPrivate {
|
||||||
|
FileSystem::Type m_Type;
|
||||||
|
qint64 m_FirstSector;
|
||||||
|
qint64 m_LastSector;
|
||||||
|
qint64 m_SectorSize;
|
||||||
|
qint64 m_SectorsUsed;
|
||||||
|
QString m_Label;
|
||||||
|
QString m_UUID;
|
||||||
|
};
|
||||||
|
|
||||||
/** Creates a new FileSystem object
|
/** Creates a new FileSystem object
|
||||||
@param firstsector the first sector used by this FileSystem on the Device
|
@param firstsector the first sector used by this FileSystem on the Device
|
||||||
@param lastsector the last sector used by this FileSystem on the Device
|
@param lastsector the last sector used by this FileSystem on the Device
|
||||||
@param sectorsused the number of sectors in use on the FileSystem
|
@param sectorsused the number of sectors in use on the FileSystem
|
||||||
@param l the FileSystem label
|
@param label the FileSystem label
|
||||||
@param t the FileSystem type
|
@param type the FileSystem type
|
||||||
*/
|
*/
|
||||||
FileSystem::FileSystem(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& l, FileSystem::Type t) :
|
FileSystem::FileSystem(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, FileSystem::Type type) :
|
||||||
m_Type(t),
|
d(std::make_unique<FileSystemPrivate>())
|
||||||
m_FirstSector(firstsector),
|
{
|
||||||
m_LastSector(lastsector),
|
d->m_Type = type;
|
||||||
m_SectorsUsed(sectorsused),
|
d->m_FirstSector = firstsector;
|
||||||
m_Label(l),
|
d->m_LastSector = lastsector;
|
||||||
m_UUID()
|
d->m_SectorsUsed = sectorsused;
|
||||||
|
d->m_Label = label;
|
||||||
|
d->m_UUID = QString();
|
||||||
|
}
|
||||||
|
|
||||||
|
FileSystem::~FileSystem()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -392,6 +406,11 @@ QString FileSystem::name(const QStringList& languages) const
|
||||||
return nameForType(type(), languages);
|
return nameForType(type(), languages);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FileSystem::Type FileSystem::type() const
|
||||||
|
{
|
||||||
|
return d->m_Type;
|
||||||
|
}
|
||||||
|
|
||||||
/** @return a pointer to a QString C array with all FileSystem names */
|
/** @return a pointer to a QString C array with all FileSystem names */
|
||||||
static const KLocalizedString* typeNames()
|
static const KLocalizedString* typeNames()
|
||||||
{
|
{
|
||||||
|
@ -530,6 +549,16 @@ bool FileSystem::unmount(Report& report, const QString& deviceNode)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qint64 FileSystem::firstSector() const
|
||||||
|
{
|
||||||
|
return d->m_FirstSector;
|
||||||
|
}
|
||||||
|
|
||||||
|
qint64 FileSystem::lastSector() const
|
||||||
|
{
|
||||||
|
return d->m_LastSector;
|
||||||
|
}
|
||||||
|
|
||||||
bool FileSystem::findExternal(const QString& cmdName, const QStringList& args, int expectedCode)
|
bool FileSystem::findExternal(const QString& cmdName, const QStringList& args, int expectedCode)
|
||||||
{
|
{
|
||||||
QString cmdFullPath = QStandardPaths::findExecutable(cmdName);
|
QString cmdFullPath = QStandardPaths::findExecutable(cmdName);
|
||||||
|
@ -552,3 +581,53 @@ FileSystem::SupportTool FileSystem::supportToolName() const
|
||||||
{
|
{
|
||||||
return SupportTool();
|
return SupportTool();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FileSystem::setFirstSector(qint64 s)
|
||||||
|
{
|
||||||
|
d->m_FirstSector = s;
|
||||||
|
}
|
||||||
|
|
||||||
|
void FileSystem::setLastSector(qint64 s)
|
||||||
|
{
|
||||||
|
d->m_LastSector = s;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QString& FileSystem::label() const
|
||||||
|
{
|
||||||
|
return d->m_Label;
|
||||||
|
}
|
||||||
|
|
||||||
|
qint64 FileSystem::sectorSize() const
|
||||||
|
{
|
||||||
|
return d->m_SectorSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
qint64 FileSystem::sectorsUsed() const
|
||||||
|
{
|
||||||
|
return d->m_SectorsUsed;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QString& FileSystem::uuid() const
|
||||||
|
{
|
||||||
|
return d->m_UUID;
|
||||||
|
}
|
||||||
|
|
||||||
|
void FileSystem::setSectorSize(qint64 s)
|
||||||
|
{
|
||||||
|
d->m_SectorSize = s;
|
||||||
|
}
|
||||||
|
|
||||||
|
void FileSystem::setSectorsUsed(qint64 s)
|
||||||
|
{
|
||||||
|
d->m_SectorsUsed = s;
|
||||||
|
}
|
||||||
|
|
||||||
|
void FileSystem::setLabel(const QString& s)
|
||||||
|
{
|
||||||
|
d->m_Label = s;
|
||||||
|
}
|
||||||
|
|
||||||
|
void FileSystem::setUUID(const QString& s)
|
||||||
|
{
|
||||||
|
d->m_UUID = s;
|
||||||
|
}
|
||||||
|
|
|
@ -28,12 +28,14 @@
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
class QColor;
|
class QColor;
|
||||||
class QValidator;
|
class QValidator;
|
||||||
class Device;
|
class Device;
|
||||||
class Report;
|
class Report;
|
||||||
|
struct FileSystemPrivate;
|
||||||
|
|
||||||
/** Base class for all FileSystems.
|
/** Base class for all FileSystems.
|
||||||
|
|
||||||
|
@ -106,10 +108,10 @@ public:
|
||||||
Q_DECLARE_FLAGS(CommandSupportTypes, CommandSupportType)
|
Q_DECLARE_FLAGS(CommandSupportTypes, CommandSupportType)
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
FileSystem(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, FileSystem::Type t);
|
FileSystem(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, FileSystem::Type type);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual ~FileSystem() {}
|
virtual ~FileSystem();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual void init() {}
|
virtual void init() {}
|
||||||
|
@ -196,9 +198,11 @@ public:
|
||||||
* @see nameForType()
|
* @see nameForType()
|
||||||
*/
|
*/
|
||||||
virtual QString name(const QStringList& languages = {}) const;
|
virtual QString name(const QStringList& languages = {}) const;
|
||||||
virtual FileSystem::Type type() const {
|
|
||||||
return m_Type; /**< @return the FileSystem's type */
|
/**
|
||||||
}
|
* @return the FileSystem's type
|
||||||
|
*/
|
||||||
|
virtual FileSystem::Type type() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the name of the given filesystem type. If @p languages
|
* Returns the name of the given filesystem type. If @p languages
|
||||||
|
@ -228,12 +232,12 @@ public:
|
||||||
virtual bool mount(Report& report, const QString& deviceNode, const QString& mountPoint);
|
virtual bool mount(Report& report, const QString& deviceNode, const QString& mountPoint);
|
||||||
virtual bool unmount(Report& report, const QString& deviceNode);
|
virtual bool unmount(Report& report, const QString& deviceNode);
|
||||||
|
|
||||||
qint64 firstSector() const {
|
/**< @return the FileSystem's first sector */
|
||||||
return m_FirstSector; /**< @return the FileSystem's first sector */
|
qint64 firstSector() const;
|
||||||
}
|
|
||||||
qint64 lastSector() const {
|
/**< @return the FileSystem's last sector */
|
||||||
return m_LastSector; /**< @return the FileSystem's last sector */
|
qint64 lastSector() const;
|
||||||
}
|
|
||||||
qint64 length() const {
|
qint64 length() const {
|
||||||
return lastSector() - firstSector() + 1; /**< @return the FileSystem's length */
|
return lastSector() - firstSector() + 1; /**< @return the FileSystem's length */
|
||||||
}
|
}
|
||||||
|
@ -244,52 +248,42 @@ public:
|
||||||
return firstByte() + length() * sectorSize() - 1; /**< @return the FileSystem's last byte */
|
return firstByte() + length() * sectorSize() - 1; /**< @return the FileSystem's last byte */
|
||||||
}
|
}
|
||||||
|
|
||||||
void setFirstSector(qint64 s) {
|
/**< @param s the new first sector */
|
||||||
m_FirstSector = s; /**< @param s the new first sector */
|
void setFirstSector(qint64 s);
|
||||||
}
|
|
||||||
void setLastSector(qint64 s) {
|
/**< @param s the new last sector */
|
||||||
m_LastSector = s; /**< @param s the new last sector */
|
void setLastSector(qint64 s);
|
||||||
}
|
|
||||||
|
|
||||||
void move(qint64 newStartSector);
|
void move(qint64 newStartSector);
|
||||||
|
|
||||||
const QString& label() const {
|
/**< @return the FileSystem's label */
|
||||||
return m_Label; /**< @return the FileSystem's label */
|
const QString& label() const;
|
||||||
}
|
|
||||||
qint64 sectorSize() const {
|
|
||||||
return m_SectorSize; /**< @return the sector size in the underlying Device */
|
|
||||||
}
|
|
||||||
qint64 sectorsUsed() const {
|
|
||||||
return m_SectorsUsed; /**< @return the sectors in use on the FileSystem */
|
|
||||||
}
|
|
||||||
const QString& uuid() const {
|
|
||||||
return m_UUID; /**< @return the FileSystem's UUID */
|
|
||||||
}
|
|
||||||
|
|
||||||
void setSectorSize(qint64 s) {
|
/**< @return the sector size in the underlying Device */
|
||||||
m_SectorSize = s; /**< @param s the new value for sector size */
|
qint64 sectorSize() const;
|
||||||
}
|
|
||||||
void setSectorsUsed(qint64 s) {
|
/**< @return the sectors in use on the FileSystem */
|
||||||
m_SectorsUsed = s; /**< @param s the new value for sectors in use */
|
qint64 sectorsUsed() const;
|
||||||
}
|
|
||||||
void setLabel(const QString& s) {
|
/**< @return the FileSystem's UUID */
|
||||||
m_Label = s; /**< @param s the new label */
|
const QString& uuid() const;
|
||||||
}
|
|
||||||
void setUUID(const QString& s) {
|
/**< @param s the new value for sector size */
|
||||||
m_UUID = s; /**< @param s the new UUID */
|
void setSectorSize(qint64 s);
|
||||||
}
|
|
||||||
|
/**< @param s the new value for sectors in use */
|
||||||
|
void setSectorsUsed(qint64 s);
|
||||||
|
|
||||||
|
/**< @param s the new label */
|
||||||
|
void setLabel(const QString& s);
|
||||||
|
|
||||||
|
/**< @param s the new UUID */
|
||||||
|
void setUUID(const QString& s);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static bool findExternal(const QString& cmdName, const QStringList& args = QStringList(), int exptectedCode = 1);
|
static bool findExternal(const QString& cmdName, const QStringList& args = QStringList(), int exptectedCode = 1);
|
||||||
|
|
||||||
protected:
|
std::unique_ptr<FileSystemPrivate> d;
|
||||||
FileSystem::Type m_Type;
|
|
||||||
qint64 m_FirstSector;
|
|
||||||
qint64 m_LastSector;
|
|
||||||
qint64 m_SectorSize;
|
|
||||||
qint64 m_SectorsUsed;
|
|
||||||
QString m_Label;
|
|
||||||
QString m_UUID;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Q_DECLARE_OPERATORS_FOR_FLAGS(FileSystem::CommandSupportTypes)
|
Q_DECLARE_OPERATORS_FOR_FLAGS(FileSystem::CommandSupportTypes)
|
||||||
|
|
Loading…
Reference in New Issue