QGIS API Documentation 3.41.0-Master (af5edcb665c)
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:
80 QgsLayoutItemsListView( QWidget *parent, QgsLayoutDesignerInterface *designer );
81
83 void setCurrentLayout( QgsLayout *layout );
84
85 protected:
86 void keyPressEvent( QKeyEvent *event ) override;
87
88 private slots:
89
90 void showContextMenu( QPoint point );
91
93 void updateSelection();
95 void onItemFocused( QgsLayoutItem *focusedItem );
96
97 private:
98 QgsLayout *mLayout = nullptr;
99 QgsLayoutItemsListViewModel *mModel = nullptr;
100 QgsLayoutDesignerInterface *mDesigner = nullptr;
101
102 bool mUpdatingSelection = false;
103 bool mUpdatingFromView = false;
104};
105
106#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