29
29
#include " qgsprintlayout.h"
30
30
#include " qgsreport.h"
31
31
#include " qgsreadwritecontext.h"
32
+ #include " qgshelp.h"
32
33
33
34
#include < QDesktopServices>
34
35
#include < QDialog>
@@ -71,23 +72,14 @@ QgsLayoutManagerDialog::QgsLayoutManagerDialog( QWidget *parent, Qt::WindowFlags
71
72
mLayoutListView ->setModel ( mProxyModel );
72
73
73
74
connect ( mButtonBox , &QDialogButtonBox::rejected, this , &QWidget::close );
74
- connect ( mLayoutListView ->selectionModel (), &QItemSelectionModel::selectionChanged,
75
+ connect ( mButtonBox , &QDialogButtonBox::helpRequested, this , &QgsLayoutManagerDialog::showHelp );
76
+ connect ( mLayoutListView ->selectionModel (), &QItemSelectionModel::selectionChanged,
75
77
this , &QgsLayoutManagerDialog::toggleButtons );
76
78
connect ( mLayoutListView , &QListView::doubleClicked, this , &QgsLayoutManagerDialog::itemDoubleClicked );
77
79
78
- mShowButton = mButtonBox ->addButton ( tr ( " &Show" ), QDialogButtonBox::ActionRole );
79
80
connect ( mShowButton , &QAbstractButton::clicked, this , &QgsLayoutManagerDialog::showClicked );
80
-
81
- mCreateReportButton = mButtonBox ->addButton ( tr ( " Create &Report" ), QDialogButtonBox::ActionRole );
82
- connect ( mCreateReportButton , &QAbstractButton::clicked, this , &QgsLayoutManagerDialog::createReport );
83
-
84
- mDuplicateButton = mButtonBox ->addButton ( tr ( " &Duplicate" ), QDialogButtonBox::ActionRole );
85
81
connect ( mDuplicateButton , &QAbstractButton::clicked, this , &QgsLayoutManagerDialog::duplicateClicked );
86
-
87
- mRemoveButton = mButtonBox ->addButton ( tr ( " &Remove" ), QDialogButtonBox::ActionRole );
88
82
connect ( mRemoveButton , &QAbstractButton::clicked, this , &QgsLayoutManagerDialog::removeClicked );
89
-
90
- mRenameButton = mButtonBox ->addButton ( tr ( " Re&name" ), QDialogButtonBox::ActionRole );
91
83
connect ( mRenameButton , &QAbstractButton::clicked, this , &QgsLayoutManagerDialog::renameClicked );
92
84
93
85
#ifdef Q_OS_MAC
@@ -97,6 +89,7 @@ QgsLayoutManagerDialog::QgsLayoutManagerDialog( QWidget *parent, Qt::WindowFlags
97
89
#endif
98
90
99
91
mTemplate ->addItem ( tr ( " Empty layout" ) );
92
+ mTemplate ->addItem ( tr ( " Empty report" ) );
100
93
mTemplate ->addItem ( tr ( " Specific" ) );
101
94
102
95
mUserTemplatesDir = QgsApplication::qgisSettingsDirPath () + " /composer_templates" ;
@@ -208,12 +201,12 @@ QMap<QString, QString> QgsLayoutManagerDialog::templatesFromPath( const QString
208
201
void QgsLayoutManagerDialog::mAddButton_clicked ()
209
202
{
210
203
QFile templateFile;
211
- bool loadingTemplate = ( mTemplate ->currentIndex () > 0 );
204
+ bool loadingTemplate = ( mTemplate ->currentIndex () > 1 );
212
205
QDomDocument templateDoc;
213
206
QString storedTitle;
214
207
if ( loadingTemplate )
215
208
{
216
- if ( mTemplate ->currentIndex () == 1 )
209
+ if ( mTemplate ->currentIndex () == 2 )
217
210
{
218
211
templateFile.setFileName ( mTemplateFileWidget ->filePath () );
219
212
}
@@ -242,44 +235,51 @@ void QgsLayoutManagerDialog::mAddButton_clicked()
242
235
}
243
236
}
244
237
245
- QString title;
246
- if ( !QgisApp::instance ()->uniqueLayoutTitle ( this , title, true , QgsMasterLayoutInterface::PrintLayout, storedTitle ) )
238
+ if ( mTemplate ->currentIndex () = 1 ) // if it's an empty report
247
239
{
248
- return ;
240
+ createReport () ;
249
241
}
250
-
251
- if ( title.isEmpty () )
242
+ else
252
243
{
253
- title = QgsProject::instance ()->layoutManager ()->generateUniqueTitle ( QgsMasterLayoutInterface::PrintLayout );
254
- }
244
+ QString title;
245
+ if ( !QgisApp::instance ()->uniqueLayoutTitle ( this , title, true , QgsMasterLayoutInterface::PrintLayout, storedTitle ) )
246
+ {
247
+ return ;
248
+ }
255
249
256
- std::unique_ptr< QgsPrintLayout > layout = qgis::make_unique< QgsPrintLayout >( QgsProject::instance () );
257
- if ( loadingTemplate )
258
- {
259
- bool loadedOK = false ;
260
- ( void )layout->loadFromTemplate ( templateDoc, QgsReadWriteContext (), true , &loadedOK );
261
- if ( !loadedOK )
250
+ if ( title.isEmpty () )
262
251
{
263
- QMessageBox::warning ( this , tr ( " Create Layout" ), tr ( " Invalid template file “%1”." ).arg ( templateFile.fileName () ) );
264
- layout.reset ();
252
+ title = QgsProject::instance ()->layoutManager ()->generateUniqueTitle ( QgsMasterLayoutInterface::PrintLayout );
265
253
}
266
- }
267
- else
268
- {
269
- layout->initializeDefaults ();
270
- }
271
254
272
- if ( layout )
273
- {
274
- layout->setName ( title );
275
- QgisApp::instance ()->openLayoutDesignerDialog ( layout.get () );
276
- QgsProject::instance ()->layoutManager ()->addLayout ( layout.release () );
255
+ std::unique_ptr< QgsPrintLayout > layout = qgis::make_unique< QgsPrintLayout >( QgsProject::instance () );
256
+ if ( loadingTemplate )
257
+ {
258
+ bool loadedOK = false ;
259
+ ( void )layout->loadFromTemplate ( templateDoc, QgsReadWriteContext (), true , &loadedOK );
260
+ if ( !loadedOK )
261
+ {
262
+ QMessageBox::warning ( this , tr ( " Create Layout" ), tr ( " Invalid template file “%1”." ).arg ( templateFile.fileName () ) );
263
+ layout.reset ();
264
+ }
265
+ }
266
+ else
267
+ {
268
+ layout->initializeDefaults ();
269
+ }
270
+
271
+ if ( layout )
272
+ {
273
+ layout->setName ( title );
274
+ QgisApp::instance ()->openLayoutDesignerDialog ( layout.get () );
275
+ QgsProject::instance ()->layoutManager ()->addLayout ( layout.release () );
276
+ }
277
277
}
278
278
}
279
279
280
280
void QgsLayoutManagerDialog::mTemplate_currentIndexChanged ( int indx )
281
281
{
282
- bool specific = ( indx == 1 ); // comes just after empty template
282
+ bool specific = ( indx == 2 ); // comes just after empty templates
283
283
mTemplateFileWidget ->setEnabled ( specific );
284
284
}
285
285
@@ -483,6 +483,11 @@ void QgsLayoutManagerDialog::itemDoubleClicked( const QModelIndex &index )
483
483
}
484
484
}
485
485
486
+ void QgsLayoutManagerDialog::showHelp ()
487
+ {
488
+ QgsHelp::openHelp ( QStringLiteral ( " print_composer/overview_composer.html#the-layout-manager" ) );
489
+ }
490
+
486
491
//
487
492
// QgsLayoutManagerModel
488
493
//
0 commit comments