Skip to content
Permalink
Browse files
Merge branch 'master' of github.com:qgis/Quantum-GIS
  • Loading branch information
timlinux committed Nov 30, 2011
2 parents 2bd2d84 + 8e4e8e1 commit ff4c360fb9b1dbebe40b91e973c5b1d590e48c43

Large diffs are not rendered by default.

@@ -9,6 +9,14 @@ class QgsComposerScaleBar: QgsComposerItem
%End
public:

/**Added in version 1.8*/
enum Alignment
{
Left = 0,
Middle,
Right
};

QgsComposerScaleBar( QgsComposition* composition /TransferThis/);
~QgsComposerScaleBar();

@@ -58,6 +66,13 @@ class QgsComposerScaleBar: QgsComposerItem

double segmentMillimeters() const;

/**Left / Middle/ Right
@note: this method was added in version 1.8*/
Alignment alignment() const;

/**@note: this method was added in version 1.8*/
void setAlignment( Alignment a );

/**Apply default settings*/
void applyDefaultSettings();
/**Apply default size (scale bar 1/5 of map item width)
@@ -31,12 +31,19 @@ QgsComposerScaleBarWidget::QgsComposerScaleBarWidget( QgsComposerScaleBar* scale
toolBox->addItem( itemPropertiesWidget, tr( "General options" ) );

blockMemberSignals( true );

//style combo box
mStyleComboBox->insertItem( 0, tr( "Single Box" ) );
mStyleComboBox->insertItem( 1, tr( "Double Box" ) );
mStyleComboBox->insertItem( 2, tr( "Line Ticks Middle" ) );
mStyleComboBox->insertItem( 3, tr( "Line Ticks Down" ) );
mStyleComboBox->insertItem( 4, tr( "Line Ticks Up" ) );
mStyleComboBox->insertItem( 5, tr( "Numeric" ) );

mAlignmentComboBox->insertItem( 0, tr( "Left" ) );
mAlignmentComboBox->insertItem( 1, tr( "Middle" ) );
mAlignmentComboBox->insertItem( 2, tr( "Right" ) );

setGuiElements(); //set the GUI elements to the state of scaleBar
blockMemberSignals( false );
}
@@ -161,6 +168,9 @@ void QgsComposerScaleBarWidget::setGuiElements()
//style...
QString style = mComposerScaleBar->style();
mStyleComboBox->setCurrentIndex( mStyleComboBox->findText( tr( style.toLocal8Bit().data() ) ) );

//alignment
mAlignmentComboBox->setCurrentIndex(( int )( mComposerScaleBar->alignment() ) );
}

//slots
@@ -371,6 +381,18 @@ void QgsComposerScaleBarWidget::on_mBoxSizeSpinBox_valueChanged( double d )
mComposerScaleBar->endCommand();
}

void QgsComposerScaleBarWidget::on_mAlignmentComboBox_currentIndexChanged( int index )
{
if ( !mComposerScaleBar )
{
return;
}

mComposerScaleBar->beginCommand( tr( "Scalebar alignment" ) );
mComposerScaleBar->setAlignment(( QgsComposerScaleBar::Alignment ) index );
mComposerScaleBar->endCommand();
}

void QgsComposerScaleBarWidget::blockMemberSignals( bool block )
{
mSegmentSizeSpinBox->blockSignals( block );
@@ -384,4 +406,5 @@ void QgsComposerScaleBarWidget::blockMemberSignals( bool block )
mLineWidthSpinBox->blockSignals( block );
mLabelBarSpaceSpinBox->blockSignals( block );
mBoxSizeSpinBox->blockSignals( block );
mAlignmentComboBox->blockSignals( block );
}
@@ -46,6 +46,7 @@ class QgsComposerScaleBarWidget: public QWidget, private Ui::QgsComposerScaleBar
void on_mStyleComboBox_currentIndexChanged( const QString& text );
void on_mLabelBarSpaceSpinBox_valueChanged( double d );
void on_mBoxSizeSpinBox_valueChanged( double d );
void on_mAlignmentComboBox_currentIndexChanged( int index );


protected:
@@ -39,7 +39,10 @@ QgsComposerShapeWidget::QgsComposerShapeWidget( QgsComposerShape* composerShape

blockAllSignals( false );

connect( mShapeComboBox, SIGNAL( currentIndexChanged( int ) ), this, SLOT( setGuiElementValues() ) );
if ( mComposerShape )
{
connect( mComposerShape, SIGNAL( itemChanged() ), this, SLOT( setGuiElementValues() ) );
}
}

QgsComposerShapeWidget::~QgsComposerShapeWidget()
@@ -38,8 +38,8 @@ QgsLayerOrder::QgsLayerOrder( QgsLegend *legend, QWidget * parent, const char *n
this, SLOT( legendItemChanged( QTreeWidgetItem *, int ) ) );

// track if legend mode changes
connect( mLegend, SIGNAL( updateDrawingOrderChanged( bool ) ),
this, SLOT( updateDrawingOrderChanged( bool ) ) );
connect( mLegend, SIGNAL( updateDrawingOrderChecked( bool ) ),
this, SLOT( updateDrawingOrderChecked( bool ) ) );

connect( mLegend, SIGNAL( zOrderChanged() ),
this, SLOT( refreshLayerList() ) );
@@ -64,13 +64,13 @@ QgsLayerOrder::QgsLayerOrder( QgsLegend *legend, QWidget * parent, const char *n
setSelectionMode( QAbstractItemView::ExtendedSelection );
setDragEnabled( false );
setAutoScroll( true );
QFont f( "Arial", 12, QFont::Bold );
QFont f( "Arial", 11, QFont::Bold );
setFont( f );
QPalette palette;
palette.setColor( backgroundRole(), QColor( 192, 192, 192 ) );
setPalette( palette );

updateDrawingOrderChanged( mLegend->updateDrawingOrder() );
updateDrawingOrderChecked( mLegend->updateDrawingOrder() );
}

QgsLayerOrder::~QgsLayerOrder()
@@ -82,11 +82,12 @@ void QgsLayerOrder::refreshLayerList()
{
clear();

foreach( QgsMapLayer *layer, mLegend->layers() )
foreach( QgsLegendLayer *layer, mLegend->legendLayers() )
{
QListWidgetItem *item = new QListWidgetItem( layer->name() );
item->setData( Qt::UserRole, qVariantFromValue( qobject_cast<QObject*>( layer ) ) );
item->setCheckState( mLegend->layerCheckState( layer ) );
QListWidgetItem *item = new QListWidgetItem( layer->layer()->name() );
item->setData( 1, QString::number( layer->drawingOrder() ) );
item->setData( Qt::UserRole, qVariantFromValue( qobject_cast<QObject*>( layer->layer() ) ) );
item->setCheckState( layer->isVisible() ? Qt::Checked : Qt::Unchecked );
QgsDebugMsg( QString( "add item=%1 at %2" ).arg( item ? item->text() : "(null item)" ).arg( count() ) );
addItem( item );
}
@@ -189,16 +190,19 @@ void QgsLayerOrder::mouseMoveEvent( QMouseEvent * e )
{
mInsertRow = row( rowItem );
QgsDebugMsg( QString( "Move to row %1" ).arg( mInsertRow ) );
scrollToItem( rowItem );
}
else if ( e->pos().y() < visualItemRect( item( 0 ) ).bottom() )
{
mInsertRow = 0;
QgsDebugMsg( QString( "Insert top row %1" ).arg( mInsertRow ) );
scrollToTop();
}
else
{
mInsertRow = count();
QgsDebugMsg( QString( "Append bottom row %1" ).arg( mInsertRow ) );
scrollToBottom();
}

int y;
@@ -269,7 +273,7 @@ void QgsLayerOrder::hideLine()
mInsertionLine->setGeometry( 0, -100, 1, 1 );
}

void QgsLayerOrder::updateDrawingOrderChanged( bool enabled )
void QgsLayerOrder::updateDrawingOrderChecked( bool enabled )
{
setDisabled( enabled );
}
@@ -46,7 +46,7 @@ class QgsLayerOrder : public QListWidget
void mouseReleaseEvent( QMouseEvent * e );

private slots:
void updateDrawingOrderChanged( bool );
void updateDrawingOrderChecked( bool );
void itemChanged( QListWidgetItem * );
void legendItemChanged( QTreeWidgetItem *, int );
void refreshLayerList();
@@ -1403,7 +1403,8 @@ bool QgsLegend::readXML( QDomNode& legendnode )
clear(); //remove all items first
mEmbeddedGroups.clear();
mUpdateDrawingOrder = legendnode.toElement().attribute( "updateDrawingOrder", "true" ) == "true";
emit updateDrawingOrderChanged( mUpdateDrawingOrder );
emit updateDrawingOrderChecked( mUpdateDrawingOrder );
emit updateDrawingOrderUnchecked( !mUpdateDrawingOrder );
return readXML( 0, legendnode );
}

@@ -2356,7 +2357,8 @@ void QgsLegend::setUpdateDrawingOrder( bool updateDrawingOrder )

updateMapCanvasLayerSet();

emit updateDrawingOrderChanged( mUpdateDrawingOrder );
emit updateDrawingOrderChecked( mUpdateDrawingOrder );
emit updateDrawingOrderUnchecked( !mUpdateDrawingOrder );
}

bool QgsLegend::updateDrawingOrder()
@@ -116,6 +116,9 @@ class QgsLegend : public QTreeWidget
Else, an empty list is returned.*/
QList<QgsMapLayer *> layers();

