246 changes: 188 additions & 58 deletions src/app/composer/qgscomposermapwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

#include "qgscomposermapwidget.h"
#include "qgscomposeritemwidget.h"
#include "qgscomposermap.h"
#include "qgsmaprenderer.h"
#include <QColorDialog>
#include <QFontDialog>
Expand Down Expand Up @@ -47,13 +46,19 @@ QgsComposerMapWidget::QgsComposerMapWidget( QgsComposerMap* composerMap ): QWidg
mGridTypeComboBox->insertItem( 0, tr( "Solid" ) );
mGridTypeComboBox->insertItem( 1, tr( "Cross" ) );

mAnnotationPositionComboBox->insertItem( 0, tr( "Inside frame" ) );
mAnnotationPositionComboBox->insertItem( 1, tr( "Outside frame" ) );
insertAnnotationPositionEntries( mAnnotationPositionLeftComboBox );
insertAnnotationPositionEntries( mAnnotationPositionRightComboBox );
insertAnnotationPositionEntries( mAnnotationPositionTopComboBox );
insertAnnotationPositionEntries( mAnnotationPositionBottomComboBox );

insertAnnotationDirectionEntries( mAnnotationDirectionComboBoxLeft );
insertAnnotationDirectionEntries( mAnnotationDirectionComboBoxRight );
insertAnnotationDirectionEntries( mAnnotationDirectionComboBoxTop );
insertAnnotationDirectionEntries( mAnnotationDirectionComboBoxBottom );

mFrameStyleComboBox->insertItem( 0, tr( "No frame" ) );
mFrameStyleComboBox->insertItem( 1, tr( "Zebra" ) );

mAnnotationDirectionComboBox->insertItem( 0, tr( "Horizontal" ) );
mAnnotationDirectionComboBox->insertItem( 1, tr( "Vertical" ) );
mAnnotationDirectionComboBox->insertItem( 2, tr( "Horizontal and Vertical" ) );
mAnnotationDirectionComboBox->insertItem( 2, tr( "Boundary direction" ) );
if ( composerMap )
{
connect( composerMap, SIGNAL( itemChanged() ), this, SLOT( setGuiElementValues() ) );
Expand Down Expand Up @@ -344,16 +349,30 @@ void QgsComposerMapWidget::updateGuiElements()

mCrossWidthSpinBox->setValue( mComposerMap->crossLength() );

QgsComposerMap::GridAnnotationPosition annotationPos = mComposerMap->gridAnnotationPosition();
if ( annotationPos == QgsComposerMap::InsideMapFrame )
//grid frame
mFrameWidthSpinBox->setValue( mComposerMap->gridFrameWidth() );
QgsComposerMap::GridFrameStyle gridFrameStyle = mComposerMap->gridFrameStyle();
if ( gridFrameStyle == QgsComposerMap::Zebra )
{
mAnnotationPositionComboBox->setCurrentIndex( mAnnotationPositionComboBox->findText( tr( "Inside frame" ) ) );
mFrameStyleComboBox->setCurrentIndex( mFrameStyleComboBox->findText( tr( "Zebra" ) ) );
}
else
else //NoGridFrame
{
mAnnotationPositionComboBox->setCurrentIndex( mAnnotationPositionComboBox->findText( tr( "Outside frame" ) ) );
mFrameStyleComboBox->setCurrentIndex( mFrameStyleComboBox->findText( tr( "No frame" ) ) );
}

//grid annotation position
initAnnotationPositionBox( mAnnotationPositionLeftComboBox, mComposerMap->gridAnnotationPosition( QgsComposerMap::Left ) );
initAnnotationPositionBox( mAnnotationPositionRightComboBox, mComposerMap->gridAnnotationPosition( QgsComposerMap::Right ) );
initAnnotationPositionBox( mAnnotationPositionTopComboBox, mComposerMap->gridAnnotationPosition( QgsComposerMap::Top ) );
initAnnotationPositionBox( mAnnotationPositionBottomComboBox, mComposerMap->gridAnnotationPosition( QgsComposerMap::Bottom ) );

//grid annotation direction
initAnnotationDirectionBox( mAnnotationDirectionComboBoxLeft, mComposerMap->gridAnnotationDirection( QgsComposerMap::Left ) );
initAnnotationDirectionBox( mAnnotationDirectionComboBoxRight, mComposerMap->gridAnnotationDirection( QgsComposerMap::Right ) );
initAnnotationDirectionBox( mAnnotationDirectionComboBoxTop, mComposerMap->gridAnnotationDirection( QgsComposerMap::Top ) );
initAnnotationDirectionBox( mAnnotationDirectionComboBoxBottom, mComposerMap->gridAnnotationDirection( QgsComposerMap::Bottom ) );

mDistanceToMapFrameSpinBox->setValue( mComposerMap->annotationFrameDistance() );

if ( mComposerMap->showGridAnnotation() )
Expand All @@ -365,24 +384,6 @@ void QgsComposerMapWidget::updateGuiElements()
mDrawAnnotationCheckBox->setCheckState( Qt::Unchecked );
}

