Skip to content

Commit

Permalink
Notify plugins if a composer has been added or removed
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk@12372 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed Dec 8, 2009
1 parent 71cf0ac commit bcb2211
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 3 deletions.
8 changes: 8 additions & 0 deletions python/gui/qgisinterface.sip
Expand Up @@ -246,5 +246,13 @@ class QgisInterface : QObject
*/
void currentLayerChanged ( QgsMapLayer * layer );

/**This signal is emitted when a new composer instance has been created
@note added in version 1.4*/
void composerAdded( QgsComposerView* v );

/**This signal is emitted before a new composer instance is going to be removed
@note added in version 1.4*/
void composerWillBeRemoved( QgsComposerView* v );

};

2 changes: 2 additions & 0 deletions src/app/qgisapp.cpp
Expand Up @@ -3633,11 +3633,13 @@ QgsComposer* QgisApp::createNewComposer()
//and place action into print composers menu
mPrintComposersMenu->addAction( newComposerObject->windowAction() );
newComposerObject->open();
emit composerAdded(newComposerObject->view());
return newComposerObject;
}

void QgisApp::deleteComposer( QgsComposer* c )
{
emit composerWillBeRemoved(c->view());
mPrintComposers.remove( c );
mPrintComposersMenu->removeAction( c->windowAction() );
delete c;
Expand Down
10 changes: 10 additions & 0 deletions src/app/qgisapp.h
Expand Up @@ -41,6 +41,7 @@ class QValidator;
class QgisAppInterface;
class QgsClipboard;
class QgsComposer;
class QgsComposerView;
class QgsGeometry;
class QgsHelpViewer;
class QgsFeature;
Expand Down Expand Up @@ -669,6 +670,15 @@ class QgisApp : public QMainWindow
*/
void currentThemeChanged( QString );

/**This signal is emitted when a new composer instance has been created
@note added in version 1.4*/
void composerAdded( QgsComposerView* v );

/**This signal is emitted before a new composer instance is going to be removed
@note added in version 1.4*/
void composerWillBeRemoved( QgsComposerView* v );


private:
/** This method will open a dialog so the user can select the sublayers
* to load
Expand Down
4 changes: 2 additions & 2 deletions src/app/qgisappinterface.cpp
Expand Up @@ -39,7 +39,8 @@ QgisAppInterface::QgisAppInterface( QgisApp * _qgis )
this, SIGNAL( currentLayerChanged( QgsMapLayer * ) ) );
connect( qgis, SIGNAL( currentThemeChanged( QString ) ),
this, SIGNAL( currentThemeChanged( QString ) ) );

connect( qgis, SIGNAL(composerAdded(QgsComposerView*)), this, SIGNAL(composerAdded( QgsComposerView* )));
connect( qgis, SIGNAL(composerWillBeRemoved(QgsComposerView*)), this, SIGNAL(composerWillBeRemoved(QgsComposerView*)));
}

QgisAppInterface::~QgisAppInterface()
Expand Down Expand Up @@ -211,7 +212,6 @@ bool QgisAppInterface::unregisterMainWindowAction( QAction* action )
return QgsShortcutsManager::instance()->unregisterAction( action );
}


//! Menus
QMenu *QgisAppInterface::fileMenu() { return qgis->fileMenu(); }
QMenu *QgisAppInterface::editMenu() { return qgis->editMenu(); }
Expand Down
7 changes: 6 additions & 1 deletion src/gui/qgisinterface.h
Expand Up @@ -292,7 +292,12 @@ class GUI_EXPORT QgisInterface : public QObject
* The pointer to layer can be null if no layer is selected
*/
void currentLayerChanged( QgsMapLayer * layer );

/**This signal is emitted when a new composer instance has been created
@note added in version 1.4*/
void composerAdded( QgsComposerView* v );
/**This signal is emitted before a new composer instance is going to be removed
@note added in version 1.4*/
void composerWillBeRemoved( QgsComposerView* v );
};

// FIXME: also in core/qgis.h
Expand Down

0 comments on commit bcb2211

Please sign in to comment.