From ae1fa0e48bb92d5e62eafd387735141201710fe3 Mon Sep 17 00:00:00 2001 From: Teo Mrnjavac Date: Tue, 28 Apr 2015 15:37:39 +0200 Subject: [PATCH] Use correct palette in new partition dialog. --- src/modules/partition/core/ColorUtils.cpp | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/modules/partition/core/ColorUtils.cpp b/src/modules/partition/core/ColorUtils.cpp index a782c35a8..1a0fd296d 100644 --- a/src/modules/partition/core/ColorUtils.cpp +++ b/src/modules/partition/core/ColorUtils.cpp @@ -105,21 +105,27 @@ colorForPartition( Partition* partition ) return PARTITION_COLORS[ colorIdx % NUM_PARTITION_COLORS ]; } + QColor colorForPartitionInFreeSpace( Partition* partition ) { - //FIXME - PartitionNode* parent = partition->parent(); - Q_ASSERT( parent ); - int colorIdx = 0; - for ( auto child : parent->children() ) + PartitionNode* parent = _findRootForPartition( partition ); + PartitionTable* table = dynamic_cast< PartitionTable* >( parent ); + Q_ASSERT( table ); + int newColorIdx = 0; + for ( PartitionIterator it = PartitionIterator::begin( table ); + it != PartitionIterator::end( table ); + ++it ) { + Partition* child = *it; if ( child == partition ) break; - if ( !PMUtils::isPartitionFreeSpace( child ) ) - ++colorIdx; + if ( !PMUtils::isPartitionFreeSpace( child ) && + !child->hasChildren() && + PMUtils::isPartitionNew( child ) ) + ++newColorIdx; } - return PARTITION_COLORS[ colorIdx % NUM_PARTITION_COLORS ]; + return NEW_PARTITION_COLORS[ newColorIdx % NUM_NEW_PARTITION_COLORS ]; } } // namespace