QgsComposerMap::GridAnnotationDirection dir = mComposerMap->gridAnnotationDirection();
if ( dir == QgsComposerMap::Horizontal )
{
mAnnotationDirectionComboBox->setCurrentIndex( mAnnotationDirectionComboBox->findText( tr( "Horizontal" ) ) );
}
else if ( dir == QgsComposerMap::Vertical )
{
mAnnotationDirectionComboBox->setCurrentIndex( mAnnotationDirectionComboBox->findText( tr( "Vertical" ) ) );
}
else if ( dir == QgsComposerMap::HorizontalAndVertical )
{
mAnnotationDirectionComboBox->setCurrentIndex( mAnnotationDirectionComboBox->findText( tr( "Horizontal and Vertical" ) ) );
}
else //BoundaryDirection
{
mAnnotationDirectionComboBox->setCurrentIndex( mAnnotationDirectionComboBox->findText( tr( "Boundary direction" ) ) );
}

mCoordinatePrecisionSpinBox->setValue( mComposerMap->gridAnnotationPrecision() );

QPen gridPen = mComposerMap->gridPen();
Expand Down Expand Up @@ -445,11 +446,19 @@ void QgsComposerMapWidget::blockAllSignals( bool b )
mLineColorButton->blockSignals( b );
mDrawAnnotationCheckBox->blockSignals( b );
mAnnotationFontButton->blockSignals( b );
mAnnotationPositionComboBox->blockSignals( b );
mAnnotationPositionLeftComboBox->blockSignals( b );
mAnnotationPositionRightComboBox->blockSignals( b );
mAnnotationPositionTopComboBox->blockSignals( b );
mAnnotationPositionBottomComboBox->blockSignals( b );
mDistanceToMapFrameSpinBox->blockSignals( b );
mAnnotationDirectionComboBox->blockSignals( b );
mAnnotationDirectionComboBoxLeft->blockSignals( b );
mAnnotationDirectionComboBoxRight->blockSignals( b );
mAnnotationDirectionComboBoxTop->blockSignals( b );
mAnnotationDirectionComboBoxBottom->blockSignals( b );
mCoordinatePrecisionSpinBox->blockSignals( b );
mDrawCanvasItemsCheckBox->blockSignals( b );
mFrameStyleComboBox->blockSignals( b );
mFrameWidthSpinBox->blockSignals( b );
}

void QgsComposerMapWidget::on_mUpdatePreviewButton_clicked()
Expand Down Expand Up @@ -683,86 +692,207 @@ void QgsComposerMapWidget::on_mDistanceToMapFrameSpinBox_valueChanged( double d
mComposerMap->endCommand();
}

