source: calamares/trunk/fuentes/src/modules/partition/core/PartitionInfo.cpp @ 7538

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

sync with github

File size: 2.3 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 *
5 *   Calamares is free software: you can redistribute it and/or modify
6 *   it under the terms of the GNU General Public License as published by
7 *   the Free Software Foundation, either version 3 of the License, or
8 *   (at your option) any later version.
9 *
10 *   Calamares is distributed in the hope that it will be useful,
11 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
12 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 *   GNU General Public License for more details.
14 *
15 *   You should have received a copy of the GNU General Public License
16 *   along with Calamares. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#include "core/PartitionInfo.h"
20
21// KPMcore
22#include <kpmcore/core/partition.h>
23
24// Qt
25#include <QVariant>
26
27namespace PartitionInfo
28{
29
30static const char MOUNT_POINT_PROPERTY[] = "_calamares_mountPoint";
31static const char FORMAT_PROPERTY[] = "_calamares_format";
32static const char FLAGS_PROPERTY[] = "_calamares_flags";
33
34QString
35mountPoint( Partition* partition )
36{
37    return partition->property( MOUNT_POINT_PROPERTY ).toString();
38}
39
40void
41setMountPoint( Partition* partition, const QString& value )
42{
43    partition->setProperty( MOUNT_POINT_PROPERTY, value );
44}
45
46bool
47format( Partition* partition )
48{
49    return partition->property( FORMAT_PROPERTY ).toBool();
50}
51
52void
53setFormat( Partition* partition, bool value )
54{
55    partition->setProperty( FORMAT_PROPERTY, value );
56}
57
58PartitionTable::Flags flags(const Partition* partition)
59{
60    auto v = partition->property( FLAGS_PROPERTY );
61    if (v.type() == QVariant::Int )
62        return static_cast<PartitionTable::Flags>( v.toInt() );
63    return partition->activeFlags();
64}
65
66void setFlags(Partition* partition, PartitionTable::Flags f)
67{
68    partition->setProperty( FLAGS_PROPERTY, PartitionTable::Flags::Int( f ) );
69}
70
71void
72reset( Partition* partition )
73{
74    partition->setProperty( MOUNT_POINT_PROPERTY, QVariant() );
75    partition->setProperty( FORMAT_PROPERTY, QVariant() );
76    partition->setProperty( FLAGS_PROPERTY, QVariant() );
77}
78
79bool
80isDirty( Partition* partition )
81{
82    return !mountPoint( partition ).isEmpty()
83           || format( partition )
84           || flags( partition ) != partition->activeFlags();
85}
86
87} // namespace
Note: See TracBrowser for help on using the repository browser.