File indexing completed on 2024-05-19 09:42:47
0001 /* 0002 SPDX-FileCopyrightText: 2008-2010 Volker Lanz <vl@fidra.de> 0003 SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa <hugo@oxygen-icons.org> 0004 SPDX-FileCopyrightText: 2014-2017 Andrius Štikonas <andrius@stikonas.eu> 0005 SPDX-FileCopyrightText: 2019 Yuri Chornoivan <yurchor@ukr.net> 0006 0007 SPDX-License-Identifier: GPL-3.0-or-later 0008 */ 0009 0010 #if !defined(PARTTABLEWIDGET_H) 0011 0012 #define PARTTABLEWIDGET_H 0013 0014 #include <gui/partwidgetbase.h> 0015 0016 #include <QLabel> 0017 #include <QStyle> 0018 0019 class PartWidget; 0020 class PartitionTable; 0021 0022 class QResizeEvent; 0023 class QMouseEvent; 0024 0025 /** Widget that represents a PartitionTable. 0026 @author Volker Lanz <vl@fidra.de> 0027 */ 0028 class PartTableWidget : public PartWidgetBase 0029 { 0030 Q_OBJECT 0031 Q_DISABLE_COPY(PartTableWidget) 0032 0033 public: 0034 explicit PartTableWidget(QWidget* parent); 0035 qint32 borderWidth() const override { 0036 return style()->pixelMetric(QStyle::PM_LayoutLeftMargin); /**< @return border width */ 0037 } 0038 qint32 borderHeight() const override { 0039 return style()->pixelMetric(QStyle::PM_LayoutTopMargin); /**< @return border height */ 0040 } 0041 0042 public: 0043 void setPartitionTable(const PartitionTable* ptable); 0044 0045 PartWidget* activeWidget(); /**< @return the active widget or nullptr if none */ 0046 const PartWidget* activeWidget() const; /**< @return the active widget or nullptr if none */ 0047 0048 void setActiveWidget(PartWidget* partWidget); 0049 void setActivePartition(const Partition* p); 0050 void clear(); 0051 void setReadOnly(bool b) { 0052 m_ReadOnly = b; /**< @param b the new value for read only */ 0053 } 0054 bool isReadOnly() const { 0055 return m_ReadOnly; /** @return true if the widget is read only */ 0056 } 0057 0058 Q_SIGNALS: 0059 void itemSelectionChanged(PartWidget*); 0060 void itemDoubleClicked(const PartWidget*); 0061 0062 protected: 0063 void resizeEvent(QResizeEvent* event) override; 0064 void mousePressEvent(QMouseEvent* event) override; 0065 void mouseDoubleClickEvent(QMouseEvent* event) override; 0066 0067 const PartitionTable* partitionTable() const { 0068 return m_PartitionTable; 0069 } 0070 0071 QLabel& labelEmpty() { 0072 return m_LabelEmpty; 0073 } 0074 const QLabel& labelEmpty() const { 0075 return m_LabelEmpty; 0076 } 0077 0078 private: 0079 const PartitionTable* m_PartitionTable; 0080 QLabel m_LabelEmpty; 0081 bool m_ReadOnly; 0082 }; 0083 0084 #endif 0085