File indexing completed on 2024-04-28 05:45:53
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: 2015 Teo Mrnjavac <teo@kde.org> 0005 SPDX-FileCopyrightText: 2016-2017 Andrius Štikonas <andrius@stikonas.eu 0006 0007 SPDX-License-Identifier: GPL-3.0-or-later 0008 */ 0009 0010 #ifndef KPMCORE_PARTWIDGETBASE_H 0011 #define KPMCORE_PARTWIDGETBASE_H 0012 0013 #include "util/libpartitionmanagerexport.h" 0014 0015 #include "core/partitionnode.h" 0016 0017 #include <QList> 0018 #include <QWidget> 0019 0020 class Partition; 0021 class PartWidget; 0022 class QWidget; 0023 0024 bool distributeLostPixels(QList<qint32>& childrenWidth, qint32 lostPixels); 0025 bool levelChildrenWidths(QList<qint32>& childrenWidth, const QList<qint32>& minChildrenWidth, const qint32 destWidgetWidth); 0026 0027 /** Base class for all widgets that need to position Partitions. 0028 @author Volker Lanz <vl@fidra.de> 0029 */ 0030 class LIBKPMCORE_EXPORT PartWidgetBase : public QWidget 0031 { 0032 Q_DISABLE_COPY(PartWidgetBase) 0033 0034 protected: 0035 PartWidgetBase(QWidget* parent) : QWidget(parent) {} 0036 ~PartWidgetBase() override {} 0037 0038 public: 0039 virtual qint32 borderWidth() const { 0040 return m_BorderWidth; /**< @return border width */ 0041 } 0042 virtual qint32 borderHeight() const { 0043 return m_BorderHeight; /**< @return border height */ 0044 } 0045 static qint32 spacing() { 0046 return m_Spacing; /**< @return spacing between Partitions */ 0047 } 0048 static qint32 minWidth() { 0049 return m_MinWidth; /**< @return minimum width for a Partition widget */ 0050 } 0051 0052 virtual const QList<PartWidget*> childWidgets() const; 0053 0054 protected: 0055 virtual void positionChildren(const QWidget* destWidget, const PartitionNode::Partitions& partitions, QList<PartWidget*> widgets) const; 0056 0057 private: 0058 static const qint32 m_Spacing; 0059 static const qint32 m_BorderWidth; 0060 static const qint32 m_BorderHeight; 0061 static const qint32 m_MinWidth; 0062 }; 0063 0064 #endif 0065