Skip to content
Permalink
Browse files

Add button in layout manager dialog to create a new report

  • Loading branch information
nyalldawson committed Dec 29, 2017
1 parent 56332b3 commit 78f2174cfeba9e42995f5226d85dfa6aace3c275
Showing with 30 additions and 0 deletions.
  1. +28 −0 src/app/layout/qgslayoutmanagerdialog.cpp
  2. +2 −0 src/app/layout/qgslayoutmanagerdialog.h
@@ -75,6 +75,9 @@ QgsLayoutManagerDialog::QgsLayoutManagerDialog( QWidget *parent, Qt::WindowFlags
mShowButton = mButtonBox->addButton( tr( "&Show" ), QDialogButtonBox::ActionRole );
connect( mShowButton, &QAbstractButton::clicked, this, &QgsLayoutManagerDialog::showClicked );

mCreateReportButton = mButtonBox->addButton( tr( "Create &Report" ), QDialogButtonBox::ActionRole );
connect( mCreateReportButton, &QAbstractButton::clicked, this, &QgsLayoutManagerDialog::createReport );

mDuplicateButton = mButtonBox->addButton( tr( "&Duplicate" ), QDialogButtonBox::ActionRole );
connect( mDuplicateButton, &QAbstractButton::clicked, this, &QgsLayoutManagerDialog::duplicateClicked );

@@ -287,6 +290,31 @@ void QgsLayoutManagerDialog::mTemplatesUserDirBtn_pressed()
openLocalDirectory( mUserTemplatesDir );
}

void QgsLayoutManagerDialog::createReport()
{
QString title;
if ( !QgisApp::instance()->uniqueLayoutTitle( this, title, true ) )
{
return;
}

if ( title.isEmpty() )
{
title = QgsProject::instance()->layoutManager()->generateUniqueTitle();
}

std::unique_ptr< QgsReport > report = qgis::make_unique< QgsReport >( QgsProject::instance() );
report->setName( title );

std::unique_ptr< QgsLayout > header = qgis::make_unique< QgsLayout >( QgsProject::instance() );
header->initializeDefaults();
report->setHeader( header.release() );
report->setHeaderEnabled( true );

QgisApp::instance()->openLayoutDesignerDialog( report.get() );
QgsProject::instance()->layoutManager()->addLayout( report.release() );
}

void QgsLayoutManagerDialog::openLocalDirectory( const QString &localDirPath )
{
QDir localDir;
@@ -92,6 +92,7 @@ class QgsLayoutManagerDialog: public QDialog, private Ui::QgsLayoutManagerBase
QPushButton *mRemoveButton = nullptr;
QPushButton *mRenameButton = nullptr;
QPushButton *mDuplicateButton = nullptr;
QPushButton *mCreateReportButton = nullptr;
QgsLayoutManagerModel *mModel = nullptr;

#ifdef Q_OS_MAC
@@ -112,6 +113,7 @@ class QgsLayoutManagerDialog: public QDialog, private Ui::QgsLayoutManagerBase
//! Slot to open user templates dir with user's system
void mTemplatesUserDirBtn_pressed();

void createReport();
void removeClicked();
void showClicked();
//! Duplicate layout

0 comments on commit 78f2174

Please sign in to comment.
You can’t perform that action at this time.