File indexing completed on 2024-05-05 05:48:52

0001 /*
0002     SPDX-FileCopyrightText: 2008-2010 Volker Lanz <vl@fidra.de>
0003     SPDX-FileCopyrightText: 2014-2016 Andrius Štikonas <andrius@stikonas.eu>
0004     SPDX-FileCopyrightText: 2015 Chris Campbell <c.j.campbell@ed.ac.uk>
0005 
0006     SPDX-License-Identifier: GPL-3.0-or-later
0007 */
0008 
0009 #ifndef KPMCORE_SETFILESYSTEMLABELOPERATION_H
0010 #define KPMCORE_SETFILESYSTEMLABELOPERATION_H
0011 
0012 #include "util/libpartitionmanagerexport.h"
0013 
0014 #include "ops/operation.h"
0015 
0016 #include <QString>
0017 
0018 class OperationStack;
0019 class Partition;
0020 
0021 class SetFileSystemLabelJob;
0022 
0023 /** Set a FileSystem label.
0024 
0025     Sets the FileSystem label for the given Partition.
0026 
0027     @author Volker Lanz <vl@fidra.de>
0028 */
0029 class LIBKPMCORE_EXPORT SetFileSystemLabelOperation : public Operation
0030 {
0031     friend class OperationStack;
0032 
0033     Q_DISABLE_COPY(SetFileSystemLabelOperation)
0034 
0035 public:
0036     SetFileSystemLabelOperation(Partition& p, const QString& newlabel);
0037 
0038 public:
0039     QString iconName() const override {
0040         return QStringLiteral("edit-rename");
0041     }
0042     QString description() const override;
0043     void preview() override;
0044     void undo() override;
0045 
0046     bool targets(const Device& d) const override;
0047     bool targets(const Partition& p) const override;
0048 
0049 protected:
0050     Partition& labeledPartition() {
0051         return m_LabeledPartition;
0052     }
0053     const Partition& labeledPartition() const {
0054         return m_LabeledPartition;
0055     }
0056 
0057     const QString& oldLabel() const {
0058         return m_OldLabel;
0059     }
0060     const QString& newLabel() const {
0061         return m_NewLabel;
0062     }
0063 
0064     void setOldLabel(const QString& l) {
0065         m_OldLabel = l;
0066     }
0067 
0068     SetFileSystemLabelJob* labelJob() {
0069         return m_LabelJob;
0070     }
0071 
0072 private:
0073     Partition& m_LabeledPartition;
0074     QString m_OldLabel;
0075     QString m_NewLabel;
0076     SetFileSystemLabelJob* m_LabelJob;
0077 };
0078 
0079 #endif