Skip to content

Commit

Permalink
Don't disable band combo when only one band is present
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed May 9, 2017
1 parent 872cd13 commit ea4143b
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 11 deletions.
2 changes: 0 additions & 2 deletions src/gui/raster/qgsrasterbandcombobox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ QgsRasterBandComboBox::QgsRasterBandComboBox( QWidget *parent )
{
emit bandChanged( currentIndex() >= 0 ? currentData().toInt() : -1 );
} );
setEnabled( false );
}

QgsRasterLayer *QgsRasterBandComboBox::layer() const
Expand Down Expand Up @@ -63,7 +62,6 @@ void QgsRasterBandComboBox::setLayer( QgsMapLayer *layer )
}
}
}
setEnabled( count() > 1 );

if ( count() > 0 )
setCurrentIndex( findData( oldBand ) >= 0 ? findData( oldBand ) : 0 );
Expand Down
9 changes: 0 additions & 9 deletions tests/src/python/test_qgsrasterbandcombobox.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,9 @@ def testNoLayer(self):
combo = QgsRasterBandComboBox()
self.assertFalse(combo.layer())
self.assertEqual(combo.currentBand(), -1)
self.assertFalse(combo.isEnabled())

combo.setShowNotSetOption(True)
self.assertEqual(combo.currentBand(), -1)
self.assertFalse(combo.isEnabled())

combo.setBand(11111)
self.assertEqual(combo.currentBand(), -1)
Expand All @@ -58,14 +56,11 @@ def testOneBandRaster(self):
combo.setLayer(layer)
self.assertEqual(combo.layer(), layer)
self.assertEqual(combo.currentBand(), 1)
# only one choice, should be disabled
self.assertEqual(combo.count(), 1)
self.assertFalse(combo.isEnabled())

combo.setShowNotSetOption(True)
self.assertEqual(combo.currentBand(), 1)
self.assertEqual(combo.count(), 2)
self.assertTrue(combo.isEnabled())
combo.setBand(-1)
self.assertEqual(combo.currentBand(), -1)
combo.setBand(1)
Expand All @@ -74,7 +69,6 @@ def testOneBandRaster(self):
combo.setShowNotSetOption(False)
self.assertEqual(combo.currentBand(), 1)
self.assertEqual(combo.count(), 1)
self.assertFalse(combo.isEnabled())

def testMultiBandRaster(self):
path = os.path.join(unitTestDataPath('raster'),
Expand All @@ -89,19 +83,16 @@ def testMultiBandRaster(self):
self.assertEqual(combo.layer(), layer)
self.assertEqual(combo.currentBand(), 1)
self.assertEqual(combo.count(), 3)
self.assertTrue(combo.isEnabled())
combo.setBand(2)
self.assertEqual(combo.currentBand(), 2)

combo.setShowNotSetOption(True)
self.assertEqual(combo.currentBand(), 2)
self.assertEqual(combo.count(), 4)
self.assertTrue(combo.isEnabled())

combo.setShowNotSetOption(False)
self.assertEqual(combo.currentBand(), 2)
self.assertEqual(combo.count(), 3)
self.assertTrue(combo.isEnabled())

def testSignals(self):
path = os.path.join(unitTestDataPath('raster'),
Expand Down

0 comments on commit ea4143b

Please sign in to comment.