/
qgslayoutcombobox.h
105 lines (85 loc) · 3.18 KB
/
qgslayoutcombobox.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/***************************************************************************
qgslayoutcombobox.h
--------------------------------------
Date : March 2019
Copyright : (C) 2019 Nyall Dawson
Email : nyall dot dawson at gmail dot com
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSLAYOUTCOMBOBOX_H
#define QGSLAYOUTCOMBOBOX_H
#include <QComboBox>
#include "qgis_sip.h"
#include "qgis_gui.h"
#include "qgslayoutmanager.h"
/**
* \class QgsLayoutComboBox
* \ingroup gui
* \brief The QgsLayoutComboBox class is a combo box which displays available layouts from a QgsLayoutManager.
* \since QGIS 3.8
*/
class GUI_EXPORT QgsLayoutComboBox : public QComboBox
{
Q_OBJECT
public:
/**
* QgsLayoutComboBox creates a combo box to display a list of items in a
* layout \a manager. The layouts can optionally be filtered by type.
*/
explicit QgsLayoutComboBox( QWidget *parent SIP_TRANSFERTHIS = nullptr, QgsLayoutManager *manager = nullptr );
/**
* Sets the layout \a manager containing the layouts to list in the combo box.
*/
void setLayoutManager( QgsLayoutManager *manager );
/**
* Returns the current filters used for filtering available layouts.
*
* \see setFilters()
*/
QgsLayoutManagerProxyModel::Filters filters() const;
/**
* Sets the current \a filters used for filtering available layouts.
*
* \see filters()
*/
void setFilters( QgsLayoutManagerProxyModel::Filters filters );
/**
* Sets whether an optional empty layout ("not set") option is present in the combobox.
* \see allowEmptyLayout()
*/
void setAllowEmptyLayout( bool allowEmpty );
/**
* Returns TRUE if the combobox includes the empty layout ("not set") choice.
* \see setAllowEmptyLayout()
*/
bool allowEmptyLayout() const;
/**
* Returns the layout currently selected in the combo box.
*/
QgsMasterLayoutInterface *currentLayout() const;
/**
* Returns the layout at the specified \a index.
*/
QgsMasterLayoutInterface *layout( int index ) const;
public slots:
/**
* Sets the currently selected \a layout in the combo box.
*/
void setCurrentLayout( QgsMasterLayoutInterface *layout );
signals:
//! Emitted whenever the currently selected layout changes
void layoutChanged( QgsMasterLayoutInterface *layout );
private slots:
void indexChanged( int i );
void rowsChanged();
private:
QgsLayoutManagerModel *mModel = nullptr;
QgsLayoutManagerProxyModel *mProxyModel = nullptr;
};
#endif // QGSLAYOUTCOMBOBOX_H