QGIS API Documentation 4.3.0-Master (eb72899e5dc)
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
21#include "qgis_gui.h"
22#include "qgis_sip.h"
23
24#include <QSortFilterProxyModel>
25#include <QTreeView>
26
27#define SIP_NO_FILE
28
29class QgsLayout;
31class QgsLayoutModel;
32class QgsLayoutItem;
33class QgsLayoutView;
34
43class GUI_EXPORT QgsLayoutItemsListViewModel : public QSortFilterProxyModel
44{
45 Q_OBJECT
46
47 public:
49 QgsLayoutItemsListViewModel( QgsLayoutModel *model, QObject *parent );
50
52 QgsLayoutItem *itemFromIndex( const QModelIndex &index ) const;
54 QModelIndex indexForItem( QgsLayoutItem *item, const int column = 0 ) const;
55 QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const override;
56
57 public slots:
59 void setSelected( const QModelIndex &index );
60
61 protected:
62 bool filterAcceptsRow( int sourceRow, const QModelIndex &sourceParent ) const override;
63
64 private:
65 QgsLayoutModel *mModel = nullptr;
66};
67
75class GUI_EXPORT QgsLayoutItemsListView : public QTreeView
76{
77 Q_OBJECT
78
79 public:
83 QgsLayoutItemsListView( QWidget *parent, QgsLayoutDesignerInterface *designer );
84
86 void setCurrentLayout( QgsLayout *layout );
87
88 protected:
89 void keyPressEvent( QKeyEvent *event ) override;
90
91 private slots:
92
93 void setLayoutView( QgsLayoutView *view );
94
95 void showContextMenu( QPoint point );
96
98 void updateSelection( const QItemSelection &selected, const QItemSelection &deselected );
100 void onItemFocused( QgsLayoutItem *focusedItem );
101
102 private:
103 QgsLayout *mLayout = nullptr;
104 QgsLayoutItemsListViewModel *mModel = nullptr;
105 QgsLayoutDesignerInterface *mDesigner = nullptr;
106
107 bool mUpdatingSelection = false;
108 bool mUpdatingFromView = false;
109
111};
112
113#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.
A graphical widget to display and interact with QgsLayouts.
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
Definition qgslayout.h:51