File indexing completed on 2024-04-28 05:46:34
0001 /* 0002 SPDX-FileCopyrightText: 2009-2011 Volker Lanz <vl@fidra.de> 0003 SPDX-FileCopyrightText: 2014-2017 Andrius Štikonas <andrius@stikonas.eu> 0004 SPDX-FileCopyrightText: 2015-2016 Teo Mrnjavac <teo@kde.org> 0005 SPDX-FileCopyrightText: 2019 Yuri Chornoivan <yurchor@ukr.net> 0006 0007 SPDX-License-Identifier: GPL-3.0-or-later 0008 */ 0009 0010 #if !defined(PARTITIONMANAGERWIDGET_H) 0011 0012 #define PARTITIONMANAGERWIDGET_H 0013 0014 #include <core/operationstack.h> 0015 #include <core/operationrunner.h> 0016 0017 #include "ui_partitionmanagerwidgetbase.h" 0018 0019 #include <QWidget> 0020 0021 class Partition; 0022 class PartWidget; 0023 class Device; 0024 0025 class QWidget; 0026 class QLabel; 0027 class QPoint; 0028 0029 /** The central widget for the application. 0030 0031 @author Volker Lanz <vl@fidra.de> 0032 */ 0033 class PartitionManagerWidget : public QWidget, Ui::PartitionManagerWidgetBase 0034 { 0035 Q_OBJECT 0036 Q_DISABLE_COPY(PartitionManagerWidget) 0037 0038 public: 0039 explicit PartitionManagerWidget(QWidget* parent = nullptr); 0040 virtual ~PartitionManagerWidget(); 0041 0042 Q_SIGNALS: 0043 void selectedPartitionChanged(const Partition*); 0044 void contextMenuRequested(const QPoint&); 0045 void deviceDoubleClicked(const Device*); 0046 void partitionDoubleClicked(const Partition* p); 0047 0048 public: 0049 void setSelectedDevice(Device* d); 0050 void setSelectedDevice(const QString& deviceNode); 0051 0052 void onNewPartition(); 0053 void onResizePartition(); 0054 void onDeletePartition(bool shred = false); 0055 void onShredPartition(); 0056 0057 void onCopyPartition(); 0058 void onPastePartition(); 0059 0060 void onEditMountPoint(); 0061 void onMountPartition(); 0062 void onDecryptPartition(); 0063 0064 void onCheckPartition(); 0065 0066 void onBackupPartition(); 0067 void onRestorePartition(); 0068 0069 void onPropertiesPartition(); 0070 0071 void init(OperationStack* ostack); 0072 0073 void clear(); 0074 0075 Device* selectedDevice() { 0076 return m_SelectedDevice; 0077 } 0078 const Device* selectedDevice() const { 0079 return m_SelectedDevice; 0080 } 0081 0082 Partition* selectedPartition(); 0083 void setSelectedPartition(const Partition* p); 0084 0085 Partition* clipboardPartition() { 0086 return m_ClipboardPartition; 0087 } 0088 const Partition* clipboardPartition() const { 0089 return m_ClipboardPartition; 0090 } 0091 void setClipboardPartition(Partition* p) { 0092 m_ClipboardPartition = p; 0093 } 0094 0095 void updatePartitions(); 0096 0097 // here we expect the full "sda1" or "nvme1n1p1" 0098 bool setCurrentPartitionByName(const QString& partitionName); 0099 0100 protected: 0101 OperationStack& operationStack() { 0102 return *m_OperationStack; 0103 } 0104 const OperationStack& operationStack() const { 0105 return *m_OperationStack; 0106 } 0107 0108 void setupConnections(); 0109 void loadConfig(); 0110 void saveConfig() const; 0111 bool showInsertDialog(Partition& insertPartition, qint64 sourceLength); 0112 0113 PartTableWidget& partTableWidget() { 0114 Q_ASSERT(m_PartTableWidget); 0115 return *m_PartTableWidget; 0116 } 0117 const PartTableWidget& partTableWidget() const { 0118 Q_ASSERT(m_PartTableWidget); 0119 return *m_PartTableWidget; 0120 } 0121 0122 QTreeWidget& treePartitions() { 0123 Q_ASSERT(m_TreePartitions); 0124 return *m_TreePartitions; 0125 } 0126 const QTreeWidget& treePartitions() const { 0127 Q_ASSERT(m_TreePartitions); 0128 return *m_TreePartitions; 0129 } 0130 0131 0132 void onHeaderContextMenu(const QPoint& p); 0133 0134 protected Q_SLOTS: 0135 void on_m_TreePartitions_currentItemChanged(QTreeWidgetItem* current, QTreeWidgetItem* previous); 0136 void on_m_TreePartitions_customContextMenuRequested(const QPoint& pos); 0137 void on_m_TreePartitions_itemDoubleClicked(QTreeWidgetItem* item, int); 0138 0139 void on_m_PartTableWidget_itemSelectionChanged(PartWidget* item); 0140 void on_m_PartTableWidget_customContextMenuRequested(const QPoint& pos); 0141 void on_m_PartTableWidget_itemDoubleClicked(); 0142 0143 private: 0144 OperationStack* m_OperationStack; 0145 Device* m_SelectedDevice; 0146 Partition* m_ClipboardPartition; 0147 }; 0148 0149 #endif 0150