2010-01-29 11:25:28 +00:00
/***************************************************************************
* Copyright ( C ) 2010 by Volker Lanz < vl @ fidra . de > *
* *
* This program 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 2 of the License , or *
* ( at your option ) any later version . *
* *
* This program 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 this program ; if not , write to the *
* Free Software Foundation , Inc . , *
* 51 Franklin Street , Fifth Floor , Boston , MA 02110 - 1301 , USA . *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
# include "gui/createpartitiontabledialog.h"
# include "gui/createpartitiontablewidget.h"
# include "core/device.h"
2010-02-01 16:32:45 +00:00
# include "core/partitiontable.h"
2010-01-29 11:25:28 +00:00
# include <klocale.h>
2010-04-11 19:06:47 +01:00
# include <kmessagebox.h>
2010-01-29 11:25:28 +00:00
2010-02-11 22:26:51 +00:00
# include <config.h>
2010-01-29 11:25:28 +00:00
CreatePartitionTableDialog : : CreatePartitionTableDialog ( QWidget * parent , const Device & d ) :
KDialog ( parent ) ,
m_DialogWidget ( new CreatePartitionTableWidget ( this ) ) ,
m_Device ( d )
{
setMainWidget ( & widget ( ) ) ;
2010-01-30 07:03:57 +00:00
setCaption ( i18nc ( " @title:window " , " Create a New Partition Table on <filename>%1</filename> " , device ( ) . deviceNode ( ) ) ) ;
2010-01-29 11:25:28 +00:00
setButtonText ( KDialog : : Ok , i18nc ( " @action:button " , " &Create New Partition Table " ) ) ;
2010-04-11 19:06:47 +01:00
connect ( & widget ( ) . radioMSDOS ( ) , SIGNAL ( toggled ( bool ) ) , SLOT ( onMSDOSToggled ( bool ) ) ) ;
2010-01-29 11:25:28 +00:00
}
2010-02-24 11:32:12 +00:00
PartitionTable : : TableType CreatePartitionTableDialog : : type ( ) const
2010-01-29 11:25:28 +00:00
{
2010-02-01 16:32:45 +00:00
if ( widget ( ) . radioGPT ( ) . isChecked ( ) )
return PartitionTable : : gpt ;
2010-03-01 12:00:07 +00:00
if ( widget ( ) . radioMSDOS ( ) . isChecked ( ) & & Config : : useCylinderAlignment ( ) = = true )
2010-02-17 13:18:25 +00:00
return PartitionTable : : msdos ;
2010-02-01 16:32:45 +00:00
2010-03-01 12:00:07 +00:00
return PartitionTable : : msdos_sectorbased ;
2010-01-29 11:25:28 +00:00
}
2010-04-11 19:06:47 +01:00
void CreatePartitionTableDialog : : onMSDOSToggled ( bool on )
{
if ( on & & device ( ) . totalSectors ( ) > 0xffffffff )
{
if ( KMessageBox : : warningContinueCancel ( this ,
i18nc ( " @info " ,
" <para>Do you really want to create an MS-Dos partition table on <filename>%1</filename>?</para> "
" <para>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.</para> " , 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 ) ;
}
}
}