void QgsComposerMapWidget::on_mAnnotationPositionComboBox_currentIndexChanged( const QString& text )
void QgsComposerMapWidget::on_mAnnotationPositionLeftComboBox_currentIndexChanged( const QString& text )
{
handleChangedAnnotationPosition( QgsComposerMap::Left, text );
}

void QgsComposerMapWidget::on_mAnnotationPositionRightComboBox_currentIndexChanged( const QString& text )
{
handleChangedAnnotationPosition( QgsComposerMap::Right, text );
}

void QgsComposerMapWidget::on_mAnnotationPositionTopComboBox_currentIndexChanged( const QString& text )
{
handleChangedAnnotationPosition( QgsComposerMap::Top, text );
}

void QgsComposerMapWidget::on_mAnnotationPositionBottomComboBox_currentIndexChanged( const QString& text )
{
handleChangedAnnotationPosition( QgsComposerMap::Bottom, text );
}

void QgsComposerMapWidget::on_mDrawAnnotationCheckBox_stateChanged( int state )
{
if ( !mComposerMap )
{
return;
}

mComposerMap->beginCommand( tr( "Annotation position changed" ) );
if ( text == tr( "Inside frame" ) )
mComposerMap->beginCommand( tr( "Annotation toggled" ) );
if ( state == Qt::Checked )
{
mComposerMap->setGridAnnotationPosition( QgsComposerMap::InsideMapFrame );
mComposerMap->setShowGridAnnotation( true );
}
else
{
mComposerMap->setGridAnnotationPosition( QgsComposerMap::OutsideMapFrame );
mComposerMap->setShowGridAnnotation( false );
}
mComposerMap->updateBoundingRect();
mComposerMap->update();
mComposerMap->endCommand();
}

void QgsComposerMapWidget::on_mDrawAnnotationCheckBox_stateChanged( int state )
void QgsComposerMapWidget::on_mAnnotationDirectionComboBoxLeft_currentIndexChanged( const QString& text )
{
handleChangedAnnotationDirection( QgsComposerMap::Left, text );
}

void QgsComposerMapWidget::on_mAnnotationDirectionComboBoxRight_currentIndexChanged( const QString& text )
{
handleChangedAnnotationDirection( QgsComposerMap::Right, text );
}

void QgsComposerMapWidget::on_mAnnotationDirectionComboBoxTop_currentIndexChanged( const QString& text )
{
handleChangedAnnotationDirection( QgsComposerMap::Top, text );
}

void QgsComposerMapWidget::on_mAnnotationDirectionComboBoxBottom_currentIndexChanged( const QString& text )
{
handleChangedAnnotationDirection( QgsComposerMap::Bottom, text );
}

void QgsComposerMapWidget::on_mCoordinatePrecisionSpinBox_valueChanged( int value )
{
if ( !mComposerMap )
{
return;
}
mComposerMap->beginCommand( tr( "Changed annotation precision" ) );
mComposerMap->setGridAnnotationPrecision( value );
mComposerMap->updateBoundingRect();
mComposerMap->update();
mComposerMap->endCommand();
}

mComposerMap->beginCommand( tr( "Annotation toggled" ) );
if ( state == Qt::Checked )
void QgsComposerMapWidget::on_mFrameStyleComboBox_currentIndexChanged( const QString& text )
{
if ( !mComposerMap )
{
mComposerMap->setShowGridAnnotation( true );
return;
}
else

mComposerMap->beginCommand( tr( "Changed grid frame style" ) );
if ( text == tr( "Zebra" ) )
{
mComposerMap->setShowGridAnnotation( false );
mComposerMap->setGridFrameStyle( QgsComposerMap::Zebra );
}
else //no frame
{
mComposerMap->setGridFrameStyle( QgsComposerMap::NoGridFrame );
}
mComposerMap->updateBoundingRect();
mComposerMap->update();
mComposerMap->endCommand();
}

