3 changes: 2 additions & 1 deletion python/core/qgsvectorlayer.sip
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,14 @@ public:
struct ValueRelationData
{
ValueRelationData();
ValueRelationData( QString layer, QString key, QString value, bool allowNull, bool orderByValue );
ValueRelationData( QString layer, QString key, QString value, bool allowNull, bool orderByValue, bool allowMulti = false );

QString mLayer;
QString mKey;
QString mValue;
bool mAllowNull;
bool mOrderByValue;
bool mAllowMulti; /* allow selection of multiple keys @added in 1.9 */
};

/** Constructor */
Expand Down
2 changes: 2 additions & 0 deletions src/app/qgsattributetypedialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,7 @@ void QgsAttributeTypeDialog::setIndex( int index, QgsVectorLayer::EditType editT
valueRelationValueColumn->setCurrentIndex( valueRelationValueColumn->findText( mValueRelationData.mValue ) );
valueRelationAllowNull->setChecked( mValueRelationData.mAllowNull );
valueRelationOrderByValue->setChecked( mValueRelationData.mOrderByValue );
valueRelationAllowMulti->setChecked( mValueRelationData.mAllowMulti );
break;

case QgsVectorLayer::LineEdit:
Expand Down Expand Up @@ -604,6 +605,7 @@ void QgsAttributeTypeDialog::accept()
mValueRelationData.mValue = valueRelationValueColumn->currentText();
mValueRelationData.mAllowNull = valueRelationAllowNull->isChecked();
mValueRelationData.mOrderByValue = valueRelationOrderByValue->isChecked();
mValueRelationData.mAllowMulti = valueRelationAllowMulti->isChecked();
break;
case 13:
mEditType = QgsVectorLayer::UuidGenerator;
Expand Down
2 changes: 2 additions & 0 deletions src/app/qgsrasterlayerproperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1388,6 +1388,8 @@ void QgsRasterLayerProperties::pixelSelected( const QgsPoint& canvasPoint )
}
}
}
#else
Q_UNUSED( canvasPoint );
#endif //0
}

Expand Down
4 changes: 3 additions & 1 deletion src/core/qgsvectorlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3132,7 +3132,8 @@ bool QgsVectorLayer::readSymbology( const QDomNode& node, QString& errorMessage
QString value = editTypeElement.attribute( "value" );
bool allowNull = editTypeElement.attribute( "allowNull" ) == "true";
bool orderByValue = editTypeElement.attribute( "orderByValue" ) == "true";
mValueRelations[ name ] = ValueRelationData( id, key, value, allowNull, orderByValue );
bool allowMulti = editTypeElement.attribute( "allowMulti", "false" ) == "true";
mValueRelations[ name ] = ValueRelationData( id, key, value, allowNull, orderByValue, allowMulti );
}
break;

Expand Down Expand Up @@ -3353,6 +3354,7 @@ bool QgsVectorLayer::writeSymbology( QDomNode& node, QDomDocument& doc, QString&
editTypeElement.setAttribute( "value", data.mValue );
editTypeElement.setAttribute( "allowNull", data.mAllowNull ? "true" : "false" );
editTypeElement.setAttribute( "orderByValue", data.mOrderByValue ? "true" : "false" );
editTypeElement.setAttribute( "allowMulti", data.mAllowMulti ? "true" : "false" );
}
break;

Expand Down
9 changes: 5 additions & 4 deletions src/core/qgsvectorlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,15 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
struct ValueRelationData
{
ValueRelationData() {}
ValueRelationData( QString layer, QString key, QString value, bool allowNull, bool orderByValue )
: mLayer( layer ), mKey( key ), mValue( value ), mAllowNull( allowNull ), mOrderByValue( orderByValue ) {}
ValueRelationData( QString layer, QString key, QString value, bool allowNull, bool orderByValue, bool allowMulti = false )
: mLayer( layer ), mKey( key ), mValue( value ), mAllowNull( allowNull ), mOrderByValue( orderByValue ), mAllowMulti( allowMulti ) {}

QString mLayer;
QString mKey;
QString mValue;
bool mAllowNull;
bool mOrderByValue;
bool mAllowMulti; /* allow selection of multiple keys @added in 1.9 */
};

