OperationStack

Search for usage in LXR

#include <operationstack.h>

Inheritance diagram for OperationStack:

Public Types

typedef QList< Device * > Devices
 
typedef QList< Operation * > Operations
 

Signals

void devicesChanged ()
 
void operationsChanged ()
 

Public Member Functions

 OperationStack (QObject *parent=nullptr)
 
 ~OperationStack () override
 
void clearOperations ()
 
bool contains (const Partition *p) const
 
DevicefindDeviceForPartition (const Partition *p)
 
QReadWriteLocklock ()
 
Operationsoperations ()
 
const Operationsoperations () const
 
void pop ()
 
DevicespreviewDevices ()
 
const DevicespreviewDevices () const
 
void push (Operation *o)
 
int size () const
 
- Public Member Functions inherited from QObject
 QObject (QObject *parent)
 
bool blockSignals (bool block)
 
const QObjectListchildren () const const
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const const
 
void deleteLater ()
 
void destroyed (QObject *obj)
 
bool disconnect (const char *signal, const QObject *receiver, const char *method) const const
 
bool disconnect (const QObject *receiver, const char *method) const const
 
void dumpObjectInfo ()
 
void dumpObjectInfo () const const
 
void dumpObjectTree ()
 
void dumpObjectTree () const const
 
QList< QByteArraydynamicPropertyNames () const const
 
virtual bool event (QEvent *e)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
findChild (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegExp &regExp, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const
 
bool inherits (const char *className) const const
 
void installEventFilter (QObject *filterObj)
 
bool isWidgetType () const const
 
bool isWindowType () const const
 
void killTimer (int id)
 
virtual const QMetaObjectmetaObject () const const
 
void moveToThread (QThread *targetThread)
 
QString objectName () const const
 
void objectNameChanged (const QString &objectName)
 
QObjectparent () const const
 
QVariant property (const char *name) const const
 
 Q_CLASSINFO (Name, Value)
 
 Q_DISABLE_COPY (Class)
 
 Q_DISABLE_COPY_MOVE (Class)
 
 Q_DISABLE_MOVE (Class)
 
 Q_EMIT Q_EMIT
 
 Q_ENUM (...)
 
 Q_ENUM_NS (...)
 
 Q_ENUMS (...)
 
 Q_FLAG (...)
 
 Q_FLAG_NS (...)
 
 Q_FLAGS (...)
 
 Q_GADGET Q_GADGET
 
 Q_INTERFACES (...)
 
 Q_INVOKABLE Q_INVOKABLE
 
 Q_NAMESPACE Q_NAMESPACE
 
 Q_NAMESPACE_EXPORT (EXPORT_MACRO)
 
 Q_OBJECT Q_OBJECT
 
 Q_PROPERTY (...)
 
 Q_REVISION Q_REVISION
 
 Q_SET_OBJECT_NAME (Object)
 
 Q_SIGNAL Q_SIGNAL
 
 Q_SIGNALS Q_SIGNALS
 
 Q_SLOT Q_SLOT
 
 Q_SLOTS Q_SLOTS
 
qFindChild (const QObject *obj, const QString &name)
 
QList< T > qFindChildren (const QObject *obj, const QRegExp &regExp)
 
QList< T > qFindChildren (const QObject *obj, const QString &name)
 
qobject_cast (QObject *object)
 
qobject_cast (const QObject *object)
 
 QT_NO_NARROWING_CONVERSIONS_IN_CONNECT QT_NO_NARROWING_CONVERSIONS_IN_CONNECT
 
void removeEventFilter (QObject *obj)
 
void setObjectName (const QString &name)
 
void setParent (QObject *parent)
 
bool setProperty (const char *name, const QVariant &value)
 
bool signalsBlocked () const const
 
int startTimer (int interval, Qt::TimerType timerType)
 
int startTimer (std::chrono::milliseconds time, Qt::TimerType timerType)
 
QThreadthread () const const
 

Protected Member Functions

void addDevice (Device *d)
 
void clearDevices ()
 
bool mergeCopyOperation (Operation *&currentOp, Operation *&pushedOp)
 
bool mergeCreatePartitionTableOperation (Operation *&currentOp, Operation *&pushedOp)
 
bool mergeNewOperation (Operation *&currentOp, Operation *&pushedOp)
 
bool mergePartFlagsOperation (Operation *&currentOp, Operation *&pushedOp)
 
bool mergePartLabelOperation (Operation *&currentOp, Operation *&pushedOp)
 
bool mergeResizeVolumeGroupResizeOperation (Operation *&pushedOp)
 
bool mergeRestoreOperation (Operation *&currentOp, Operation *&pushedOp)
 
void sortDevices ()
 
- Protected Member Functions inherited from QObject
virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 
bool isSignalConnected (const QMetaMethod &signal) const const
 
int receivers (const char *signal) const const
 
QObjectsender () const const
 
int senderSignalIndex () const const
 
virtual void timerEvent (QTimerEvent *event)
 

Additional Inherited Members

- Properties inherited from QObject
 objectName
 
- Static Public Member Functions inherited from QObject
QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, Functor functor)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type)
 
