Skip to content

Commit

Permalink
More cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
marco committed Dec 5, 2011
1 parent c9bcd60 commit a5f15d8
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 108 deletions.
14 changes: 0 additions & 14 deletions python/gui/qgscomposerview.sip
Expand Up @@ -70,23 +70,9 @@ class QgsComposerView: QGraphicsView
void wheelEvent( QWheelEvent* event );


public slots:
/**Casts object to the proper subclass type and calls corresponding itemAdded signal*/
void sendItemAddedSignal( QgsComposerItem* item );

signals:
/**Is emitted when selected item changed. If 0, no item is selected*/
void selectedItemChanged( QgsComposerItem* selected );
/**Ist emittted when new composer label has been added to the view*/
void composerLabelAdded( QgsComposerLabel* label );
/**Is emitted when new composer map has been added to the view*/
void composerMapAdded( QgsComposerMap* map );
/**Is emitted when new composer scale bar has been added*/
void composerScaleBarAdded( QgsComposerScaleBar* scalebar );
/**Is emitted when a new composer legend has been added*/
void composerLegendAdded( QgsComposerLegend* legend );
/**Is emitted when a new composer picture has been added*/
void composerPictureAdded( QgsComposerPicture* picture );
/**Is emitted when a composer item has been removed from the scene*/
void itemRemoved( QgsComposerItem* );
/**Current action (e.g. adding composer map) has been finished. The purpose of this signal is that
Expand Down
9 changes: 1 addition & 8 deletions src/app/composer/qgscomposer.cpp
Expand Up @@ -316,15 +316,7 @@ void QgsComposer::setIconSizes( int size )
void QgsComposer::connectSlots()
{
connect( mView, SIGNAL( selectedItemChanged( QgsComposerItem* ) ), this, SLOT( showItemOptions( QgsComposerItem* ) ) );
connect( mView, SIGNAL( composerLabelAdded( QgsComposerLabel* ) ), this, SLOT( addComposerLabel( QgsComposerLabel* ) ) );
connect( mView, SIGNAL( composerMapAdded( QgsComposerMap* ) ), this, SLOT( addComposerMap( QgsComposerMap* ) ) );
connect( mView, SIGNAL( itemRemoved( QgsComposerItem* ) ), this, SLOT( deleteItem( QgsComposerItem* ) ) );
connect( mView, SIGNAL( composerScaleBarAdded( QgsComposerScaleBar* ) ), this, SLOT( addComposerScaleBar( QgsComposerScaleBar* ) ) );
connect( mView, SIGNAL( composerLegendAdded( QgsComposerLegend* ) ), this, SLOT( addComposerLegend( QgsComposerLegend* ) ) );
connect( mView, SIGNAL( composerPictureAdded( QgsComposerPicture* ) ), this, SLOT( addComposerPicture( QgsComposerPicture* ) ) );
connect( mView, SIGNAL( composerShapeAdded( QgsComposerShape* ) ), this, SLOT( addComposerShape( QgsComposerShape* ) ) );
connect( mView, SIGNAL( composerArrowAdded( QgsComposerArrow* ) ), this, SLOT( addComposerArrow( QgsComposerArrow* ) ) );
connect( mView, SIGNAL( composerTableAdded( QgsComposerAttributeTable* ) ), this, SLOT( addComposerTable( QgsComposerAttributeTable* ) ) );
connect( mView, SIGNAL( actionFinished() ), this, SLOT( setSelectionTool() ) );

connect( mComposition, SIGNAL( selectedItemChanged( QgsComposerItem* ) ), this, SLOT( showItemOptions( QgsComposerItem* ) ) );
Expand All @@ -336,6 +328,7 @@ void QgsComposer::connectSlots()
connect( mComposition, SIGNAL( composerPictureAdded( QgsComposerPicture* ) ), this, SLOT( addComposerPicture( QgsComposerPicture* ) ) );
connect( mComposition, SIGNAL( composerShapeAdded( QgsComposerShape* ) ), this, SLOT( addComposerShape( QgsComposerShape* ) ) );
connect( mComposition, SIGNAL( composerTableAdded( QgsComposerAttributeTable* ) ), this, SLOT( addComposerTable( QgsComposerAttributeTable* ) ) );
connect( mComposition, SIGNAL( itemRemoved( QgsComposerItem* ) ), this, SLOT( deleteItem( QgsComposerItem* ) ) );
}

void QgsComposer::open( void )
Expand Down
62 changes: 62 additions & 0 deletions src/core/composer/qgscomposition.cpp
Expand Up @@ -1045,3 +1045,65 @@ void QgsComposition::addComposerTable( QgsComposerAttributeTable* table )
emit selectedItemChanged( table );
//pushAddRemoveCommand( table, tr( "Table added" ) );
}

void QgsComposition::sendItemAddedSignal( QgsComposerItem* item )
{
//cast and send proper signal
item->setSelected( true );
QgsComposerArrow* arrow = dynamic_cast<QgsComposerArrow*>( item );
if ( arrow )
{
emit composerArrowAdded( arrow );
emit selectedItemChanged( arrow );
return;
}
QgsComposerLabel* label = dynamic_cast<QgsComposerLabel*>( item );
if ( label )
{
emit composerLabelAdded( label );
emit selectedItemChanged( label );
return;
}
QgsComposerMap* map = dynamic_cast<QgsComposerMap*>( item );
if ( map )
{
emit composerMapAdded( map );
emit selectedItemChanged( map );
return;
}
QgsComposerScaleBar* scalebar = dynamic_cast<QgsComposerScaleBar*>( item );
if ( scalebar )
{
emit composerScaleBarAdded( scalebar );
emit selectedItemChanged( scalebar );
return;
}
QgsComposerLegend* legend = dynamic_cast<QgsComposerLegend*>( item );
if ( legend )
{
emit composerLegendAdded( legend );
emit selectedItemChanged( legend );
return;
}
QgsComposerPicture* picture = dynamic_cast<QgsComposerPicture*>( item );
if ( picture )
{
emit composerPictureAdded( picture );
emit selectedItemChanged( picture );
return;
}
QgsComposerShape* shape = dynamic_cast<QgsComposerShape*>( item );
if ( shape )
{
emit composerShapeAdded( shape );
emit selectedItemChanged( shape );
return;
}
QgsComposerAttributeTable* table = dynamic_cast<QgsComposerAttributeTable*>( item );
if ( table )
{
emit composerTableAdded( table );
emit selectedItemChanged( table );
return;
}
}
6 changes: 6 additions & 0 deletions src/core/composer/qgscomposition.h
Expand Up @@ -204,6 +204,10 @@ class CORE_EXPORT QgsComposition: public QGraphicsScene
/**Adds a composer table to the graphics scene and advices composer to create a widget for it (through signal)*/
void addComposerTable( QgsComposerAttributeTable* table );

