d-pointerize Operation class.

This commit is contained in:
Andrius Štikonas 2018-04-11 03:52:46 +03:00
parent 9cc583e7d5
commit db40442744
3 changed files with 52 additions and 30 deletions

View File

@ -54,8 +54,8 @@ Device::Device(std::shared_ptr<DevicePrivate> d_ptr,
*/ */
Device::Device(const Device& other) Device::Device(const Device& other)
: QObject() : QObject()
, d(std::make_shared<DevicePrivate>())
{ {
d = std::make_shared<DevicePrivate>();
d->m_Name = other.d->m_Name; d->m_Name = other.d->m_Name;
d->m_DeviceNode = other.d->m_DeviceNode; d->m_DeviceNode = other.d->m_DeviceNode;
d->m_LogicalSectorSize = other.d->m_LogicalSectorSize; d->m_LogicalSectorSize = other.d->m_LogicalSectorSize;

View File

@ -16,7 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.* * along with this program. If not, see <http://www.gnu.org/licenses/>.*
*************************************************************************/ *************************************************************************/
#include "ops/operation.h" #include "ops/operation_p.h"
#include "core/partition.h" #include "core/partition.h"
#include "core/device.h" #include "core/device.h"
@ -32,10 +32,10 @@
#include <KLocalizedString> #include <KLocalizedString>
Operation::Operation() : Operation::Operation() :
m_Status(StatusNone), d(std::make_unique<OperationPrivate>())
m_Jobs(),
m_ProgressBase(0)
{ {
d->m_Status = StatusNone;
d->m_ProgressBase = 0;
} }
Operation::~Operation() Operation::~Operation()
@ -172,3 +172,33 @@ bool Operation::execute(Report& parent)
return rval; return rval;
} }
Operation::OperationStatus Operation::status() const
{
return d->m_Status;
}
void Operation::setStatus(OperationStatus s)
{
d->m_Status = s;
}
QList<Job*>& Operation::jobs()
{
return d->m_Jobs;
}
const QList<Job*>& Operation::jobs() const
{
return d->m_Jobs;
}
void Operation::setProgressBase(qint32 i)
{
d->m_ProgressBase = i;
}
qint32 Operation::progressBase() const
{
return d->m_ProgressBase;
}

View File

@ -1,5 +1,6 @@
/************************************************************************* /*************************************************************************
* Copyright (C) 2008 by Volker Lanz <vl@fidra.de> * * Copyright (C) 2008 by Volker Lanz <vl@fidra.de> *
* Copyright (C) 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 *
@ -15,8 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.* * along with this program. If not, see <http://www.gnu.org/licenses/>.*
*************************************************************************/ *************************************************************************/
#if !defined(KPMCORE_OPERATION_H) #ifndef KPMCORE_OPERATION_H
#define KPMCORE_OPERATION_H #define KPMCORE_OPERATION_H
#include "util/libpartitionmanagerexport.h" #include "util/libpartitionmanagerexport.h"
@ -25,10 +25,13 @@
#include <QList> #include <QList>
#include <QtGlobal> #include <QtGlobal>
#include <memory>
class Partition; class Partition;
class Device; class Device;
class OperationStack;
class Job; class Job;
class OperationPrivate;
class OperationStack;
class OperationRunner; class OperationRunner;
class Report; class Report;
@ -108,17 +111,16 @@ public:
virtual bool targets(const Device&) const = 0; virtual bool targets(const Device&) const = 0;
virtual bool targets(const Partition&) const = 0; virtual bool targets(const Partition&) const = 0;
virtual OperationStatus status() const { /**< @return the current status */
return m_Status; /**< @return the current status */ virtual OperationStatus status() const;
}
virtual QString statusText() const; virtual QString statusText() const;
virtual QString statusIcon() const; virtual QString statusIcon() const;
virtual void setStatus(OperationStatus s) { /**< @param s the new status */
m_Status = s; /**< @param s the new status */ virtual void setStatus(OperationStatus s);
}
LIBKPMCORE_EXPORT qint32 totalProgress() const; qint32 totalProgress() const;
protected: protected:
void onJobStarted(); void onJobStarted();
@ -129,24 +131,14 @@ protected:
void addJob(Job* job); void addJob(Job* job);
QList<Job*>& jobs() { QList<Job*>& jobs();
return m_Jobs; const QList<Job*>& jobs() const;
}
const QList<Job*>& jobs() const {
return m_Jobs;
}
void setProgressBase(qint32 i) { void setProgressBase(qint32 i);
m_ProgressBase = i; qint32 progressBase() const;
}
qint32 progressBase() const {
return m_ProgressBase;
}
private: private:
OperationStatus m_Status; std::unique_ptr<OperationPrivate> d;
QList<Job*> m_Jobs;
qint32 m_ProgressBase;
}; };
#endif #endif