2015-06-04 01:29:22 +01:00
/*************************************************************************
* Copyright ( C ) 2008 by Volker Lanz < vl @ fidra . de > *
2016-03-02 19:00:31 +00:00
* Copyright ( C ) 2016 by Andrius Š tikonas < andrius @ stikonas . eu > *
2015-06-04 01:29:22 +01:00
* *
* 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 3 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 , see < http : //www.gnu.org/licenses/>.*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
# include "ops/setpartflagsoperation.h"
# include "core/partition.h"
# include "core/partitionnode.h"
# include "core/partitiontable.h"
# include "core/device.h"
# include "jobs/setpartflagsjob.h"
# include "fs/filesystem.h"
# include <QString>
# include <KLocalizedString>
/** Creates a new SetPartFlagsOperation.
2015-07-13 15:16:36 +01:00
@ param d the Device on which the Partition to set flags for is
@ param p the Partition to set new flags for
@ param flags the new flags to set
2015-06-04 01:29:22 +01:00
*/
SetPartFlagsOperation : : SetPartFlagsOperation ( Device & d , Partition & p , const PartitionTable : : Flags & flags ) :
2015-07-13 15:16:36 +01:00
Operation ( ) ,
m_TargetDevice ( d ) ,
m_FlagPartition ( p ) ,
m_OldFlags ( flagPartition ( ) . activeFlags ( ) ) ,
m_NewFlags ( flags ) ,
m_FlagsJob ( new SetPartFlagsJob ( targetDevice ( ) , flagPartition ( ) , newFlags ( ) ) )
2015-06-04 01:29:22 +01:00
{
2015-07-13 15:16:36 +01:00
addJob ( flagsJob ( ) ) ;
2015-06-04 01:29:22 +01:00
}
bool SetPartFlagsOperation : : targets ( const Device & d ) const
{
2015-07-13 15:16:36 +01:00
return d = = targetDevice ( ) ;
2015-06-04 01:29:22 +01:00
}
bool SetPartFlagsOperation : : targets ( const Partition & p ) const
{
2015-07-13 15:16:36 +01:00
return p = = flagPartition ( ) ;
2015-06-04 01:29:22 +01:00
}
void SetPartFlagsOperation : : preview ( )
{
2015-07-13 15:16:36 +01:00
flagPartition ( ) . setFlags ( newFlags ( ) ) ;
2015-06-04 01:29:22 +01:00
}
void SetPartFlagsOperation : : undo ( )
{
2015-07-13 15:16:36 +01:00
flagPartition ( ) . setFlags ( oldFlags ( ) ) ;
2015-06-04 01:29:22 +01:00
}
QString SetPartFlagsOperation : : description ( ) const
{
2015-07-13 15:16:36 +01:00
if ( PartitionTable : : flagNames ( newFlags ( ) ) . size ( ) = = 0 )
2016-07-17 23:41:00 +01:00
return xi18nc ( " @info:status " , " Clear flags for partition <filename>%1</filename> " , flagPartition ( ) . deviceNode ( ) ) ;
2015-06-04 01:29:22 +01:00
2016-07-17 23:41:00 +01:00
return xi18nc ( " @info:status " , " Set flags for partition <filename>%1</filename> to \" %2 \" " , flagPartition ( ) . deviceNode ( ) , PartitionTable : : flagNames ( newFlags ( ) ) . join ( QStringLiteral ( " , " ) ) ) ;
2015-06-04 01:29:22 +01:00
}