1
/***************************************************************************
2
* Copyright (C) 2008 by Volker Lanz <vl@fidra.de> *
4
* This program is free software; you can redistribute it and/or modify *
5
* it under the terms of the GNU General Public License as published by *
6
* the Free Software Foundation; either version 2 of the License, or *
7
* (at your option) any later version. *
9
* This program is distributed in the hope that it will be useful, *
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12
* GNU General Public License for more details. *
14
* You should have received a copy of the GNU General Public License *
15
* along with this program; if not, write to the *
16
* Free Software Foundation, Inc., *
17
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18
***************************************************************************/
20
#include "gui/resizedialog.h"
21
#include "gui/sizedialogwidget.h"
23
#include "core/partition.h"
25
#include "ops/resizeoperation.h"
27
#include "util/capacity.h"
29
/** Creates a new ResizeDialog
30
@param parent pointer to the parent widget
31
@param device the Device the Partition to resize is on
32
@param p the Partition to resize
33
@param freebefore number of sectors free before the Partition to resize
34
@param freeafter number of sectors free after the Partition to resize
36
ResizeDialog::ResizeDialog(QWidget* parent, Device& device, Partition& p, qint64 freebefore, qint64 freeafter) :
37
SizeDialogBase(parent, Capacity::MiB, device, p, freebefore, freeafter),
38
m_OriginalFirstSector(p.firstSector()),
39
m_OriginalLastSector(p.lastSector())
41
setMainWidget(&dialogWidget());
42
setCaption(i18nc("@title:window", "Resize/move partition: <filename>%1</filename>", partition().deviceNode()));
44
dialogWidget().hideRole();
45
dialogWidget().hideFileSystem();
51
restoreDialogSize(KConfigGroup(KGlobal::config(), "resizeDialog"));
54
/** Destroys a ResizeDialog */
55
ResizeDialog::~ResizeDialog()
57
KConfigGroup kcg(KGlobal::config(), "resizeDialog");
61
void ResizeDialog::setupDialog()
63
SizeDialogBase::setupDialog();
64
enableButtonOk(false);
67
void ResizeDialog::setDirty()
69
enableButtonOk(isModified());
72
/** @return true if the user modified anything */
73
bool ResizeDialog::isModified() const
75
return partition().firstSector() != originalFirstSector() || partition().lastSector() != originalLastSector();
78
bool ResizeDialog::canGrow() const
80
return ResizeOperation::canGrow(&partition());
83
bool ResizeDialog::canShrink() const
85
return ResizeOperation::canShrink(&partition());
88
bool ResizeDialog::canMove() const
90
return ResizeOperation::canMove(&partition());