public slots:
/**Casts object to the proper subclass type and calls corresponding itemAdded signal*/
void sendItemAddedSignal( QgsComposerItem* item );

private:
/**Pointer to map renderer of QGIS main map*/
QgsMapRenderer* mMapRenderer;
Expand Down Expand Up @@ -267,6 +271,8 @@ class CORE_EXPORT QgsComposition: public QGraphicsScene
void composerShapeAdded( QgsComposerShape* shape );
/**Is emitted when a new composer table has been added*/
void composerTableAdded( QgsComposerAttributeTable* table );
/**Is emitted when a composer item has been removed from the scene*/
void itemRemoved( QgsComposerItem* );
};

#endif
Expand Down
70 changes: 6 additions & 64 deletions src/gui/qgscomposerview.cpp
Expand Up @@ -655,68 +655,6 @@ void QgsComposerView::ungroupItems()
}
}

void QgsComposerView::sendItemAddedSignal( QgsComposerItem* item )
{
//cast and send proper signal
item->setSelected( true );
QgsComposerArrow* arrow = dynamic_cast<QgsComposerArrow*>( item );
if ( arrow )
{
emit composerArrowAdded( arrow );
emit selectedItemChanged( arrow );
return;
}
QgsComposerLabel* label = dynamic_cast<QgsComposerLabel*>( item );
if ( label )
{
emit composerLabelAdded( label );
emit selectedItemChanged( label );
return;
}
QgsComposerMap* map = dynamic_cast<QgsComposerMap*>( item );
if ( map )
{
emit composerMapAdded( map );
emit selectedItemChanged( map );
return;
}
QgsComposerScaleBar* scalebar = dynamic_cast<QgsComposerScaleBar*>( item );
if ( scalebar )
{
emit composerScaleBarAdded( scalebar );
emit selectedItemChanged( scalebar );
return;
}
QgsComposerLegend* legend = dynamic_cast<QgsComposerLegend*>( item );
if ( legend )
{
emit composerLegendAdded( legend );
emit selectedItemChanged( legend );
return;
}
QgsComposerPicture* picture = dynamic_cast<QgsComposerPicture*>( item );
if ( picture )
{
emit composerPictureAdded( picture );
emit selectedItemChanged( picture );
return;
}
QgsComposerShape* shape = dynamic_cast<QgsComposerShape*>( item );
if ( shape )
{
emit composerShapeAdded( shape );
emit selectedItemChanged( shape );
return;
}
QgsComposerAttributeTable* table = dynamic_cast<QgsComposerAttributeTable*>( item );
if ( table )
{
emit composerTableAdded( table );
emit selectedItemChanged( table );
return;
}
}

QMainWindow* QgsComposerView::composerWindow()
{
QMainWindow* composerObject = 0;
Expand Down Expand Up @@ -745,8 +683,12 @@ void QgsComposerView::connectAddRemoveCommandSignals( QgsAddRemoveItemCommand* c
{
return;
}
QObject::connect( c, SIGNAL( itemRemoved( QgsComposerItem* ) ), this, SIGNAL( itemRemoved( QgsComposerItem* ) ) );
QObject::connect( c, SIGNAL( itemAdded( QgsComposerItem* ) ), this, SLOT( sendItemAddedSignal( QgsComposerItem* ) ) );

if ( composition() )
{
QObject::connect( c, SIGNAL( itemRemoved( QgsComposerItem* ) ), composition(), SIGNAL( itemRemoved( QgsComposerItem* ) ) );
QObject::connect( c, SIGNAL( itemAdded( QgsComposerItem* ) ), composition(), SLOT( sendItemAddedSignal( QgsComposerItem* ) ) );
}
}

void QgsComposerView::pushAddRemoveCommand( QgsComposerItem* item, const QString& text, QgsAddRemoveItemCommand::State state )
Expand Down
22 changes: 0 additions & 22 deletions src/gui/qgscomposerview.h
Expand Up @@ -128,31 +128,9 @@ class GUI_EXPORT QgsComposerView: public QGraphicsView

void connectAddRemoveCommandSignals( QgsAddRemoveItemCommand* c );


public slots:
/**Casts object to the proper subclass type and calls corresponding itemAdded signal*/
void sendItemAddedSignal( QgsComposerItem* item );

signals:
/**Is emitted when selected item changed. If 0, no item is selected*/
void selectedItemChanged( QgsComposerItem* selected );
/**Is emitted when new composer arrow has been added to the view*/
void composerArrowAdded( QgsComposerArrow* arrow );
/**Is emitted when new composer label has been added to the view*/
void composerLabelAdded( QgsComposerLabel* label );
/**Is emitted when new composer map has been added to the view*/
void composerMapAdded( QgsComposerMap* map );
/**Is emitted when new composer scale bar has been added*/
void composerScaleBarAdded( QgsComposerScaleBar* scalebar );
/**Is emitted when a new composer legend has been added*/
void composerLegendAdded( QgsComposerLegend* legend );
/**Is emitted when a new composer picture has been added*/
void composerPictureAdded( QgsComposerPicture* picture );
/**Is emitted when a new composer shape has been added*/
void composerShapeAdded( QgsComposerShape* shape );
/**Is emitted when a new composer table has been added*/
void composerTableAdded( QgsComposerAttributeTable* table );
/**Is emitted when a composer item has been removed from the scene*/
void itemRemoved( QgsComposerItem* );
/**Current action (e.g. adding composer map) has been finished. The purpose of this signal is that
QgsComposer may set the selection tool again*/
Expand Down

0 comments on commit a5f15d8

Please sign in to comment.