bool disconnect (const QMetaObject::Connection &connection)
 
bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)
 
bool disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method)
 
bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
QString tr (const char *sourceText, const char *disambiguation, int n)
 
QString trUtf8 (const char *sourceText, const char *disambiguation, int n)
 
- Public Attributes inherited from QObject
typedef QObjectList
 

Detailed Description

The list of Operations the user wants to have performed.

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.

Author
Volker Lanz [email protected][email protected]dra.[email protected]de

Definition at line 35 of file operationstack.h.

Constructor & Destructor Documentation

OperationStack::OperationStack ( QObject parent = nullptr)
explicit

Constructs a new OperationStack.

Definition at line 40 of file operationstack.cpp.

OperationStack::~OperationStack ( )
override

Destructs an OperationStack, cleaning up Operations and Devices.

Definition at line 49 of file operationstack.cpp.

Member Function Documentation

void OperationStack::addDevice ( Device d)
protected

Adds a Device to the OperationStack.

Parameters
dpointer to the Device to add. Must not be nullptr.

Definition at line 536 of file operationstack.cpp.

void OperationStack::clearDevices ( )
protected

Clears the list of Devices.

Definition at line 497 of file operationstack.cpp.

void OperationStack::clearOperations ( )

Removes all Operations from the OperationStack, calling Operation::undo() on them and deleting them.

Definition at line 484 of file operationstack.cpp.

bool OperationStack::contains ( const Partition p) const

Check whether previous operations involve given partition.

Parameters
pPointer to the Partition. Must not be nullptr.

Definition at line 464 of file operationstack.cpp.

Device * OperationStack::findDeviceForPartition ( const Partition p)

Finds a Device a Partition is on.

Parameters
ppointer to the Partition to find a Device for
Returns
the Device or nullptr if none could be found

Definition at line 510 of file operationstack.cpp.

bool OperationStack::mergeCopyOperation ( Operation *&  currentOp,
Operation *&  pushedOp 
)
protected

Tries to merge an existing CopyOperation with a new Operation pushed on the OperationStack.

These are the cases to consider:

  1. An existing CopyOperation created a Partition that is now being deleted. Remove the CopyOperation, and, if the CopyOperation was an overwrite, carry on with the delete. Else also remove the DeleteOperation.

  2. An existing CopyOperation created a Partition that is now being copied. We're not copying the target of this existing CopyOperation, but its source instead. If this merge is not done, copied partitions will have misleading labels ("copy of sdXY" instead of "copy of copy of sdXY" for a second-generation copy) but the Operation itself will still work.
Parameters
currentOpthe Operation already on the stack to try to merge with
pushedOpthe newly pushed Operation
Returns
true if the OperationStack has been modified in a way that requires merging to stop

Definition at line 218 of file operationstack.cpp.

bool OperationStack::mergeCreatePartitionTableOperation ( Operation *&  currentOp,
Operation *&  pushedOp 
)
protected

Tries to merge an existing CreatePartitionTableOperation with a new Operation pushed on the OperationStack.

If a new partition table is to be created on a device and a previous operation targets that device, remove this previous operation.

Parameters
currentOpthe Operation already on the stack to try to merge with
pushedOpthe newly pushed Operation
Returns
true if the OperationStack has been modified in a way that requires merging to stop

Definition at line 370 of file operationstack.cpp.

