From 2f822dd21bc68e1047cd2ea6b039078b7eba0623 Mon Sep 17 00:00:00 2001 From: Volker Lanz Date: Sun, 11 Apr 2010 18:06:47 +0000 Subject: [PATCH] check if device has more than 2^32 sectors if user wants to create an msdos partition table on it and show a warning in that case. also make the default GPT. svn path=/trunk/extragear/sysadmin/partitionmanager/; revision=1113771 --- TODO | 3 --- src/gui/createpartitiontabledialog.cpp | 20 ++++++++++++++++++++ src/gui/createpartitiontabledialog.h | 3 +++ src/gui/createpartitiontablewidgetbase.ui | 11 +++++++---- 4 files changed, 30 insertions(+), 7 deletions(-) diff --git a/TODO b/TODO index 75d4a65..91a1a88 100644 --- a/TODO +++ b/TODO @@ -1,8 +1,5 @@ Plans and ideas for 1.1: -* Check if no of sectors fits in an unsigned 32 bit int for msdos partition - tables. - * offer a) no alignment of partition boundaries at all or b) legacy cylinder alignment or c) sector based alignment (the name is misleading, though) diff --git a/src/gui/createpartitiontabledialog.cpp b/src/gui/createpartitiontabledialog.cpp index c8dd35b..43ae6ed 100644 --- a/src/gui/createpartitiontabledialog.cpp +++ b/src/gui/createpartitiontabledialog.cpp @@ -24,6 +24,7 @@ #include "core/partitiontable.h" #include +#include #include @@ -35,6 +36,8 @@ CreatePartitionTableDialog::CreatePartitionTableDialog(QWidget* parent, const De setMainWidget(&widget()); setCaption(i18nc("@title:window", "Create a New Partition Table on %1", device().deviceNode())); setButtonText(KDialog::Ok, i18nc("@action:button", "&Create New Partition Table")); + + connect(&widget().radioMSDOS(), SIGNAL(toggled(bool)), SLOT(onMSDOSToggled(bool))); } PartitionTable::TableType CreatePartitionTableDialog::type() const @@ -47,3 +50,20 @@ PartitionTable::TableType CreatePartitionTableDialog::type() const return PartitionTable::msdos_sectorbased; } + +void CreatePartitionTableDialog::onMSDOSToggled(bool on) +{ + if (on && device().totalSectors() > 0xffffffff) + { + if (KMessageBox::warningContinueCancel(this, + i18nc("@info", + "Do you really want to create an MS-Dos partition table on %1?" + "This device has more than 2^32 sectors. That is the most the MS-Dos partition table type supports, so you will not be able to use the whole device.", device().deviceNode()), + i18nc("@title:window", "Really Create MS-Dos Partition Table Type?"), + KGuiItem(i18nc("@action:button", "Create MS-Dos Type"), "arrow-right"), + KStandardGuiItem::cancel(), "reallyCreateMSDOSOnLargeDevice") == KMessageBox::Cancel) + { + widget().radioGPT().setChecked(true); + } + } +} \ No newline at end of file diff --git a/src/gui/createpartitiontabledialog.h b/src/gui/createpartitiontabledialog.h index 025f6ad..f5fb557 100644 --- a/src/gui/createpartitiontabledialog.h +++ b/src/gui/createpartitiontabledialog.h @@ -44,6 +44,9 @@ class CreatePartitionTableDialog : public KDialog const CreatePartitionTableWidget& widget() const { return *m_DialogWidget; } const Device& device() const { return m_Device; } + protected slots: + void onMSDOSToggled(bool on); + private: CreatePartitionTableWidget* m_DialogWidget; const Device& m_Device; diff --git a/src/gui/createpartitiontablewidgetbase.ui b/src/gui/createpartitiontablewidgetbase.ui index 8ad9d0e..3176be2 100644 --- a/src/gui/createpartitiontablewidgetbase.ui +++ b/src/gui/createpartitiontablewidgetbase.ui @@ -24,9 +24,9 @@ - + - MS-Dos + GPT true @@ -34,9 +34,12 @@ - + - GPT + MS-Dos + + + false