Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
-Prevent text from being entered in color cell in the color map tree
-Stort / reload color map table on apply

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@9284 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
ersts committed Sep 8, 2008
1 parent c17ccca commit 75cf6c9
Showing 1 changed file with 30 additions and 4 deletions.
34 changes: 30 additions & 4 deletions src/app/qgsrasterlayerproperties.cpp
Expand Up @@ -1367,11 +1367,12 @@ void QgsRasterLayerProperties::apply()
if ( myRasterShaderFunction )
{
//iterate through mColormapTreeWidget and set colormap info of layer
QList<QgsColorRampShader::ColorRampItem> mColorRampItems;
QList<QgsColorRampShader::ColorRampItem> myColorRampItems;

bool inserted = false;
int myCurrentIndex = 0;
int myTopLevelItemCount = mColormapTreeWidget->topLevelItemCount();
QTreeWidgetItem* myCurrentItem;

for ( int i = 0; i < myTopLevelItemCount; ++i )
{
myCurrentItem = mColormapTreeWidget->topLevelItem( i );
Expand All @@ -1383,9 +1384,33 @@ void QgsRasterLayerProperties::apply()
myNewColorRampItem.value = myCurrentItem->text( 0 ).toDouble();
myNewColorRampItem.color = myCurrentItem->background( 1 ).color();
myNewColorRampItem.label = myCurrentItem->text( 2 );
mColorRampItems.push_back( myNewColorRampItem );

//Simple insertion sort - speed is not a huge factor here
inserted = false;
myCurrentIndex = 0;
while ( !inserted )
{
if ( 0 == myColorRampItems.size() || myCurrentIndex == myColorRampItems.size() )
{
myColorRampItems.push_back( myNewColorRampItem );
inserted = true;
}
else if ( myColorRampItems[myCurrentIndex].value <= myNewColorRampItem.value && myCurrentIndex == myColorRampItems.size() - 1 )
{
myColorRampItems.push_back( myNewColorRampItem );
inserted = true;
}
else if ( myColorRampItems[myCurrentIndex].value <= myNewColorRampItem.value && myColorRampItems[myCurrentIndex+1].value > myNewColorRampItem.value )
{
myColorRampItems.insert( myCurrentIndex + 1, myNewColorRampItem );
inserted = true;
}
myCurrentIndex++;
}
}
myRasterShaderFunction->setColorRampItemList( mColorRampItems );
myRasterShaderFunction->setColorRampItemList( myColorRampItems );
//Reload table in GUI because it may have been sorted or contained invalid values
populateColorMapTable( myColorRampItems );

if ( cboxColorInterpolation->currentText() == tr( "Linear" ) )
{
Expand Down Expand Up @@ -2610,6 +2635,7 @@ void QgsRasterLayerProperties::handleColormapTreeWidgetDoubleClick( QTreeWidgetI
{
if ( column == 1 )
{
item->setFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable );
//show color dialog
QColor newColor = QColorDialog::getColor();
if ( newColor.isValid() )
Expand Down

0 comments on commit 75cf6c9

Please sign in to comment.