22 #include <QColorDialog>
38 for (
int i = 1; i <= nBands; ++i )
54 int nColors = mTreeWidget->topLevelItemCount();
55 QColor* colorArray =
new QColor[nColors];
56 QVector<QString> labels;
57 for (
int i = 0; i < nColors; ++i )
59 colorArray[i] = mTreeWidget->topLevelItem( i )->background( 1 ).color();
60 QString label = mTreeWidget->topLevelItem( i )->text( 2 );
61 if ( !label.isEmpty() )
63 if ( i >= labels.size() ) labels.resize( i + 1 );
67 int bandNumber = mBandComboBox->itemData( mBandComboBox->currentIndex() ).toInt();
71 void QgsPalettedRendererWidget::on_mTreeWidget_itemDoubleClicked( QTreeWidgetItem * item,
int column )
73 if ( column == 1 && item )
75 item->setFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable );
79 item->setBackground( column, QBrush( c ) );
82 else if ( column == 2 && item )
84 item->setFlags( Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsSelectable );
95 QColor* colors = pr->
colors();
96 for (
int i = 0; i < nColors; ++i )
98 QTreeWidgetItem* item =
new QTreeWidgetItem( mTreeWidget );
99 item->setText( 0, QString::number( i ) );
100 item->setBackground( 1, QBrush( colors[i] ) );
101 item->setText( 2, pr->
label( i ) );
111 QList<QgsColorRampShader::ColorRampItem> itemList = provider->
colorTable( mBandComboBox->itemData( mBandComboBox->currentIndex() ).toInt() );
112 QList<QgsColorRampShader::ColorRampItem>::const_iterator itemIt = itemList.constBegin();
114 for ( ; itemIt != itemList.constEnd(); ++itemIt )
116 QTreeWidgetItem* item =
new QTreeWidgetItem( mTreeWidget );
117 item->setText( 0, QString::number( index ) );
118 item->setBackground( 1, QBrush( itemIt->color ) );
119 item->setText( 2, itemIt->label );