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) 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 *
|
||||
* 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
|
||||
@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 sectorsused the number of sectors in use on the FileSystem
|
||||
@param l the FileSystem label
|
||||
@param t the FileSystem type
|
||||
@param label the FileSystem label
|
||||
@param type the FileSystem type
|
||||
*/
|
||||
FileSystem::FileSystem(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& l, FileSystem::Type t) :
|
||||
m_Type(t),
|
||||
m_FirstSector(firstsector),
|
||||
m_LastSector(lastsector),
|
||||
m_SectorsUsed(sectorsused),
|
||||
m_Label(l),
|
||||
m_UUID()
|
||||
FileSystem::FileSystem(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, FileSystem::Type type) :
|
||||
d(std::make_unique<FileSystemPrivate>())
|
||||
{
|
||||
d->m_Type = type;
|
||||
d->m_FirstSector = firstsector;
|
||||
d->m_LastSector = lastsector;
|
||||
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);
|
||||
}
|
||||
|
||||
FileSystem::Type FileSystem::type() const
|
||||
{
|
||||
return d->m_Type;
|
||||
}
|
||||
|
||||
/** @return a pointer to a QString C array with all FileSystem names */
|
||||
static const KLocalizedString* typeNames()
|
||||
{
|
||||
|
@ -530,6 +549,16 @@ bool FileSystem::unmount(Report& report, const QString& deviceNode)
|
|||
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)
|
||||
{
|
||||
QString cmdFullPath = QStandardPaths::findExecutable(cmdName);
|
||||
|
@ -552,3 +581,53 @@ FileSystem::SupportTool FileSystem::supportToolName() const
|
|||
{
|
||||
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 <QUrl>
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
class QColor;
|
||||
class QValidator;
|
||||
class Device;
|
||||
class Report;
|
||||
struct FileSystemPrivate;
|
||||
|
||||
/** Base class for all FileSystems.
|
||||
|
||||
|
@ -106,10 +108,10 @@ public:
|
|||
Q_DECLARE_FLAGS(CommandSupportTypes, CommandSupportType)
|
||||
|
||||
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:
|
||||
virtual ~FileSystem() {}
|
||||
virtual ~FileSystem();
|
||||
|
||||
public:
|
||||
virtual void init() {}
|
||||
|
@ -196,9 +198,11 @@ public:
|
|||
* @see nameForType()
|
||||
*/
|
||||
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
|
||||
|
@ -228,12 +232,12 @@ public:
|
|||
virtual bool mount(Report& report, const QString& deviceNode, const QString& mountPoint);
|
||||
virtual bool unmount(Report& report, const QString& deviceNode);
|
||||
|
||||
qint64 firstSector() const {
|
||||
return m_FirstSector; /**< @return the FileSystem's first sector */
|
||||
}
|
||||
qint64 lastSector() const {
|
||||
return m_LastSector; /**< @return the FileSystem's last sector */
|
||||
}
|
||||
/**< @return the FileSystem's first sector */
|
||||
qint64 firstSector() const;
|
||||
|
||||
/**< @return the FileSystem's last sector */
|
||||
qint64 lastSector() const;
|
||||
|
||||
qint64 length() const {
|
||||
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 */
|
||||
}
|
||||
|
||||
void setFirstSector(qint64 s) {
|
||||
m_FirstSector = s; /**< @param s the new first sector */
|
||||
}
|
||||
void setLastSector(qint64 s) {
|
||||
m_LastSector = s; /**< @param s the new last sector */
|
||||
}
|
||||
/**< @param s the new first sector */
|
||||
void setFirstSector(qint64 s);
|
||||
|
||||
/**< @param s the new last sector */
|
||||
void setLastSector(qint64 s);
|
||||
|
||||
void move(qint64 newStartSector);
|
||||
|
||||
const QString& label() const {
|
||||
return m_Label; /**< @return the FileSystem's label */
|
||||
}
|
||||
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 */
|
||||
}
|
||||
/**< @return the FileSystem's label */
|
||||
const QString& label() const;
|
||||
|
||||
void setSectorSize(qint64 s) {
|
||||
m_SectorSize = s; /**< @param s the new value for sector size */
|
||||
}
|
||||
void setSectorsUsed(qint64 s) {
|
||||
m_SectorsUsed = s; /**< @param s the new value for sectors in use */
|
||||
}
|
||||
void setLabel(const QString& s) {
|
||||
m_Label = s; /**< @param s the new label */
|
||||
}
|
||||
void setUUID(const QString& s) {
|
||||
m_UUID = s; /**< @param s the new UUID */
|
||||
}
|
||||
/**< @return the sector size in the underlying Device */
|
||||
qint64 sectorSize() const;
|
||||
|
||||
/**< @return the sectors in use on the FileSystem */
|
||||
qint64 sectorsUsed() const;
|
||||
|
||||
/**< @return the FileSystem's UUID */
|
||||
const QString& uuid() const;
|
||||
|
||||
/**< @param s the new value for sector size */
|
||||
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:
|
||||
static bool findExternal(const QString& cmdName, const QStringList& args = QStringList(), int exptectedCode = 1);
|
||||
|
||||
protected:
|
||||
FileSystem::Type m_Type;
|
||||
qint64 m_FirstSector;
|
||||
qint64 m_LastSector;
|
||||
qint64 m_SectorSize;
|
||||
qint64 m_SectorsUsed;
|
||||
QString m_Label;
|
||||
QString m_UUID;
|
||||
std::unique_ptr<FileSystemPrivate> d;
|
||||
};
|
||||
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS(FileSystem::CommandSupportTypes)
|
||||
|
|
Loading…
Reference in New Issue