21 #include <QColorDialog>
37 for (
int i = 1; i <= nBands; ++i )
53 int nColors = mTreeWidget->topLevelItemCount();
54 QColor* colorArray =
new QColor[nColors];
55 QVector<QString> labels;
56 for (
int i = 0; i < nColors; ++i )
58 colorArray[i] = mTreeWidget->topLevelItem( i )->background( 1 ).color();
59 QString label = mTreeWidget->topLevelItem( i )->text( 2 );
60 if ( !label.isEmpty() )
62 if ( i >= labels.size() ) labels.resize( i + 1 );
66 int bandNumber = mBandComboBox->itemData( mBandComboBox->currentIndex() ).toInt();
72 if ( column == 1 && item )
74 item->setFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable );
75 QColor c = QColorDialog::getColor( item->background( column ).color() );
78 item->setBackground( column, QBrush( c ) );
81 else if ( column == 2 && item )
83 item->setFlags( Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsSelectable );
94 QColor* colors = pr->
colors();
95 for (
int i = 0; i < nColors; ++i )
97 QTreeWidgetItem* item =
new QTreeWidgetItem( mTreeWidget );
98 item->setText( 0, QString::number( i ) );
99 item->setBackground( 1, QBrush( colors[i] ) );
100 item->setText( 2, pr->
label( i ) );
110 QList<QgsColorRampShader::ColorRampItem> itemList = provider->
colorTable( mBandComboBox->itemData( mBandComboBox->currentIndex() ).toInt() );
111 QList<QgsColorRampShader::ColorRampItem>::const_iterator itemIt = itemList.constBegin();
113 for ( ; itemIt != itemList.constEnd(); ++itemIt )
115 QTreeWidgetItem* item =
new QTreeWidgetItem( mTreeWidget );
116 item->setText( 0, QString::number( index ) );
117 item->setBackground( 1, QBrush( itemIt->color ) );
118 item->setText( 2, itemIt->label );