/** Constructor */
Expand Down Expand Up @@ -614,8 +615,8 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
ValueRelationData &valueRelation( int idx );

/**Adds a new overlay to this class. QgsVectorLayer takes ownership of the object
@note this method was added in version 1.1
*/
@note this method was added in version 1.1
*/
void addOverlay( QgsVectorOverlay* overlay );

/**Removes all overlays of a given type
Expand Down
22 changes: 11 additions & 11 deletions src/core/raster/qgsrasterlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1068,7 +1068,7 @@ QPixmap QgsRasterLayer::legendAsPixmap()
* @param theWithNameFlag - boolena flag whether to overlay the legend name in the text
* @return a pixmap representing a legend image
*/
QPixmap QgsRasterLayer::legendAsPixmap( bool theWithNameFlag )
QPixmap QgsRasterLayer::legendAsPixmap( bool )
{
return QPixmap();
} //end of legendAsPixmap function
Expand All @@ -1077,7 +1077,7 @@ QPixmap QgsRasterLayer::legendAsPixmap( bool theWithNameFlag )
* \param theLabelCount number of vertical labels to display
* @return a pixmap representing a legend image
*/
QPixmap QgsRasterLayer::legendAsPixmap( int theLabelCount )
QPixmap QgsRasterLayer::legendAsPixmap( int )
{
return QPixmap();
}//end of getDetailedLegend
Expand Down Expand Up @@ -1778,12 +1778,12 @@ void QgsRasterLayer::closeDataProvider()
mPyramidList.clear();
}

void QgsRasterLayer::setColorShadingAlgorithm( ColorShadingAlgorithm theShadingAlgorithm )
void QgsRasterLayer::setColorShadingAlgorithm( ColorShadingAlgorithm )
{
//legacy method
}

void QgsRasterLayer::setColorShadingAlgorithm( QString theShaderAlgorithm )
void QgsRasterLayer::setColorShadingAlgorithm( QString )
{
//legacy method
}
Expand Down Expand Up @@ -1957,12 +1957,12 @@ void QgsRasterLayer::setDrawingStyle( QString const & theDrawingStyleQString )
}
}

void QgsRasterLayer::setGrayBandName( QString const & theBandName )
void QgsRasterLayer::setGrayBandName( QString const & )
{
//legacy method
}

void QgsRasterLayer::setGreenBandName( QString const & theBandName )
void QgsRasterLayer::setGreenBandName( QString const & )
{
//legacy method
}
Expand Down Expand Up @@ -2006,12 +2006,12 @@ void QgsRasterLayer::setMinimumMaximumUsingDataset()
//legacy method
}

void QgsRasterLayer::setMinimumValue( unsigned int theBand, double theValue, bool theGenerateLookupTableFlag )
void QgsRasterLayer::setMinimumValue( unsigned int, double, bool )
{
//legacy method
}

void QgsRasterLayer::setMinimumValue( QString theBand, double theValue, bool theGenerateLookupTableFlag )
void QgsRasterLayer::setMinimumValue( QString, double, bool )
{
//legacy method
}
Expand All @@ -2032,12 +2032,12 @@ void QgsRasterLayer::setNoDataValue( double theNoDataValue )
}
}

void QgsRasterLayer::setRasterShaderFunction( QgsRasterShaderFunction* theFunction )
void QgsRasterLayer::setRasterShaderFunction( QgsRasterShaderFunction* )
{
//legacy method
}

void QgsRasterLayer::setRedBandName( QString const & theBandName )
void QgsRasterLayer::setRedBandName( QString const & )
{
//legacy method
}
Expand All @@ -2053,7 +2053,7 @@ void QgsRasterLayer::setSubLayerVisibility( QString name, bool vis )

}

void QgsRasterLayer::setTransparentBandName( QString const & theBandName )
void QgsRasterLayer::setTransparentBandName( QString const & )
{
//legacy method
}
Expand Down
22 changes: 11 additions & 11 deletions src/core/raster/qgsrasterlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -482,10 +482,10 @@ class CORE_EXPORT QgsRasterLayer : public QgsMapLayer
QPixmap legendAsPixmap();

/** \brief Overloaded version of above function that can print layer name onto legend */
QPixmap legendAsPixmap( bool );
Q_DECL_DEPRECATED QPixmap legendAsPixmap( bool );

