source: calamares/trunk/fuentes/src/modules/partition/gui/PartitionSizeController.h

Last change on this file was 7538, checked in by kbut, 14 months ago

sync with github

File size: 2.4 KB
Line 
1/* === This file is part of Calamares - <https://github.com/calamares> ===
2 *
3 *   Copyright 2014, Aurélien Gâteau <agateau@kde.org>
4 *   Copyright 2016, Teo Mrnjavac <teo@kde.org>
5 *
6 *   Calamares is free software: you can redistribute it and/or modify
7 *   it under the terms of the GNU General Public License as published by
8 *   the Free Software Foundation, either version 3 of the License, or
9 *   (at your option) any later version.
10 *
11 *   Calamares is distributed in the hope that it will be useful,
12 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
13 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 *   GNU General Public License for more details.
15 *
16 *   You should have received a copy of the GNU General Public License
17 *   along with Calamares. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef PARTITIONSIZECONTROLLER_H
21#define PARTITIONSIZECONTROLLER_H
22
23// KPMcore
24#include <kpmcore/core/partition.h>
25
26// Qt
27#include <QColor>
28#include <QObject>
29#include <QPointer>
30#include <QScopedPointer>
31
32class QSpinBox;
33
34class Device;
35class Partition;
36class PartResizerWidget;
37
38/**
39 * Synchronizes a PartResizerWidget and a QSpinBox, making sure any change made
40 * to one is reflected in the other.
41 *
42 * It does not touch the partition it works on: changes are exposed through the
43 * firstSector() and lastSector() getters.
44 */
45class PartitionSizeController : public QObject
46{
47    Q_OBJECT
48public:
49    explicit PartitionSizeController( QObject* parent = nullptr );
50    void init( Device* device, Partition* partition, const QColor& color );
51    void setPartResizerWidget( PartResizerWidget* widget, bool format = true );
52    void setSpinBox( QSpinBox* spinBox );
53
54    qint64 firstSector() const;
55    qint64 lastSector() const;
56
57    bool isDirty() const;
58
59private:
60    QPointer< PartResizerWidget > m_partResizerWidget;
61    QPointer< QSpinBox > m_spinBox;
62    Device* m_device = nullptr;
63    const Partition* m_originalPartition = nullptr;
64    QScopedPointer< Partition > m_partition;
65    QColor m_partitionColor;
66
67    bool m_updating = false;
68
69    void connectWidgets();
70    void doUpdateSpinBox();
71    void doAlignAndUpdatePartResizerWidget( qint64 fistSector, qint64 lastSector );
72
73    bool m_dirty = false;
74    qint64 m_currentSpinBoxValue = -1;
75
76private Q_SLOTS:
77    void updatePartResizerWidget();
78    void updateSpinBox();
79};
80
81#endif /* PARTITIONSIZECONTROLLER_H */
Note: See TracBrowser for help on using the repository browser.