QGIS API Documentation 3.40.0-Bratislava (b56115d8743)
Loading...
Searching...
No Matches
qgslayoutitemslistview.h
Go to the documentation of this file.
1/***************************************************************************
2 qgslayoutitemslistview.h
3 ------------------------
4 Date : October 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#ifndef QGSLAYOUTITEMSLISTVIEW_H
17#define QGSLAYOUTITEMSLISTVIEW_H
18
19// We don't want to expose this in the public API
20#define SIP_NO_FILE
21
22#include "qgis_gui.h"
23#include "qgis_sip.h"
24#include <QTreeView>
25#include <QSortFilterProxyModel>
26
27class QgsLayout;
29class QgsLayoutModel;
30class QgsLayoutItem;
31
40class GUI_EXPORT QgsLayoutItemsListViewModel : public QSortFilterProxyModel
41{
42 Q_OBJECT
43
44 public:
46 QgsLayoutItemsListViewModel( QgsLayoutModel *model, QObject *parent );
47
49 QgsLayoutItem *itemFromIndex( const QModelIndex &index ) const;
51 QModelIndex indexForItem( QgsLayoutItem *item, const int column = 0 ) const;
52 QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const override;
53
54 public slots:
56 void setSelected( const QModelIndex &index );
57
58 protected:
59 bool filterAcceptsRow( int sourceRow, const QModelIndex &sourceParent ) const override;
60
61 private:
62 QgsLayoutModel *mModel = nullptr;
63};
64
72class GUI_EXPORT QgsLayoutItemsListView : public QTreeView
73{
74 Q_OBJECT
75
76 public:
77
81 QgsLayoutItemsListView( QWidget *parent, QgsLayoutDesignerInterface *designer );
82
84 void setCurrentLayout( QgsLayout *layout );
85
86 protected:
87 void keyPressEvent( QKeyEvent *event ) override;
88
89 private slots:
90
91 void showContextMenu( QPoint point );
92
94 void updateSelection();
96 void onItemFocused( QgsLayoutItem *focusedItem );
97
98 private:
99
100 QgsLayout *mLayout = nullptr;
101 QgsLayoutItemsListViewModel *mModel = nullptr;
102 QgsLayoutDesignerInterface *mDesigner = nullptr;
103
104 bool mUpdatingSelection = false;
105 bool mUpdatingFromView = false;
106};
107
108#endif // QGSLAYOUTITEMSLISTVIEW_H
A common interface for layout designer dialogs and widgets.
Base class for graphical items within a QgsLayout.
Model for the layout items list view.
A list view for showing items in a layout.
A model for items attached to a layout.
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
Definition qgslayout.h:49