QGIS API Documentation
4.3.0-Master (16eddb2670e)
Toggle main menu visibility
Loading...
Searching...
No Matches
src
core
layout
qgslayoutmanagermodel.cpp
Go to the documentation of this file.
1
/***************************************************************************
2
qgslayoutmanagermodel.cpp
3
--------------------
4
Date : January 2017
5
Copyright : (C) 2017 Nyall Dawson
6
Email : nyall dot dawson at gmail dot com
7
***************************************************************************
8
* *
9
* This program is free software; you can redistribute it and/or modify *
10
* it under the terms of the GNU General Public License as published by *
11
* the Free Software Foundation; either version 2 of the License, or *
12
* (at your option) any later version. *
13
* *
14
***************************************************************************/
15
16
#include "
qgslayoutmanagermodel.h
"
17
18
#include "
qgslayoutmanager.h
"
19
#include "
qgsproject.h
"
20
21
#include <QMessageBox>
22
23
#include "moc_qgslayoutmanagermodel.cpp"
24
25
//
26
// QgsLayoutManagerModel
27
//
28
29
QgsLayoutManagerModel::QgsLayoutManagerModel
(
QgsLayoutManager
*manager, QObject *parent )
30
:
QgsProjectStoredObjectManagerModel
( manager, parent )
31
{
32
connect( manager, &
QgsLayoutManager::layoutRenamed
,
this
, &QgsLayoutManagerModel::objectRenamedInternal );
33
}
34
35
QgsMasterLayoutInterface
*
QgsLayoutManagerModel::layoutFromIndex
(
const
QModelIndex &index )
const
36
{
37
return
objectFromIndex
( index );
38
}
39
40
QModelIndex
QgsLayoutManagerModel::indexFromLayout
(
QgsMasterLayoutInterface
*layout )
const
41
{
42
return
indexFromObject
( layout );
43
}
44
45
void
QgsLayoutManagerModel::setAllowEmptyLayout
(
bool
allowEmpty )
46
{
47
setAllowEmptyObject
( allowEmpty );
48
}
49
50
51
//
52
// QgsLayoutManagerProxyModel
53
//
54
55
QgsLayoutManagerProxyModel::QgsLayoutManagerProxyModel
( QObject *parent )
56
:
QgsProjectStoredObjectManagerProxyModel
( parent )
57
{}
58
59
bool
QgsLayoutManagerProxyModel::filterAcceptsRowInternal
(
int
sourceRow,
const
QModelIndex &sourceParent )
const
60
{
61
if
( !
QgsProjectStoredObjectManagerProxyModel::filterAcceptsRowInternal
( sourceRow, sourceParent ) )
62
return
false
;
63
64
QgsLayoutManagerModel
*model = qobject_cast< QgsLayoutManagerModel * >( sourceModel() );
65
if
( !model )
66
return
false
;
67
68
QgsMasterLayoutInterface
*layout = model->
layoutFromIndex
( model->index( sourceRow, 0, sourceParent ) );
69
if
( !layout )
70
return
model->
allowEmptyLayout
();
71
72
switch
( layout->
layoutType
() )
73
{
74
case
QgsMasterLayoutInterface::PrintLayout
:
75
return
mFilters &
FilterPrintLayouts
;
76
case
QgsMasterLayoutInterface::Report
:
77
return
mFilters &
FilterReports
;
78
}
79
return
false
;
80
}
81
82
QgsLayoutManagerProxyModel::Filters
QgsLayoutManagerProxyModel::filters
()
const
83
{
84
return
mFilters;
85
}
86
87
void
QgsLayoutManagerProxyModel::setFilters
(
Filters
filters
)
88
{
89
mFilters =
filters
;
90
invalidateFilter();
91
}
QgsLayoutManagerModel
List model representing the print layouts and reports available in a layout manager.
Definition
qgslayoutmanagermodel.h:48
QgsLayoutManagerModel::indexFromLayout
QModelIndex indexFromLayout(QgsMasterLayoutInterface *layout) const
Returns the model index corresponding to a layout.
Definition
qgslayoutmanagermodel.cpp:40
QgsLayoutManagerModel::layoutFromIndex
QgsMasterLayoutInterface * layoutFromIndex(const QModelIndex &index) const
Returns the layout at the corresponding index.
Definition
qgslayoutmanagermodel.cpp:35
QgsLayoutManagerModel::setAllowEmptyLayout
void setAllowEmptyLayout(bool allowEmpty)
Sets whether an optional empty layout ("not set") option is present in the model.
Definition
qgslayoutmanagermodel.cpp:45
QgsLayoutManagerModel::allowEmptyLayout
bool allowEmptyLayout() const
Returns true if the model allows the empty layout ("not set") choice.
Definition
qgslayoutmanagermodel.h:95
QgsLayoutManagerModel::QgsLayoutManagerModel
QgsLayoutManagerModel(QgsLayoutManager *manager, QObject *parent=nullptr)
Constructor for QgsLayoutManagerModel, showing the layouts from the specified manager.
Definition
qgslayoutmanagermodel.cpp:29
QgsLayoutManagerProxyModel::setFilters
void setFilters(QgsLayoutManagerProxyModel::Filters filters)
Sets the current filters used for filtering available layouts.
Definition
qgslayoutmanagermodel.cpp:87
QgsLayoutManagerProxyModel::filters
QgsLayoutManagerProxyModel::Filters filters() const
Returns the current filters used for filtering available layouts.
Definition
qgslayoutmanagermodel.cpp:82
QgsLayoutManagerProxyModel::Filters
QFlags< Filter > Filters
Definition
qgslayoutmanagermodel.h:122
QgsLayoutManagerProxyModel::FilterReports
@ FilterReports
Includes reports.
Definition
qgslayoutmanagermodel.h:120
QgsLayoutManagerProxyModel::FilterPrintLayouts
@ FilterPrintLayouts
Includes print layouts.
Definition
qgslayoutmanagermodel.h:119
QgsLayoutManagerProxyModel::QgsLayoutManagerProxyModel
QgsLayoutManagerProxyModel(QObject *parent=nullptr)
Constructor for QgsLayoutManagerProxyModel.
Definition
qgslayoutmanagermodel.cpp:55
QgsLayoutManagerProxyModel::filterAcceptsRowInternal
bool filterAcceptsRowInternal(int sourceRow, const QModelIndex &sourceParent) const override
Returns true if the proxy accepts the matching source row.
Definition
qgslayoutmanagermodel.cpp:59
QgsLayoutManager
Manages storage of a set of layouts.
Definition
qgslayoutmanager.h:50
QgsLayoutManager::layoutRenamed
void layoutRenamed(QgsMasterLayoutInterface *layout, const QString &newName)
Emitted when a layout is renamed.
QgsMasterLayoutInterface
Interface for master layout type objects, such as print layouts and reports.
Definition
qgsmasterlayoutinterface.h:45
QgsMasterLayoutInterface::layoutType
virtual QgsMasterLayoutInterface::Type layoutType() const =0
Returns the master layout type.
QgsMasterLayoutInterface::Report
@ Report
Report (QgsReport).
Definition
qgsmasterlayoutinterface.h:70
QgsMasterLayoutInterface::PrintLayout
@ PrintLayout
Individual print layout (QgsPrintLayout).
Definition
qgsmasterlayoutinterface.h:69
QgsProjectStoredObjectManagerModel< QgsMasterLayoutInterface >::setAllowEmptyObject
void setAllowEmptyObject(bool allowEmpty)
Definition
qgsprojectstoredobjectmanagermodel.cpp:273
QgsProjectStoredObjectManagerModel< QgsMasterLayoutInterface >::indexFromObject
QModelIndex indexFromObject(QgsMasterLayoutInterface *object) const
Definition
qgsprojectstoredobjectmanagermodel.cpp:253
QgsProjectStoredObjectManagerModel< QgsMasterLayoutInterface >::objectFromIndex
QgsMasterLayoutInterface * objectFromIndex(const QModelIndex &index) const
Definition
qgsprojectstoredobjectmanagermodel.cpp:242
QgsProjectStoredObjectManagerModel< QgsMasterLayoutInterface >::QgsProjectStoredObjectManagerModel
QgsProjectStoredObjectManagerModel(QgsAbstractProjectStoredObjectManager< QgsMasterLayoutInterface > *manager, QObject *parent=nullptr)
Definition
qgsprojectstoredobjectmanagermodel.cpp:76
QgsProjectStoredObjectManagerProxyModel::filterAcceptsRowInternal
bool filterAcceptsRowInternal(int sourceRow, const QModelIndex &sourceParent) const override
Returns true if the proxy accepts the matching source row.
Definition
qgsprojectstoredobjectmanagermodel.cpp:438
QgsProjectStoredObjectManagerProxyModel< QgsMasterLayoutInterface >::QgsProjectStoredObjectManagerProxyModel
QgsProjectStoredObjectManagerProxyModel(QObject *parent=nullptr)
Definition
qgsprojectstoredobjectmanagermodel.cpp:434
qgslayoutmanager.h
qgslayoutmanagermodel.h
qgsproject.h
Generated on
for QGIS API Documentation by
1.17.0