Example #1
0
/** Gets valid PartitionRoles for a Partition
    @param p the Partition
    @return valid roles for the given Partition
*/
PartitionRole::Roles PartitionTable::childRoles(const Partition& p) const
{
    Q_ASSERT(p.parent());

    PartitionRole::Roles r = p.parent()->isRoot() ? PartitionRole::Primary : PartitionRole::Logical;

    if (r == PartitionRole::Primary && hasExtended() == false && tableTypeSupportsExtended(type()))
        r |= PartitionRole::Extended;

    return r;
}
Example #2
0
bool
PartitionPage::checkCanCreate( Device* device )
{
    auto table = device->partitionTable();

    if ( table->type() == PartitionTable::msdos ||table->type() == PartitionTable::msdos_sectorbased )
    {
        cDebug() << "Checking MSDOS partition" << table->numPrimaries() << "primaries, max" << table->maxPrimaries();

        if ( ( table->numPrimaries() >= table->maxPrimaries() ) && !table->hasExtended() )
        {
            QMessageBox::warning( this, tr( "Can not create new partition" ),
                tr( "The partition table on %1 already has %2 primary partitions, and no more can be added. "
                    "Please remove one primary partition and add an extended partition, instead." ).arg( device->name() ).arg( table->numPrimaries() )
            );
            return false;
        }
        return true;
    }
    else
        return true;  // GPT is fine
}