void QgsComposerMapWidget::on_mAnnotationDirectionComboBox_currentIndexChanged( const QString& text )
void QgsComposerMapWidget::on_mFrameWidthSpinBox_valueChanged( double d )
{
if ( !mComposerMap )
if ( mComposerMap )
{
return;
mComposerMap->beginCommand( tr( "Changed grid frame width" ) );
mComposerMap->setGridFrameWidth( d );
mComposerMap->updateBoundingRect();
mComposerMap->update();
mComposerMap->endCommand();
}
}

mComposerMap->beginCommand( tr( "Changed annotation direction" ) );
if ( text == tr( "Horizontal" ) )
void QgsComposerMapWidget::insertAnnotationPositionEntries( QComboBox* c )
{
c->insertItem( 0, tr( "Inside frame" ) );
c->insertItem( 1, tr( "Outside frame" ) );
c->insertItem( 2, tr( "Disabled" ) );
}

void QgsComposerMapWidget::insertAnnotationDirectionEntries( QComboBox* c )
{
c->insertItem( 0, tr( "Horizontal" ) );
c->insertItem( 1, tr( "Vertical" ) );
}

void QgsComposerMapWidget::handleChangedAnnotationPosition( QgsComposerMap::Border border, const QString& text )
{
if ( !mComposerMap )
{
mComposerMap->setGridAnnotationDirection( QgsComposerMap::Horizontal );
return;
}
else if ( text == tr( "Vertical" ) )

mComposerMap->beginCommand( tr( "Annotation position changed" ) );
if ( text == tr( "Inside frame" ) )
{
mComposerMap->setGridAnnotationDirection( QgsComposerMap::Vertical );
mComposerMap->setGridAnnotationPosition( QgsComposerMap::InsideMapFrame, border );
}
else if ( text == tr( "Horizontal and Vertical" ) )
else if ( text == tr( "Disabled" ) )
{
mComposerMap->setGridAnnotationDirection( QgsComposerMap::HorizontalAndVertical );
mComposerMap->setGridAnnotationPosition( QgsComposerMap::Disabled, border );
}
else //BoundaryDirection
else //Outside frame
{
mComposerMap->setGridAnnotationDirection( QgsComposerMap::BoundaryDirection );
mComposerMap->setGridAnnotationPosition( QgsComposerMap::OutsideMapFrame, border );
}

mComposerMap->updateBoundingRect();
mComposerMap->update();
mComposerMap->endCommand();
}

void QgsComposerMapWidget::on_mCoordinatePrecisionSpinBox_valueChanged( int value )
void QgsComposerMapWidget::handleChangedAnnotationDirection( QgsComposerMap::Border border, const QString& text )
{
if ( !mComposerMap )
{
return;
}
mComposerMap->beginCommand( tr( "Changed annotation precision" ) );
mComposerMap->setGridAnnotationPrecision( value );

mComposerMap->beginCommand( tr( "Changed annotation direction" ) );
if ( text == tr( "Horizontal" ) )
{
mComposerMap->setGridAnnotationDirection( QgsComposerMap::Horizontal, border );
}
else //Vertical
{
mComposerMap->setGridAnnotationDirection( QgsComposerMap::Vertical, border );
}
mComposerMap->updateBoundingRect();
mComposerMap->update();
mComposerMap->endCommand();
}

void QgsComposerMapWidget::initAnnotationPositionBox( QComboBox* c, QgsComposerMap::GridAnnotationPosition pos )
{
if ( !c )
{
return;
}

if ( pos == QgsComposerMap::InsideMapFrame )
{
c->setCurrentIndex( c->findText( tr( "Inside frame" ) ) );
}
else if ( pos == QgsComposerMap::OutsideMapFrame )
{
c->setCurrentIndex( c->findText( tr( "Outside frame" ) ) );
}
else //disabled
{
c->setCurrentIndex( c->findText( tr( "Disabled" ) ) );
}
}

