From 4429a8fd639183d02bff611ac8c4f0ce6898af2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20G=C3=A2teau?= Date: Mon, 30 Jun 2014 15:03:29 +0200 Subject: [PATCH] Introduce PMUtils --- src/modules/partition/CMakeLists.txt | 2 ++ src/modules/partition/PMUtils.cpp | 33 ++++++++++++++++++++++++ src/modules/partition/PMUtils.h | 30 +++++++++++++++++++++ src/modules/partition/PartitionModel.cpp | 4 ++- 4 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 src/modules/partition/PMUtils.cpp create mode 100644 src/modules/partition/PMUtils.h diff --git a/src/modules/partition/CMakeLists.txt b/src/modules/partition/CMakeLists.txt index d57550c04..7919804e1 100644 --- a/src/modules/partition/CMakeLists.txt +++ b/src/modules/partition/CMakeLists.txt @@ -12,6 +12,7 @@ calamares_add_plugin( partition PartitionModel.cpp PartitionPage.cpp PartitionViewStep.cpp + PMUtils.cpp UI PartitionPage.ui LINK_LIBRARIES @@ -27,6 +28,7 @@ set( partview_SRCS PartitionCoreModule.cpp PartitionModel.cpp PartitionPage.cpp + PMUtils.cpp ${calamares_SOURCE_DIR}/viewpages/AbstractPage.cpp main.cpp ) diff --git a/src/modules/partition/PMUtils.cpp b/src/modules/partition/PMUtils.cpp new file mode 100644 index 000000000..436f6c853 --- /dev/null +++ b/src/modules/partition/PMUtils.cpp @@ -0,0 +1,33 @@ +/* === This file is part of Calamares - === + * + * Copyright 2014, Aurélien Gâteau + * + * Calamares is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Calamares is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Calamares. If not, see . + */ + +#include + +// CalaPM +#include + +namespace PMUtils +{ + +bool isPartitionFreeSpace( Partition* partition ) +{ + // FIXME: Check FS type instead + return partition->partitionPath().isEmpty(); +} + +} // namespace diff --git a/src/modules/partition/PMUtils.h b/src/modules/partition/PMUtils.h new file mode 100644 index 000000000..3c7d63dca --- /dev/null +++ b/src/modules/partition/PMUtils.h @@ -0,0 +1,30 @@ +/* === This file is part of Calamares - === + * + * Copyright 2014, Aurélien Gâteau + * + * Calamares is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Calamares is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Calamares. If not, see . + */ +#ifndef PMUTILS_H +#define PMUTILS_H + +class Partition; + +namespace PMUtils +{ + +bool isPartitionFreeSpace( Partition* ); + +} + +#endif /* PMUTILS_H */ diff --git a/src/modules/partition/PartitionModel.cpp b/src/modules/partition/PartitionModel.cpp index 2b75ba124..90be12439 100644 --- a/src/modules/partition/PartitionModel.cpp +++ b/src/modules/partition/PartitionModel.cpp @@ -17,6 +17,8 @@ */ #include +#include + // CalaPM #include #include @@ -61,7 +63,7 @@ PartitionModel::data( const QModelIndex& index, int role ) const switch ( role ) { case Qt::DisplayRole: - if ( partition->partitionPath().isEmpty() ) + if ( PMUtils::isPartitionFreeSpace( partition ) ) { return tr( "Free Space" ); }