~ubuntu-branches/ubuntu/oneiric/partitionmanager/oneiric

« back to all changes in this revision

Viewing changes to src/gui/resizedialog.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Anthony Mercatante
  • Date: 2009-01-23 17:57:36 UTC
  • Revision ID: james.westby@ubuntu.com-20090123175736-2ltrhgg3m55dokbm
Tags: upstream-1.0.0~beta1a
ImportĀ upstreamĀ versionĀ 1.0.0~beta1a

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
 *   Copyright (C) 2008 by Volker Lanz <vl@fidra.de>                       *
 
3
 *                                                                         *
 
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.                                   *
 
8
 *                                                                         *
 
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.                          *
 
13
 *                                                                         *
 
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
 ***************************************************************************/
 
19
 
 
20
#include "gui/resizedialog.h"
 
21
#include "gui/sizedialogwidget.h"
 
22
 
 
23
#include "core/partition.h"
 
24
 
 
25
#include "ops/resizeoperation.h"
 
26
 
 
27
#include "util/capacity.h"
 
28
 
 
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
 
35
*/
 
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())
 
40
{
 
41
        setMainWidget(&dialogWidget());
 
42
        setCaption(i18nc("@title:window", "Resize/move partition: <filename>%1</filename>", partition().deviceNode()));
 
43
 
 
44
        dialogWidget().hideRole();
 
45
        dialogWidget().hideFileSystem();
 
46
 
 
47
        setupDialog();
 
48
        setupConstraints();
 
49
        setupConnections();
 
50
 
 
51
        restoreDialogSize(KConfigGroup(KGlobal::config(), "resizeDialog"));
 
52
}
 
53
 
 
54
/** Destroys a ResizeDialog */
 
55
ResizeDialog::~ResizeDialog()
 
56
{
 
57
        KConfigGroup kcg(KGlobal::config(), "resizeDialog");
 
58
        saveDialogSize(kcg);
 
59
}
 
60
 
 
61
void ResizeDialog::setupDialog()
 
62
{
 
63
        SizeDialogBase::setupDialog();
 
64
        enableButtonOk(false);
 
65
}
 
66
 
 
67
void ResizeDialog::setDirty()
 
68
{
 
69
        enableButtonOk(isModified());
 
70
}
 
71
 
 
72
/** @return true if the user modified anything */
 
73
bool ResizeDialog::isModified() const
 
74
{
 
75
        return partition().firstSector() != originalFirstSector() || partition().lastSector() != originalLastSector();
 
76
}
 
77
 
 
78
bool ResizeDialog::canGrow() const
 
79
{
 
80
        return ResizeOperation::canGrow(&partition());
 
81
}
 
82
 
 
83
bool ResizeDialog::canShrink() const
 
84
{
 
85
        return ResizeOperation::canShrink(&partition());
 
86
}
 
87
 
 
88
bool ResizeDialog::canMove() const
 
89
{
 
90
        return ResizeOperation::canMove(&partition());
 
91
}