void QgsComposerMapWidget::initAnnotationDirectionBox( QComboBox* c, QgsComposerMap::GridAnnotationDirection dir )
{
if ( !c )
{
return;
}

if ( dir == QgsComposerMap::Vertical )
{
c->setCurrentIndex( c->findText( tr( "Vertical" ) ) );
}
else //horizontal
{
c->setCurrentIndex( c->findText( tr( "Horizontal" ) ) );
}
}
30 changes: 26 additions & 4 deletions src/app/composer/qgscomposermapwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
#define QGSCOMPOSERMAPWIDGET_H

#include "ui_qgscomposermapwidgetbase.h"

class QgsComposerMap;
#include "qgscomposermap.h"

/** \ingroup MapComposer
* Input widget for the configuration of QgsComposerMap
Expand Down Expand Up @@ -61,11 +60,25 @@ class QgsComposerMapWidget: public QWidget, private Ui::QgsComposerMapWidgetBase
void on_mCrossWidthSpinBox_valueChanged( double d );
void on_mAnnotationFontButton_clicked();
void on_mDistanceToMapFrameSpinBox_valueChanged( double d );
void on_mAnnotationPositionComboBox_currentIndexChanged( const QString& text );

//annotation position
void on_mAnnotationPositionLeftComboBox_currentIndexChanged( const QString& text );
void on_mAnnotationPositionRightComboBox_currentIndexChanged( const QString& text );
void on_mAnnotationPositionTopComboBox_currentIndexChanged( const QString& text );
void on_mAnnotationPositionBottomComboBox_currentIndexChanged( const QString& text );

//annotation direction
void on_mAnnotationDirectionComboBoxLeft_currentIndexChanged( const QString& text );
void on_mAnnotationDirectionComboBoxRight_currentIndexChanged( const QString& text );
void on_mAnnotationDirectionComboBoxTop_currentIndexChanged( const QString& text );
void on_mAnnotationDirectionComboBoxBottom_currentIndexChanged( const QString& text );

void on_mDrawAnnotationCheckBox_stateChanged( int state );
void on_mAnnotationDirectionComboBox_currentIndexChanged( const QString& text );
void on_mCoordinatePrecisionSpinBox_valueChanged( int value );

void on_mFrameStyleComboBox_currentIndexChanged( const QString& text );
void on_mFrameWidthSpinBox_valueChanged( double d );

private slots:

/**Sets the GUI elements to the values of mPicture*/
Expand All @@ -82,6 +95,15 @@ class QgsComposerMapWidget: public QWidget, private Ui::QgsComposerMapWidgetBase

/**Blocks / unblocks the signals of all GUI elements*/
void blockAllSignals( bool b );

void handleChangedAnnotationPosition( QgsComposerMap::Border border, const QString& text );
void handleChangedAnnotationDirection( QgsComposerMap::Border border, const QString& text );

void insertAnnotationPositionEntries( QComboBox* c );
void insertAnnotationDirectionEntries( QComboBox* c );

void initAnnotationPositionBox( QComboBox* c, QgsComposerMap::GridAnnotationPosition pos );
void initAnnotationDirectionBox( QComboBox* c, QgsComposerMap::GridAnnotationDirection dir );
};