/** \brief Use this method when you want an annotated legend suitable for print output etc */
QPixmap legendAsPixmap( int theLabelCount );
Q_DECL_DEPRECATED QPixmap legendAsPixmap( int theLabelCount );

/** \brief Accessor for maximum value user for contrast enhancement */
double maximumValue( unsigned int theBand );
Expand Down Expand Up @@ -534,7 +534,7 @@ class CORE_EXPORT QgsRasterLayer : public QgsMapLayer
void setColorShadingAlgorithm( QgsRasterLayer::ColorShadingAlgorithm theShaderAlgorithm );

/** \brief Mutator for color shader algorithm */
void setColorShadingAlgorithm( QString theShaderAlgorithm );
Q_DECL_DEPRECATED void setColorShadingAlgorithm( QString theShaderAlgorithm );

/** \brief Mutator for contrast enhancement algorithm */
void setContrastEnhancementAlgorithm( QgsContrastEnhancement::ContrastEnhancementAlgorithm theAlgorithm,
Expand All @@ -550,16 +550,16 @@ class CORE_EXPORT QgsRasterLayer : public QgsMapLayer
void setDrawingStyle( const QString & theDrawingStyleQString );

/** \brief Mutator for gray band name mapping */
void setGrayBandName( const QString & theBandName );
Q_DECL_DEPRECATED void setGrayBandName( const QString & theBandName );

/** \brief Mutator for green band name mapping */
void setGreenBandName( const QString & theBandName );
Q_DECL_DEPRECATED void setGreenBandName( const QString & theBandName );

/** \brief Mutator for setting the maximum value for contrast enhancement */
void setMaximumValue( unsigned int theBand, double theValue, bool theGenerateLookupTableFlag = true );

/** \brief Mutator for setting the maximum value for contrast enhancement */
void setMaximumValue( QString theBand, double theValue, bool theGenerateLookupTableFlag = true );
Q_DECL_DEPRECATED void setMaximumValue( QString theBand, double theValue, bool theGenerateLookupTableFlag = true );

/** \brief Sets the minimum and maximum values for the band(s) currently
* being displayed using the only pixel values from the last/current extent
Expand All @@ -571,23 +571,23 @@ class CORE_EXPORT QgsRasterLayer : public QgsMapLayer
void setMinimumMaximumUsingDataset();

/** \brief Mutator for setting the minimum value for contrast enhancement */
void setMinimumValue( unsigned int theBand, double theValue, bool theGenerateLookupTableFlag = true );
Q_DECL_DEPRECATED void setMinimumValue( unsigned int theBand, double theValue, bool theGenerateLookupTableFlag = true );

/** \brief Mutator for setting the minimum value for contrast enhancement */
void setMinimumValue( QString theBand, double theValue, bool theGenerateLookupTableFlag = true );
Q_DECL_DEPRECATED void setMinimumValue( QString theBand, double theValue, bool theGenerateLookupTableFlag = true );

/** \brief Mutator that allows the NO_DATA entry for this raster to be overridden */
void setNoDataValue( double theNoData );

/** \brief Set the raster shader function to a user defined function
\note ownership of the shader function is transfered to raster shader */
void setRasterShaderFunction( QgsRasterShaderFunction* theFunction );
Q_DECL_DEPRECATED void setRasterShaderFunction( QgsRasterShaderFunction* theFunction );

/** \brief Mutator for red band name (allows alternate mappings e.g. map blue as red color) */
void setRedBandName( const QString & theBandName );
Q_DECL_DEPRECATED void setRedBandName( const QString & theBandName );

/** \brief Mutator for transparent band name mapping */
void setTransparentBandName( const QString & theBandName );
Q_DECL_DEPRECATED void setTransparentBandName( const QString & theBandName );

/** \brief [ data provider interface ] A wrapper function to emit a progress update signal */
void showProgress( int theValue );
Expand Down
85 changes: 77 additions & 8 deletions src/gui/qgsattributeeditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include <QTextEdit>
#include <QFileDialog>
#include <QComboBox>
#include <QListWidget>
#include <QCheckBox>
#include <QSpinBox>
#include <QCompleter>
Expand Down Expand Up @@ -112,6 +113,17 @@ QComboBox *QgsAttributeEditor::comboBox( QWidget *editor, QWidget *parent )
return cb;
}