//!Return all layers in drawing order
QList<QgsLegendLayer *> legendLayers();

void setDrawingOrder( QList<QgsMapLayer *> );

/*!set the current layer
@@ -307,6 +310,9 @@ class QgsLegend : public QTreeWidget
/** Update drawing order */
void setUpdateDrawingOrder( bool updateDrawingOrder );

/** Update drawing order */
void unsetUpdateDrawingOrder( bool dontUpdateDrawingOrder ) { setUpdateDrawingOrder( !dontUpdateDrawingOrder ); }

protected:

/*!Event handler for mouse movements.
@@ -432,7 +438,6 @@ class QgsLegend : public QTreeWidget
bool writeXML( QList<QTreeWidgetItem *> items, QDomNode &node, QDomDocument &document );

QList<QgsMapCanvasLayer> canvasLayers();
QList<QgsLegendLayer *> legendLayers();

/*! Prevent the copying of QgsLegends
* @todo See if this is really required - we may want multiple map, canvas and
@@ -511,7 +516,8 @@ class QgsLegend : public QTreeWidget

void zOrderChanged();

void updateDrawingOrderChanged( bool );
void updateDrawingOrderChecked( bool );
void updateDrawingOrderUnchecked( bool );

//! Emitted whenever current (selected) layer changes
// the pointer to layer can be null if no layer is selected
@@ -1716,19 +1716,45 @@ void QgisApp::initLegend()
mLegendDock = new QDockWidget( tr( "Layers" ), this );
mLegendDock->setObjectName( "Legend" );
mLegendDock->setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea );
mLegendDock->setWidget( mMapLegend );

QCheckBox *legendCb = new QCheckBox( tr( "Control rendering order" ) );
legendCb->setChecked( true );

QCheckBox *orderCb = new QCheckBox( tr( "Control rendering order" ) );
orderCb->setChecked( false );

connect( legendCb, SIGNAL( toggled( bool ) ), mMapLegend, SLOT( setUpdateDrawingOrder( bool ) ) );
connect( orderCb, SIGNAL( toggled( bool ) ), mMapLegend, SLOT( unsetUpdateDrawingOrder( bool ) ) );
connect( mMapLegend, SIGNAL( updateDrawingOrderChecked( bool ) ), legendCb, SLOT( setChecked( bool ) ) );
connect( mMapLegend, SIGNAL( updateDrawingOrderUnchecked( bool ) ), orderCb, SLOT( setChecked( bool ) ) );

QWidget *w = new QWidget( this );
QLayout *l = new QVBoxLayout;
l->addWidget( mMapLegend );
l->addWidget( legendCb );
w->setLayout( l );
mLegendDock->setWidget( w );
addDockWidget( Qt::LeftDockWidgetArea, mLegendDock );

// add to the Panel submenu
mPanelMenu->addAction( mLegendDock->toggleViewAction() );

mMapLayerOrder->setWhatsThis( tr( "Map layer list that displays all layers in drawing order." ) );
mLayerOrderDock = new QDockWidget( tr( "Layerorder" ), this );
mLayerOrderDock = new QDockWidget( tr( "Layer order" ), this );
mLayerOrderDock->setObjectName( "Legend" );
mLayerOrderDock->setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea );
mLayerOrderDock->setWidget( mMapLayerOrder );

w = new QWidget( this );
l = new QVBoxLayout;
l->addWidget( mMapLayerOrder );
l->addWidget( orderCb );
w->setLayout( l );
mLayerOrderDock->setWidget( w );
addDockWidget( Qt::LeftDockWidgetArea, mLayerOrderDock );

// add to the Panel submenu
mPanelMenu->addAction( mLayerOrderDock->toggleViewAction() );

return;
}

0 comments on commit ff4c360

Please sign in to comment.