#endif
11 changes: 10 additions & 1 deletion src/app/qgsrasterlayerproperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,18 @@ QgsRasterLayerProperties::QgsRasterLayerProperties( QgsMapLayer* lyr, QgsMapCanv
{
cboxTransparencyBand->addItem( tr( "None" ), -1 );
int nBands = provider->bandCount();
QString bandName;
for ( int i = 1; i <= nBands; ++i ) //band numbering seem to start at 1
{
cboxTransparencyBand->addItem( provider->colorInterpretationName( i ), i );
bandName = provider->colorInterpretationName( i );
if ( bandName == "Undefined" )
{
cboxTransparencyBand->addItem( provider->generateBandName( i ), i );
}
else
{
cboxTransparencyBand->addItem( bandName, i );
}
}

if ( renderer )
Expand Down
305 changes: 270 additions & 35 deletions src/core/composer/qgscomposermap.cpp

Large diffs are not rendered by default.

80 changes: 58 additions & 22 deletions src/core/composer/qgscomposermap.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ class CORE_EXPORT QgsComposerMap : public QgsComposerItem
enum GridAnnotationPosition
{
InsideMapFrame = 0,
OutsideMapFrame
OutsideMapFrame,
Disabled
};

enum GridAnnotationDirection
Expand All @@ -77,6 +78,21 @@ class CORE_EXPORT QgsComposerMap : public QgsComposerItem
BoundaryDirection
};

enum GridFrameStyle
{
NoGridFrame = 0,
Zebra //black / white pattern
};

/**Enum for different frame borders*/
enum Border
{
Left,
Right,
Bottom,
Top
};

/**This function is deprecated*/
void draw( QPainter *painter, const QgsRectangle& extent, const QSize& size, int dpi );

Expand Down Expand Up @@ -227,20 +243,26 @@ class CORE_EXPORT QgsComposerMap : public QgsComposerItem
void setShowGridAnnotation( bool show ) {mShowGridAnnotation = show;}
bool showGridAnnotation() const {return mShowGridAnnotation;}

/**Sets position of grid annotations. Possibilities are inside or outside of the map frame
@note this function was added in version 1.4*/
void setGridAnnotationPosition( GridAnnotationPosition p ) {mGridAnnotationPosition = p;}
GridAnnotationPosition gridAnnotationPosition() const {return mGridAnnotationPosition;}
void setGridAnnotationPosition( GridAnnotationPosition p, QgsComposerMap::Border border );
GridAnnotationPosition gridAnnotationPosition( QgsComposerMap::Border border ) const;

/**Sets distance between map frame and annotations
@note this function was added in version 1.4*/
void setAnnotationFrameDistance( double d ) {mAnnotationFrameDistance = d;}
double annotationFrameDistance() const {return mAnnotationFrameDistance;}

/**Sets grid annotation direction. Can be horizontal, vertical, direction of axis and horizontal and vertical
@note this function was added in version 1.4*/
void setGridAnnotationDirection( GridAnnotationDirection d ) {mGridAnnotationDirection = d;}
GridAnnotationDirection gridAnnotationDirection() const {return mGridAnnotationDirection;}
void setGridAnnotationDirection( GridAnnotationDirection d, QgsComposerMap::Border border );
GridAnnotationDirection gridAnnotationDirection( QgsComposerMap::Border border ) const;

/**Set grid frame style (NoGridFrame or Zebra)
@note: this function was added in version 1.9*/
void setGridFrameStyle( GridFrameStyle style ) { mGridFrameStyle = style; }
GridFrameStyle gridFrameStyle() const { return mGridFrameStyle; }

/**Set grid frame width
@note: this function was added in version 1.9*/
void setGridFrameWidth( double w ) { mGridFrameWidth = w; }
double gridFrameWidth() const { return mGridFrameWidth; }

/**In case of annotations, the bounding rectangle can be larger than the map item rectangle
@note this function was added in version 1.4*/
Expand Down Expand Up @@ -279,15 +301,6 @@ class CORE_EXPORT QgsComposerMap : public QgsComposerItem

private:

/**Enum for different frame borders*/
enum Border
{
Left,
Right,
Bottom,
Top
};

// Pointer to map renderer of the QGIS main map. Note that QgsComposerMap uses a different map renderer,
//it just copies some properties from the main map renderer.
QgsMapRenderer *mMapRenderer;
Expand Down Expand Up @@ -352,12 +365,31 @@ class CORE_EXPORT QgsComposerMap : public QgsComposerItem
int mGridAnnotationPrecision;
/**True if coordinate values should be drawn*/
bool mShowGridAnnotation;
/**Annotation position inside or outside of map frame*/
GridAnnotationPosition mGridAnnotationPosition;

/**Annotation position for left map side (inside / outside / not shown)*/
GridAnnotationPosition mLeftGridAnnotationPosition;
/**Annotation position for right map side (inside / outside / not shown)*/
GridAnnotationPosition mRightGridAnnotationPosition;
/**Annotation position for top map side (inside / outside / not shown)*/
GridAnnotationPosition mTopGridAnnotationPosition;
/**Annotation position for bottom map side (inside / outside / not shown)*/
GridAnnotationPosition mBottomGridAnnotationPosition;

/**Distance between map frame and annotation*/
double mAnnotationFrameDistance;
/**Annotation can be horizontal / vertical or different for axes*/
GridAnnotationDirection mGridAnnotationDirection;

/**Annotation direction on left side ( horizontal or vertical )*/
GridAnnotationDirection mLeftGridAnnotationDirection;
/**Annotation direction on right side ( horizontal or vertical )*/
GridAnnotationDirection mRightGridAnnotationDirection;
/**Annotation direction on top side ( horizontal or vertical )*/
GridAnnotationDirection mTopGridAnnotationDirection;
/**Annotation direction on bottom side ( horizontal or vertical )*/
GridAnnotationDirection mBottomGridAnnotationDirection;

GridFrameStyle mGridFrameStyle;
double mGridFrameWidth;

/**Current bounding rectangle. This is used to check if notification to the graphics scene is necessary*/
QRectF mCurrentRectangle;
/**The length of the cross sides for mGridStyle Cross*/
Expand All @@ -368,6 +400,7 @@ class CORE_EXPORT QgsComposerMap : public QgsComposerItem

/**Draws the map grid*/
void drawGrid( QPainter* p );
void drawGridFrame( QPainter* p, const QList< QPair< double, QLineF > >& hLines, const QList< QPair< double, QLineF > >& vLines );
/**Draw coordinates for mGridAnnotationType Coordinate
@param p drawing painter
@param hLines horizontal coordinate lines in item coordinates
Expand Down Expand Up @@ -409,6 +442,9 @@ class CORE_EXPORT QgsComposerMap : public QgsComposerItem
void drawCanvasItems( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle );
void drawCanvasItem( QGraphicsItem* item, QPainter* painter, const QStyleOptionGraphicsItem* itemStyle );
QPointF composerMapPosForItem( const QGraphicsItem* item ) const;
void sortGridLinesOnBorders( const QList< QPair< double, QLineF > >& hLines, const QList< QPair< double, QLineF > >& vLines, QMap< double, double >& leftFrameEntries,
QMap< double, double >& rightFrameEntries, QMap< double, double >& topFrameEntries, QMap< double, double >& bottomFrameEntries ) const;
void drawGridFrameBorder( QPainter* p, const QMap< double, double >& borderPos, Border border );
};

#endif
56 changes: 56 additions & 0 deletions src/core/qgsprojectfiletransform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,62 @@ void QgsProjectFileTransform::transform1800to1900()
rasterLayer.readXML( layerNode );
convertRasterProperties( mDom, layerNode, rasterPropertiesElem, &rasterLayer );
}

//composer: replace mGridAnnotationPosition with mLeftGridAnnotationPosition & co.
// and mGridAnnotationDirection with mLeftGridAnnotationDirection & co.
QDomNodeList composerMapList = mDom.elementsByTagName( "ComposerMap" );
for ( int i = 0; i < composerMapList.size(); ++i )
{
QDomNodeList gridList = composerMapList.at( i ).toElement().elementsByTagName( "Grid" );
for ( int j = 0; j < gridList.size(); ++j )
{
QDomNodeList annotationList = gridList.at( j ).toElement().elementsByTagName( "Annotation" );
for ( int k = 0; k < annotationList.size(); ++k )
{
QDomElement annotationElem = annotationList.at( k ).toElement();

//position
if ( annotationElem.hasAttribute( "position" ) )
{
int pos = annotationElem.attribute( "position" ).toInt();
annotationElem.setAttribute( "leftPosition", pos );
annotationElem.setAttribute( "rightPosition", pos );
annotationElem.setAttribute( "topPosition", pos );
annotationElem.setAttribute( "bottomPosition", pos );
annotationElem.removeAttribute( "position" );
}

//direction
if ( annotationElem.hasAttribute( "direction" ) )
{
int dir = annotationElem.attribute( "direction" ).toInt();
if ( dir == 2 )
{
annotationElem.setAttribute( "leftDirection", 0 );
annotationElem.setAttribute( "rightDirection", 0 );
annotationElem.setAttribute( "topDirection", 1 );
annotationElem.setAttribute( "bottomDirection", 1 );
}
else if ( dir == 3 )
{
annotationElem.setAttribute( "leftDirection", 1 );
annotationElem.setAttribute( "rightDirection", 1 );
annotationElem.setAttribute( "topDirection", 0 );
annotationElem.setAttribute( "bottomDirection", 0 );
}
else
{
annotationElem.setAttribute( "leftDirection", dir );
annotationElem.setAttribute( "rightDirection", dir );
annotationElem.setAttribute( "topDirection", dir );
annotationElem.setAttribute( "bottomDirection", dir );
}
annotationElem.removeAttribute( "direction" );
}
}
}
}

QgsDebugMsg( mDom.toString() );
}

Expand Down
12 changes: 3 additions & 9 deletions src/providers/spatialite/qgsspatialiteprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3600,13 +3600,6 @@ bool QgsSpatiaLiteProvider::addFeatures( QgsFeatureList & flist )
values = QString( ") VALUES (" );
separator = "";

if ( !mPrimaryKey.isEmpty() )
{
sql += separator + quotedIdentifier( mPrimaryKey );
values += separator + "NULL";
separator = ",";
}

if ( !mGeometryColumn.isNull() )
{
sql += separator + quotedIdentifier( mGeometryColumn );
Expand All @@ -3621,11 +3614,12 @@ bool QgsSpatiaLiteProvider::addFeatures( QgsFeatureList & flist )
continue;

QString fieldname = fit->name();
if ( fieldname.isEmpty() || fieldname == mGeometryColumn || fieldname == mPrimaryKey )
if ( fieldname.isEmpty() || fieldname == mGeometryColumn )
continue;

sql += separator + quotedIdentifier( fieldname );
values += separator + "?";
separator = ",";
}

sql += values;
Expand Down Expand Up @@ -3673,7 +3667,7 @@ bool QgsSpatiaLiteProvider::addFeatures( QgsFeatureList & flist )
continue;

QString fieldname = fit->name();
if ( fieldname.isEmpty() || fieldname == mGeometryColumn || fieldname == mPrimaryKey )
if ( fieldname.isEmpty() || fieldname == mGeometryColumn )
continue;

QVariant::Type type = fit->type();
Expand Down
2 changes: 2 additions & 0 deletions src/providers/spatialite/qgsspatialitesourceselect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,8 @@ void QgsSpatiaLiteSourceSelect::setConnectionListPosition()
// If possible, set the item currently displayed database
QString toSelect = settings.value( "/SpatiaLite/connections/selected" ).toString();

toSelect += "@" + settings.value( "/SpatiaLite/connections/" + toSelect + "/sqlitepath" ).toString();

cmbConnections->setCurrentIndex( cmbConnections->findText( toSelect ) );

if ( cmbConnections->currentIndex() < 0 )
Expand Down
552 changes: 331 additions & 221 deletions src/ui/qgscomposermapwidgetbase.ui

Large diffs are not rendered by default.