QListWidget *QgsAttributeEditor::listWidget( QWidget *editor, QWidget *parent )
{
QListWidget *lw = NULL;
if ( editor )
lw = qobject_cast<QListWidget *>( editor );
else
lw = new QListWidget( parent );

return lw;
}

QWidget *QgsAttributeEditor::createAttributeEditor( QWidget *parent, QWidget *editor, QgsVectorLayer *vl, int idx, const QVariant &value )
{
if ( !vl )
Expand Down Expand Up @@ -206,18 +218,49 @@ QWidget *QgsAttributeEditor::createAttributeEditor( QWidget *parent, QWidget *ed
}
}

QComboBox *cb = comboBox( editor, parent );
if ( cb )
if ( !data.mAllowMulti )
{
for ( QMap< QString, QString >::const_iterator it = map.begin(); it != map.end(); it++ )
QComboBox *cb = comboBox( editor, parent );
if ( cb )
{
if ( data.mOrderByValue )
cb->addItem( it.key(), it.value() );
else
cb->addItem( it.value(), it.key() );
for ( QMap< QString, QString >::const_iterator it = map.begin(); it != map.end(); it++ )
{
if ( data.mOrderByValue )
cb->addItem( it.key(), it.value() );
else
cb->addItem( it.value(), it.key() );
}

myWidget = cb;
}
}
else
{
QListWidget *lw = listWidget( editor, parent );
if ( lw )
{
QStringList checkList = value.toString().remove( QChar( '{' ) ).remove( QChar( '}' ) ).split( "," );

myWidget = cb;
for ( QMap< QString, QString >::const_iterator it = map.begin(); it != map.end(); it++ )
{
QListWidgetItem *item;
if ( data.mOrderByValue )
{
item = new QListWidgetItem( it.key() );
item->setData( Qt::UserRole, it.value() );
item->setCheckState( checkList.contains( it.value() ) ? Qt::Checked : Qt::Unchecked );
}
else
{
item = new QListWidgetItem( it.value() );
item->setData( Qt::UserRole, it.key() );
item->setCheckState( checkList.contains( it.key() ) ? Qt::Checked : Qt::Unchecked );
}
lw->addItem( item );
}

myWidget = lw;
}
}
}
break;
Expand Down Expand Up @@ -551,6 +594,32 @@ bool QgsAttributeEditor::retrieveValue( QWidget *widget, QgsVectorLayer *vl, int
modified = true;
}

QListWidget *lw = qobject_cast<QListWidget *>( widget );
if ( lw )
{
if ( editType == QgsVectorLayer::ValueRelation )
{
text = '{';
for ( int i = 0; i < lw->count(); i++ )
{
if ( lw->item( i )->checkState() == Qt::Checked )
{
if ( i > 0 )
{
text.append( ',' );
}
text.append( lw->item( i )->data( Qt::UserRole ).toString() );
}
}
text.append( '}' );
}
else
{
text = QString::null;
}
modified = true;
}

QSpinBox *sb = qobject_cast<QSpinBox *>( widget );
if ( sb )
{
Expand Down
2 changes: 2 additions & 0 deletions src/gui/qgsattributeeditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class QObject;
class QWidget;
class QgsVectorLayer;
class QComboBox;
class QListWidget;

/* \brief create attribute widget for editing */
class GUI_EXPORT QgsAttributeEditor : public QObject
Expand All @@ -37,6 +38,7 @@ class GUI_EXPORT QgsAttributeEditor : public QObject

private:
static QComboBox *comboBox( QWidget *editor, QWidget *parent );
static QListWidget *listWidget( QWidget *editor, QWidget *parent );

public slots:
void selectFileName();
Expand Down
3 changes: 3 additions & 0 deletions src/mapserver/qgssldparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,9 @@ bool QgsSLDParser::rasterSymbologyFromUserStyle( const QDomElement& userStyleEle

//set pseudo color mode
return true;
#else
Q_UNUSED( userStyleElement );
Q_UNUSED( r );
#endif //0
}

Expand Down
Loading