bool OperationStack::mergeNewOperation ( Operation *&  currentOp,
Operation *&  pushedOp 
)
protected

Tries to merge an existing NewOperation with a new Operation pushed on the OperationStack.

There are several cases what might need to be done:

  1. An existing operation created a Partition that is now being deleted: In this case, just remove the corresponding NewOperation from the OperationStack.
    This does not work for extended partitions.(#232092)

  2. An existing Operation created a Partition that is now being moved or resized. In this case, remove the original NewOperation and create a new NewOperation with updated start and end sectors. This new NewOperation is appended to the OperationStack.
    This does not work for extended partitions.(#232092)

  3. An existing NewOperation created a Partition that is now being copied. We're not copying but instead creating another new Partition in its place.

  4. The label for a new Partition's FileSystem is modified: Modify in NewOperation and forget it.

  5. File system is changed for a new Partition: Modify in NewOperation and forget it.

  6. A file system on a new Partition is about to be checked: Just delete the CheckOperation, because file systems are checked anyway when they're created. This fixes #275657.
Parameters
currentOpthe Operation already on the stack to try to merge with
pushedOpthe newly pushed Operation
Returns
true if the OperationStack has been modified in a way that requires merging to stop

Definition at line 85 of file operationstack.cpp.

bool OperationStack::mergePartFlagsOperation ( Operation *&  currentOp,
Operation *&  pushedOp 
)
protected

Tries to merge an existing SetPartFlagsOperation with a new Operation pushed on the OperationStack.

If the Partition flags for an existing Partition are modified look if there is an existing Operation for the same Partition and modify that one.

Parameters
currentOpthe Operation already on the stack to try to merge with
pushedOpthe newly pushed Operation
Returns
true if the OperationStack has been modified in a way that requires merging to stop

Definition at line 308 of file operationstack.cpp.

bool OperationStack::mergePartLabelOperation ( Operation *&  currentOp,
Operation *&  pushedOp 
)
protected

Tries to merge an existing SetFileSystemLabelOperation with a new Operation pushed on the OperationStack.

If a FileSystem label for an existing Partition is modified look if there is an existing SetFileSystemLabelOperation for the same Partition.

Parameters
currentOpthe Operation already on the stack to try to merge with
pushedOpthe newly pushed Operation
Returns
true if the OperationStack has been modified in a way that requires merging to stop

Definition at line 339 of file operationstack.cpp.

bool OperationStack::mergeRestoreOperation ( Operation *&  currentOp,
Operation *&  pushedOp 
)
protected

Tries to merge an existing RestoreOperation with a new Operation pushed on the OperationStack.

If an existing RestoreOperation created a Partition that is now being deleted, remove the RestoreOperation, and, if the RestoreOperation was an overwrite, carry on with the delete. Else also remove the DeleteOperation.

Parameters
currentOpthe Operation already on the stack to try to merge with
pushedOpthe newly pushed Operation
Returns
true if the OperationStack has been modified in a way that requires merging to stop

Definition at line 269 of file operationstack.cpp.

Operations& OperationStack::operations ( )
inline

<

Returns
the list of operations

Definition at line 70 of file operationstack.h.

const Operations& OperationStack::operations ( ) const
inline

<

Returns
the list of operations

Definition at line 73 of file operationstack.h.

void OperationStack::pop ( )

Removes the topmost Operation from the OperationStack, calls Operation::undo() on it and deletes it.

Definition at line 452 of file operationstack.cpp.

Devices& OperationStack::previewDevices ( )
inline

<

Returns
the list of Devices

Definition at line 63 of file operationstack.h.

const Devices& OperationStack::previewDevices ( ) const
inline

<

Returns
the list of Devices

Definition at line 66 of file operationstack.h.

void OperationStack::push ( Operation o)

Pushes a new Operation on the OperationStack.

This method will call all methods that try to merge the new Operation with the existing ones. It is not uncommon that any of these will delete the pushed Operation. Callers must not rely on the pushed Operation to exist after calling OperationStack::push().

Parameters
oPointer to the Operation. Must not be nullptr.

Definition at line 412 of file operationstack.cpp.

int OperationStack::size ( ) const
inline

<

Returns
number of operations

Definition at line 59 of file operationstack.h.


The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Sat Jan 22 2022 23:11:11 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.