QGIS API Documentation 3.99.0-Master (21b3aa880ba)
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
25#include <QSortFilterProxyModel>
26#include <QTreeView>
27
28class QgsLayout;
30class QgsLayoutModel;
31class QgsLayoutItem;
32
41class GUI_EXPORT QgsLayoutItemsListViewModel : public QSortFilterProxyModel
42{
43 Q_OBJECT
44
45 public:
47 QgsLayoutItemsListViewModel( QgsLayoutModel *model, QObject *parent );
48
50 QgsLayoutItem *itemFromIndex( const QModelIndex &index ) const;
52 QModelIndex indexForItem( QgsLayoutItem *item, const int column = 0 ) const;
53 QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const override;
54
55 public slots:
57 void setSelected( const QModelIndex &index );
58
59 protected:
60 bool filterAcceptsRow( int sourceRow, const QModelIndex &sourceParent ) const override;
61
62 private:
63 QgsLayoutModel *mModel = nullptr;
64};
65
73class GUI_EXPORT QgsLayoutItemsListView : public QTreeView
74{
75 Q_OBJECT
76
77 public:
78
82 QgsLayoutItemsListView( QWidget *parent, QgsLayoutDesignerInterface *designer );
83
85 void setCurrentLayout( QgsLayout *layout );
86
87 protected:
88 void keyPressEvent( QKeyEvent *event ) override;
89
90 private slots:
91
92 void showContextMenu( QPoint point );
93
95 void updateSelection();
97 void onItemFocused( QgsLayoutItem *focusedItem );
98
99 private:
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.
QgsLayoutItem * itemFromIndex(const QModelIndex &index) const
Returns the layout item listed at the specified index.
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override
QgsLayoutItemsListViewModel(QgsLayoutModel *model, QObject *parent)
constructor
void setSelected(const QModelIndex &index)
Sets the selected index.
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
QModelIndex indexForItem(QgsLayoutItem *item, const int column=0) const
Returns the model index matching the specified layout item.
void setCurrentLayout(QgsLayout *layout)
Sets the current layout.
QgsLayoutItemsListView(QWidget *parent, QgsLayoutDesignerInterface *designer)
Constructor for QgsLayoutItemsListView.
void keyPressEvent(QKeyEvent *event) override
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:50