Skip to content
Permalink
Browse files
Add new, duplicate and delete composer to iface
- Works via QgsComposerView, which is already exposed in iface
  • Loading branch information
dakcarto committed Feb 28, 2013
1 parent d56ad40 commit 4941a0e5dc78103f895bcf6f313e2d0c76ad64b9
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 0 deletions.
@@ -121,6 +121,26 @@ class QgisInterface : QObject
/**Return mainwindows / composer views of running composer instances (currently only one)*/
virtual QList<QgsComposerView*> activeComposers() = 0;

/** Create a new composer
* @param title window title for new composer (one will be generated if empty)
* @return pointer to composer's view
* @note new composer window will be shown and activated (added in 1.9)
*/
virtual QgsComposerView* createNewComposer( QString title = QString( "" ) ) = 0;

/** Duplicate an existing parent composer from composer view
* @param composerView pointer to existing composer view
* @param title window title for duplicated composer (one will be generated if empty)
* @return pointer to duplicate composer's view
* @note dupicate composer window will be hidden until loaded, then shown and activated (added in 1.9)
*/
virtual QgsComposerView* duplicateComposer( QgsComposerView* composerView, QString title = QString( "" ) ) = 0;

/** Deletes parent composer of composer view, after closing composer window
* @note (added in 1.9)
*/
virtual void deleteComposer( QgsComposerView* composerView ) = 0;

/** Return changeable options built from settings and/or defaults
* @note (added in 1.9)
*/
@@ -26,6 +26,7 @@
#include "qgisappstylesheet.h"
#include "qgisapp.h"
#include "qgscomposer.h"
#include "qgscomposerview.h"
#include "qgsmaplayer.h"
#include "qgsmaplayerregistry.h"
#include "qgsmapcanvas.h"
@@ -290,6 +291,44 @@ QList<QgsComposerView*> QgisAppInterface::activeComposers()
return composerViewList;
}

QgsComposerView* QgisAppInterface::createNewComposer( QString title )
{
QgsComposer* composerObj = 0;
composerObj = qgis->createNewComposer( title );
if ( composerObj )
{
return composerObj->view();
}
return 0;
}

QgsComposerView* QgisAppInterface::duplicateComposer( QgsComposerView* composerView, QString title )
{
QgsComposer* composerObj = 0;
composerObj = qobject_cast<QgsComposer *>( composerView->composerWindow() );
if ( composerObj )
{
QgsComposer* dupComposer = qgis->duplicateComposer( composerObj, title );
if ( dupComposer )
{
return dupComposer->view();
}
}
return 0;
}

void QgisAppInterface::deleteComposer( QgsComposerView* composerView )
{
composerView->composerWindow()->close();

QgsComposer* composerObj = 0;
composerObj = qobject_cast<QgsComposer *>( composerView->composerWindow() );
if ( composerObj )
{
qgis->deleteComposer( composerObj );
}
}

QMap<QString, QVariant> QgisAppInterface::defaultStyleSheetOptions()
{
return qgis->styleSheetBuilder()->defaultOptions();
@@ -125,6 +125,26 @@ class QgisAppInterface : public QgisInterface

QList<QgsComposerView*> activeComposers();

/** Create a new composer
* @param title window title for new composer (one will be generated if empty)
* @return pointer to composer's view
* @note new composer window will be shown and activated (added in 1.9)
*/
QgsComposerView* createNewComposer( QString title = QString( "" ) );

/** Duplicate an existing parent composer from composer view
* @param composerView pointer to existing composer view
* @param title window title for duplicated composer (one will be generated if empty)
* @return pointer to duplicate composer's view
* @note dupicate composer window will be hidden until loaded, then shown and activated (added in 1.9)
*/
QgsComposerView* duplicateComposer( QgsComposerView* composerView, QString title = QString( "" ) );

/** Deletes parent composer of composer view, after closing composer window
* @note (added in 1.9)
*/
void deleteComposer( QgsComposerView* composerView );

/** Return changeable options built from settings and/or defaults
* @note (added in 1.9)
*/
@@ -166,6 +166,26 @@ class GUI_EXPORT QgisInterface : public QObject
/**Return mainwindows / composer views of running composer instances (currently only one)*/
virtual QList<QgsComposerView*> activeComposers() = 0;

/** Create a new composer
* @param title window title for new composer (one will be generated if empty)
* @return pointer to composer's view
* @note new composer window will be shown and activated (added in 1.9)
*/
virtual QgsComposerView* createNewComposer( QString title = QString( "" ) ) = 0;

/** Duplicate an existing parent composer from composer view
* @param composerView pointer to existing composer view
* @param title window title for duplicated composer (one will be generated if empty)
* @return pointer to duplicate composer's view
* @note dupicate composer window will be hidden until loaded, then shown and activated (added in 1.9)
*/
virtual QgsComposerView* duplicateComposer( QgsComposerView* composerView, QString title = QString( "" ) ) = 0;

/** Deletes parent composer of composer view, after closing composer window
* @note (added in 1.9)
*/
virtual void deleteComposer( QgsComposerView* composerView ) = 0;

/** Return changeable options built from settings and/or defaults
* @note (added in 1.9)
*/

0 comments on commit 4941a0e

Please sign in to comment.