[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    extragear/sysadmin/partitionmanager/src/gui
From:       Volker Lanz <vl () fidra ! de>
Date:       2010-04-26 14:34:59
Message-ID: 20100426143459.DB01EAC8A4 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1119091 by vlanz:

set spin box stepping for capacity, too

make sure we set the correct value for the free space spinboxes after
calculating the new first/last sector


 M  +16 -31    sizedialogbase.cpp  


--- trunk/extragear/sysadmin/partitionmanager/src/gui/sizedialogbase.cpp \
#1119090:1119091 @@ -170,10 +170,11 @@
 	detailsWidget().spinFirstSector().setSingleStep(align ? \
PartitionAlignment::sectorAlignment(device()) : 1);  \
detailsWidget().spinLastSector().setSingleStep(align ? \
PartitionAlignment::sectorAlignment(device()) : 1);  
-	const double freeStep = align ? sectorsToDialogUnit(partition(), \
PartitionAlignment::sectorAlignment(device())) : 1; +	const double capacityStep = \
align ? sectorsToDialogUnit(partition(), \
PartitionAlignment::sectorAlignment(device())) : 1;  
-	dialogWidget().spinFreeBefore().setSingleStep(freeStep);
-	dialogWidget().spinFreeBefore().setSingleStep(freeStep);
+	dialogWidget().spinFreeBefore().setSingleStep(capacityStep);
+	dialogWidget().spinFreeBefore().setSingleStep(capacityStep);
+	dialogWidget().spinCapacity().setSingleStep(capacityStep);
 }
 
 void SizeDialogBase::onFirstSectorChanged(qint64 newFirst)
@@ -219,65 +220,49 @@
 
 void SizeDialogBase::onFreeSpaceBeforeChanged(double newBefore)
 {
-	const double oldBefore = sectorsToDialogUnit(partition(), partition().firstSector() \
                - minimumFirstSector());
-
 	qint64 newFirstSector = minimumFirstSector() + dialogUnitToSectors(partition(), \
newBefore);  
 	if (detailsWidget().checkAlign().isChecked())
 	{
+		const qint64 oldBefore = sectorsToDialogUnit(partition(), \
partition().firstSector() - minimumFirstSector());  const qint64 deltaCorrection = \
newBefore > oldBefore ? PartitionAlignment::firstDelta(device(), partition(), \
newFirstSector) : 0;  newFirstSector = \
PartitionAlignment::alignedFirstSector(device(), partition(), newFirstSector + \
deltaCorrection, minimumFirstSector(), -1, minimumLength(), maximumLength());  }
 
-	bool success = dialogWidget().partResizerWidget().movePartition(newFirstSector);
+	if (dialogWidget().partResizerWidget().movePartition(newFirstSector) ||
+			dialogWidget().partResizerWidget().updateFirstSector(newFirstSector))
+		setDirty();
 
-	if (!success)
-	{
-		success = dialogWidget().partResizerWidget().updateFirstSector(newFirstSector);
-
-		if (!success)
-		{
+	// In most cases the capacity free before the partition's first sector that we \
calculated +	// above from newBefore will not exactly equal newBefore (due to \
rounding errors). So +	// make sure to set the spin box to the actual value.
 			const bool state = dialogWidget().spinFreeBefore().blockSignals(true);
-			dialogWidget().spinFreeBefore().setValue(oldBefore);
+	dialogWidget().spinFreeBefore().setValue(sectorsToDialogUnit(partition(), \
partition().firstSector() - minimumFirstSector()));  \
dialogWidget().spinFreeBefore().blockSignals(state);  }
-	}
 
-	if (success)
-		setDirty();
-}
-
 void SizeDialogBase::onFreeSpaceAfterChanged(double newAfter)
 {
-	const double oldAfter = sectorsToDialogUnit(partition(), maximumLastSector() - \
partition().lastSector());  qint64 newLastSector = maximumLastSector() - \
dialogUnitToSectors(partition(), newAfter);  
 	if (detailsWidget().checkAlign().isChecked())
 	{
+		const double oldAfter = sectorsToDialogUnit(partition(), maximumLastSector() - \
partition().lastSector());  const qint64 deltaCorrection = newAfter > oldAfter ? \
PartitionAlignment::lastDelta(device(), partition(), newLastSector) : 0;  \
newLastSector = PartitionAlignment::alignedLastSector(device(), partition(), \
newLastSector - deltaCorrection, -1, maximumLastSector(), minimumLength(), \
maximumLength());  }
 
 	const qint64 newFirstSector = newLastSector - partition().length() + 1;
 
-	bool success = dialogWidget().partResizerWidget().movePartition(newFirstSector);
+	if (dialogWidget().partResizerWidget().movePartition(newFirstSector) ||
+			dialogWidget().partResizerWidget().updateLastSector(newLastSector))
+		setDirty();
 
-	if (!success)
-	{
-		success = dialogWidget().partResizerWidget().updateLastSector(newLastSector);
-
-		if (!success)
-		{
 			const bool state = dialogWidget().spinFreeAfter().blockSignals(true);
 			dialogWidget().spinFreeAfter().setValue(sectorsToDialogUnit(partition(), \
maximumLastSector() - partition().lastSector()));  \
dialogWidget().spinFreeAfter().blockSignals(state);  }
-	}
 
-	if (success)
-		setDirty();
-}
-
 const PartitionTable& SizeDialogBase::partitionTable() const
 {
 	Q_ASSERT(device().partitionTable());


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic