Skip to content

Commit a5f15d8

Browse files
author
marco
committedDec 5, 2011
More cleanups
1 parent c9bcd60 commit a5f15d8

File tree

6 files changed

+75
-108
lines changed

6 files changed

+75
-108
lines changed
 

‎python/gui/qgscomposerview.sip

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -70,23 +70,9 @@ class QgsComposerView: QGraphicsView
7070
void wheelEvent( QWheelEvent* event );
7171

7272

73-
public slots:
74-
/**Casts object to the proper subclass type and calls corresponding itemAdded signal*/
75-
void sendItemAddedSignal( QgsComposerItem* item );
76-
7773
signals:
7874
/**Is emitted when selected item changed. If 0, no item is selected*/
7975
void selectedItemChanged( QgsComposerItem* selected );
80-
/**Ist emittted when new composer label has been added to the view*/
81-
void composerLabelAdded( QgsComposerLabel* label );
82-
/**Is emitted when new composer map has been added to the view*/
83-
void composerMapAdded( QgsComposerMap* map );
84-
/**Is emitted when new composer scale bar has been added*/
85-
void composerScaleBarAdded( QgsComposerScaleBar* scalebar );
86-
/**Is emitted when a new composer legend has been added*/
87-
void composerLegendAdded( QgsComposerLegend* legend );
88-
/**Is emitted when a new composer picture has been added*/
89-
void composerPictureAdded( QgsComposerPicture* picture );
9076
/**Is emitted when a composer item has been removed from the scene*/
9177
void itemRemoved( QgsComposerItem* );
9278
/**Current action (e.g. adding composer map) has been finished. The purpose of this signal is that

‎src/app/composer/qgscomposer.cpp

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -316,15 +316,7 @@ void QgsComposer::setIconSizes( int size )
316316
void QgsComposer::connectSlots()
317317
{
318318
connect( mView, SIGNAL( selectedItemChanged( QgsComposerItem* ) ), this, SLOT( showItemOptions( QgsComposerItem* ) ) );
319-
connect( mView, SIGNAL( composerLabelAdded( QgsComposerLabel* ) ), this, SLOT( addComposerLabel( QgsComposerLabel* ) ) );
320-
connect( mView, SIGNAL( composerMapAdded( QgsComposerMap* ) ), this, SLOT( addComposerMap( QgsComposerMap* ) ) );
321319
connect( mView, SIGNAL( itemRemoved( QgsComposerItem* ) ), this, SLOT( deleteItem( QgsComposerItem* ) ) );
322-
connect( mView, SIGNAL( composerScaleBarAdded( QgsComposerScaleBar* ) ), this, SLOT( addComposerScaleBar( QgsComposerScaleBar* ) ) );
323-
connect( mView, SIGNAL( composerLegendAdded( QgsComposerLegend* ) ), this, SLOT( addComposerLegend( QgsComposerLegend* ) ) );
324-
connect( mView, SIGNAL( composerPictureAdded( QgsComposerPicture* ) ), this, SLOT( addComposerPicture( QgsComposerPicture* ) ) );
325-
connect( mView, SIGNAL( composerShapeAdded( QgsComposerShape* ) ), this, SLOT( addComposerShape( QgsComposerShape* ) ) );
326-
connect( mView, SIGNAL( composerArrowAdded( QgsComposerArrow* ) ), this, SLOT( addComposerArrow( QgsComposerArrow* ) ) );
327-
connect( mView, SIGNAL( composerTableAdded( QgsComposerAttributeTable* ) ), this, SLOT( addComposerTable( QgsComposerAttributeTable* ) ) );
328320
connect( mView, SIGNAL( actionFinished() ), this, SLOT( setSelectionTool() ) );
329321

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

341334
void QgsComposer::open( void )

‎src/core/composer/qgscomposition.cpp

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,3 +1045,65 @@ void QgsComposition::addComposerTable( QgsComposerAttributeTable* table )
10451045
emit selectedItemChanged( table );
10461046
//pushAddRemoveCommand( table, tr( "Table added" ) );
10471047
}
1048+
1049+
void QgsComposition::sendItemAddedSignal( QgsComposerItem* item )
1050+
{
1051+
//cast and send proper signal
1052+
item->setSelected( true );
1053+
QgsComposerArrow* arrow = dynamic_cast<QgsComposerArrow*>( item );
1054+
if ( arrow )
1055+
{
1056+
emit composerArrowAdded( arrow );
1057+
emit selectedItemChanged( arrow );
1058+
return;
1059+
}
1060+
QgsComposerLabel* label = dynamic_cast<QgsComposerLabel*>( item );
1061+
if ( label )
1062+
{
1063+
emit composerLabelAdded( label );
1064+
emit selectedItemChanged( label );
1065+
return;
1066+
}
1067+
QgsComposerMap* map = dynamic_cast<QgsComposerMap*>( item );
1068+
if ( map )
1069+
{
1070+
emit composerMapAdded( map );
1071+
emit selectedItemChanged( map );
1072+
return;
1073+
}
1074+
QgsComposerScaleBar* scalebar = dynamic_cast<QgsComposerScaleBar*>( item );
1075+
if ( scalebar )
1076+
{
1077+
emit composerScaleBarAdded( scalebar );
1078+
emit selectedItemChanged( scalebar );
1079+
return;
1080+
}
1081+
QgsComposerLegend* legend = dynamic_cast<QgsComposerLegend*>( item );
1082+
if ( legend )
1083+
{
1084+
emit composerLegendAdded( legend );
1085+
emit selectedItemChanged( legend );
1086+
return;
1087+
}
1088+
QgsComposerPicture* picture = dynamic_cast<QgsComposerPicture*>( item );
1089+
if ( picture )
1090+
{
1091+
emit composerPictureAdded( picture );
1092+
emit selectedItemChanged( picture );
1093+
return;
1094+
}
1095+
QgsComposerShape* shape = dynamic_cast<QgsComposerShape*>( item );
1096+
if ( shape )
1097+
{
1098+
emit composerShapeAdded( shape );
1099+
emit selectedItemChanged( shape );
1100+
return;
1101+
}
1102+
QgsComposerAttributeTable* table = dynamic_cast<QgsComposerAttributeTable*>( item );
1103+
if ( table )
1104+
{
1105+
emit composerTableAdded( table );
1106+
emit selectedItemChanged( table );
1107+
return;
1108+
}
1109+
}

‎src/core/composer/qgscomposition.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,10 @@ class CORE_EXPORT QgsComposition: public QGraphicsScene
204204
/**Adds a composer table to the graphics scene and advices composer to create a widget for it (through signal)*/
205205
void addComposerTable( QgsComposerAttributeTable* table );
206206

207+
public slots:
208+
/**Casts object to the proper subclass type and calls corresponding itemAdded signal*/
209+
void sendItemAddedSignal( QgsComposerItem* item );
210+
207211
private:
208212
/**Pointer to map renderer of QGIS main map*/
209213
QgsMapRenderer* mMapRenderer;
@@ -267,6 +271,8 @@ class CORE_EXPORT QgsComposition: public QGraphicsScene
267271
void composerShapeAdded( QgsComposerShape* shape );
268272
/**Is emitted when a new composer table has been added*/
269273
void composerTableAdded( QgsComposerAttributeTable* table );
274+
/**Is emitted when a composer item has been removed from the scene*/
275+
void itemRemoved( QgsComposerItem* );
270276
};
271277

272278
#endif

‎src/gui/qgscomposerview.cpp

Lines changed: 6 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -655,68 +655,6 @@ void QgsComposerView::ungroupItems()
655655
}
656656
}
657657

658-
void QgsComposerView::sendItemAddedSignal( QgsComposerItem* item )
659-
{
660-
//cast and send proper signal
661-
item->setSelected( true );
662-
QgsComposerArrow* arrow = dynamic_cast<QgsComposerArrow*>( item );
663-
if ( arrow )
664-
{
665-
emit composerArrowAdded( arrow );
666-
emit selectedItemChanged( arrow );
667-
return;
668-
}
669-
QgsComposerLabel* label = dynamic_cast<QgsComposerLabel*>( item );
670-
if ( label )
671-
{
672-
emit composerLabelAdded( label );
673-
emit selectedItemChanged( label );
674-
return;
675-
}
676-
QgsComposerMap* map = dynamic_cast<QgsComposerMap*>( item );
677-
if ( map )
678-
{
679-
emit composerMapAdded( map );
680-
emit selectedItemChanged( map );
681-
return;
682-
}
683-
QgsComposerScaleBar* scalebar = dynamic_cast<QgsComposerScaleBar*>( item );
684-
if ( scalebar )
685-
{
686-
emit composerScaleBarAdded( scalebar );
687-
emit selectedItemChanged( scalebar );
688-
return;
689-
}
690-
QgsComposerLegend* legend = dynamic_cast<QgsComposerLegend*>( item );
691-
if ( legend )
692-
{
693-
emit composerLegendAdded( legend );
694-
emit selectedItemChanged( legend );
695-
return;
696-
}
697-
QgsComposerPicture* picture = dynamic_cast<QgsComposerPicture*>( item );
698-
if ( picture )
699-
{
700-
emit composerPictureAdded( picture );
701-
emit selectedItemChanged( picture );
702-
return;
703-
}
704-
QgsComposerShape* shape = dynamic_cast<QgsComposerShape*>( item );
705-
if ( shape )
706-
{
707-
emit composerShapeAdded( shape );
708-
emit selectedItemChanged( shape );
709-
return;
710-
}
711-
QgsComposerAttributeTable* table = dynamic_cast<QgsComposerAttributeTable*>( item );
712-
if ( table )
713-
{
714-
emit composerTableAdded( table );
715-
emit selectedItemChanged( table );
716-
return;
717-
}
718-
}
719-
720658
QMainWindow* QgsComposerView::composerWindow()
721659
{
722660
QMainWindow* composerObject = 0;
@@ -745,8 +683,12 @@ void QgsComposerView::connectAddRemoveCommandSignals( QgsAddRemoveItemCommand* c
745683
{
746684
return;
747685
}
748-
QObject::connect( c, SIGNAL( itemRemoved( QgsComposerItem* ) ), this, SIGNAL( itemRemoved( QgsComposerItem* ) ) );
749-
QObject::connect( c, SIGNAL( itemAdded( QgsComposerItem* ) ), this, SLOT( sendItemAddedSignal( QgsComposerItem* ) ) );
686+
687+
if ( composition() )
688+
{
689+
QObject::connect( c, SIGNAL( itemRemoved( QgsComposerItem* ) ), composition(), SIGNAL( itemRemoved( QgsComposerItem* ) ) );
690+
QObject::connect( c, SIGNAL( itemAdded( QgsComposerItem* ) ), composition(), SLOT( sendItemAddedSignal( QgsComposerItem* ) ) );
691+
}
750692
}
751693

752694
void QgsComposerView::pushAddRemoveCommand( QgsComposerItem* item, const QString& text, QgsAddRemoveItemCommand::State state )

‎src/gui/qgscomposerview.h

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -128,31 +128,9 @@ class GUI_EXPORT QgsComposerView: public QGraphicsView
128128

129129
void connectAddRemoveCommandSignals( QgsAddRemoveItemCommand* c );
130130

131-
132-
public slots:
133-
/**Casts object to the proper subclass type and calls corresponding itemAdded signal*/
134-
void sendItemAddedSignal( QgsComposerItem* item );
135-
136131
signals:
137132
/**Is emitted when selected item changed. If 0, no item is selected*/
138133
void selectedItemChanged( QgsComposerItem* selected );
139-
/**Is emitted when new composer arrow has been added to the view*/
140-
void composerArrowAdded( QgsComposerArrow* arrow );
141-
/**Is emitted when new composer label has been added to the view*/
142-
void composerLabelAdded( QgsComposerLabel* label );
143-
/**Is emitted when new composer map has been added to the view*/
144-
void composerMapAdded( QgsComposerMap* map );
145-
/**Is emitted when new composer scale bar has been added*/
146-
void composerScaleBarAdded( QgsComposerScaleBar* scalebar );
147-
/**Is emitted when a new composer legend has been added*/
148-
void composerLegendAdded( QgsComposerLegend* legend );
149-
/**Is emitted when a new composer picture has been added*/
150-
void composerPictureAdded( QgsComposerPicture* picture );
151-
/**Is emitted when a new composer shape has been added*/
152-
void composerShapeAdded( QgsComposerShape* shape );
153-
/**Is emitted when a new composer table has been added*/
154-
void composerTableAdded( QgsComposerAttributeTable* table );
155-
/**Is emitted when a composer item has been removed from the scene*/
156134
void itemRemoved( QgsComposerItem* );
157135
/**Current action (e.g. adding composer map) has been finished. The purpose of this signal is that
158136
QgsComposer may set the selection tool again*/

0 commit comments

Comments
 (0)
Please sign in to comment.