Commit 9346e020 authored by PIERSON Julie's avatar PIERSON Julie
Browse files

removing add button for adding a row in table

parent 3f5aba9b
......@@ -56,7 +56,6 @@ class BandTableWidget(BASE, WIDGET):
self.cmbLayers.setFilters(QgsMapLayerProxyModel.RasterLayer)
self.cmbLayers.layerChanged.connect(self.layerChanged)
self.btnAdd.setIcon(QgsApplication.getThemeIcon('/symbologyAdd.svg'))
self.btnRemove.setIcon(QgsApplication.getThemeIcon('/symbologyRemove.svg'))
self.btnUp.setIcon(QgsApplication.getThemeIcon('/mActionArrowUp.svg'))
self.btnDown.setIcon(QgsApplication.getThemeIcon('/mActionArrowDown.svg'))
......@@ -75,28 +74,23 @@ class BandTableWidget(BASE, WIDGET):
# for each band
for band_number in range(nbands):
band = input_raster.GetRasterBand(band_number + 1)
# add band name to table in first column
self._addBandData(band.GetDescription())
# add band name and number to table
bandnumber = 'bande ' + str(band_number+1)
bandname = band.GetDescription()
self._addBandData(bandnumber, bandname)
# add selected raster band names to table
def _addBandData(self, bandname):
# add selected raster band number and names to table
def _addBandData(self, bandnumber, bandname):
item = QTreeWidgetItem()
item.setText(0, bandname)
item.setText(1, '')
item.setText(0, bandnumber)
item.setText(1, bandname)
#item.setText(2, '')
self.bandClassTree.addTopLevelItem(item)
# remove all rows from table
def _removeBandData(self,):
self.bandClassTree.clear()
@pyqtSlot()
def on_btnAdd_clicked(self):
item = QTreeWidgetItem()
item.setText(0, '0.00')
item.setText(1, '0.00')
# item.setBackground(2, QBrush(QColor(127, 127, 127)))
self.bandClassTree.addTopLevelItem(item)
@pyqtSlot()
def on_btnRemove_clicked(self):
selectedItems = self.bandClassTree.selectedItems()
......@@ -129,13 +123,13 @@ class BandTableWidget(BASE, WIDGET):
if not item:
return
if column == 1:
if column == 2:
d, ok = QInputDialog.getText(None,
self.tr('Band name'),
self.tr('Enter new band name')
)
if ok:
item.setText(1, str(d))
item.setText(2, str(d))
def reliefColors(self):
colors = []
......
......@@ -36,6 +36,11 @@
</item>
<item row="1" column="0" colspan="2">
<widget class="QTreeWidget" name="bandClassTree">
<column>
<property name="text">
<string>Band number</string>
</property>
</column>
<column>
<property name="text">
<string>Band name</string>
......@@ -50,16 +55,6 @@
</item>
<item row="1" column="3">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QToolButton" name="btnAdd">
<property name="toolTip">
<string>Add row</string>
</property>
<property name="text">
<string></string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="btnRemove">
<property name="toolTip">
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment