2015-06-04 01:29:22 +01:00
|
|
|
/*************************************************************************
|
|
|
|
* Copyright (C) 2008 by Volker Lanz <vl@fidra.de> *
|
|
|
|
* *
|
|
|
|
* This program is free software; you can redistribute it and/or *
|
|
|
|
* modify it under the terms of the GNU General Public License as *
|
|
|
|
* published by the Free Software Foundation; either version 3 of *
|
|
|
|
* the License, or (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* This program is distributed in the hope that it will be useful, *
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
* GNU General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU General Public License *
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.*
|
|
|
|
*************************************************************************/
|
|
|
|
|
2017-09-10 20:12:52 +01:00
|
|
|
#if !defined(KPMCORE_OPERATIONSTACK_H)
|
2015-06-04 01:29:22 +01:00
|
|
|
|
2017-09-10 20:12:52 +01:00
|
|
|
#define KPMCORE_OPERATIONSTACK_H
|
2015-06-04 01:29:22 +01:00
|
|
|
|
2016-05-06 22:36:24 +01:00
|
|
|
#include "util/libpartitionmanagerexport.h"
|
2015-06-04 01:29:22 +01:00
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
#include <QList>
|
|
|
|
#include <QReadWriteLock>
|
|
|
|
|
2016-04-18 17:14:31 +01:00
|
|
|
#include <QtGlobal>
|
2015-06-04 01:29:22 +01:00
|
|
|
|
|
|
|
class Device;
|
|
|
|
class Partition;
|
|
|
|
class Operation;
|
|
|
|
class DeviceScanner;
|
|
|
|
|
|
|
|
/** The list of Operations the user wants to have performed.
|
|
|
|
|
2015-07-13 15:16:36 +01:00
|
|
|
OperationStack also handles the Devices that were found on this computer and the merging of
|
|
|
|
Operations, e.g., when the user first creates a Partition, then deletes it.
|
2015-06-04 01:29:22 +01:00
|
|
|
|
2015-07-13 15:16:36 +01:00
|
|
|
@author Volker Lanz <vl@fidra.de>
|
2015-06-04 01:29:22 +01:00
|
|
|
*/
|
|
|
|
class LIBKPMCORE_EXPORT OperationStack : public QObject
|
|
|
|
{
|
2015-07-13 15:16:36 +01:00
|
|
|
Q_OBJECT
|
|
|
|
Q_DISABLE_COPY(OperationStack)
|
|
|
|
|
|
|
|
friend class DeviceScanner;
|
|
|
|
|
|
|
|
public:
|
|
|
|
typedef QList<Device*> Devices;
|
|
|
|
typedef QList<Operation*> Operations;
|
|
|
|
|
|
|
|
public:
|
2015-07-22 14:48:03 +01:00
|
|
|
OperationStack(QObject* parent = nullptr);
|
2015-07-13 15:16:36 +01:00
|
|
|
~OperationStack();
|
|
|
|
|
|
|
|
Q_SIGNALS:
|
|
|
|
void operationsChanged();
|
|
|
|
void devicesChanged();
|
|
|
|
|
|
|
|
public:
|
|
|
|
void push(Operation* o);
|
|
|
|
void pop();
|
2016-05-18 14:56:13 +01:00
|
|
|
bool contains(const Partition* p) const;
|
2015-07-13 15:16:36 +01:00
|
|
|
void clearOperations();
|
|
|
|
int size() const {
|
|
|
|
return operations().size(); /**< @return number of operations */
|
|
|
|
}
|
|
|
|
|
|
|
|
Devices& previewDevices() {
|
|
|
|
return m_PreviewDevices; /**< @return the list of Devices */
|
|
|
|
}
|
|
|
|
const Devices& previewDevices() const {
|
|
|
|
return m_PreviewDevices; /**< @return the list of Devices */
|
|
|
|
}
|
|
|
|
|
|
|
|
Operations& operations() {
|
|
|
|
return m_Operations; /**< @return the list of operations */
|
|
|
|
}
|
|
|
|
const Operations& operations() const {
|
|
|
|
return m_Operations; /**< @return the list of operations */
|
|
|
|
}
|
|
|
|
|
2016-08-08 22:33:17 +01:00
|
|
|
Device* findDeviceForPartition(const Partition* p);
|
2015-07-13 15:16:36 +01:00
|
|
|
|
|
|
|
QReadWriteLock& lock() {
|
|
|
|
return m_Lock;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void clearDevices();
|
|
|
|
void addDevice(Device* d);
|
|
|
|
void sortDevices();
|
|
|
|
|
|
|
|
bool mergeNewOperation(Operation*& currentOp, Operation*& pushedOp);
|
|
|
|
bool mergeCopyOperation(Operation*& currentOp, Operation*& pushedOp);
|
|
|
|
bool mergeRestoreOperation(Operation*& currentOp, Operation*& pushedOp);
|
|
|
|
bool mergePartFlagsOperation(Operation*& currentOp, Operation*& pushedOp);
|
|
|
|
bool mergePartLabelOperation(Operation*& currentOp, Operation*& pushedOp);
|
|
|
|
bool mergeCreatePartitionTableOperation(Operation*& currentOp, Operation*& pushedOp);
|
2016-11-07 18:56:26 +00:00
|
|
|
bool mergeResizeVolumeGroupResizeOperation(Operation*& pushedOp);
|
2015-07-13 15:16:36 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
Operations m_Operations;
|
|
|
|
mutable Devices m_PreviewDevices;
|
|
|
|
QReadWriteLock m_Lock;
|
2015-06-04 01:29:22 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|