QGIS API Documentation 3.28.0-Firenze (ed3ad0430f)
qgsannotationitemwidget_impl.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsannotationitemwidget_impl.h
3 ------------------------
4 Date : September 2021
5 Copyright : (C) 2021 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#ifndef QGSANNOTATIONITEMWIDGETIMPL_H
16#define QGSANNOTATIONITEMWIDGETIMPL_H
17
19#include "qgis_sip.h"
20#include "qgis_gui.h"
21#include "qgstextformat.h"
22#include <memory>
23
24#include "ui_qgsannotationpointtextwidgetbase.h"
25#include "ui_qgsannotationsymbolwidgetbase.h"
26
28class QgsFillSymbol;
29class QgsLineSymbol;
30class QgsMarkerSymbol;
36
37#define SIP_NO_FILE
38
40
41class QgsAnnotationPolygonItemWidget : public QgsAnnotationItemBaseWidget, private Ui_QgsAnnotationSymbolWidgetBase
42{
43 Q_OBJECT
44
45 public:
46 QgsAnnotationPolygonItemWidget( QWidget *parent );
47 ~QgsAnnotationPolygonItemWidget() override;
48 QgsAnnotationItem *createItem() override;
49 void updateItem( QgsAnnotationItem *item ) override;
50 void setDockMode( bool dockMode ) override;
51 void setContext( const QgsSymbolWidgetContext &context ) override;
52
53 protected:
54 bool setNewItem( QgsAnnotationItem *item ) override;
55
56 private:
57
58 QgsSymbolSelectorWidget *mSelector = nullptr;
59 std::unique_ptr< QgsFillSymbol > mSymbol;
60 bool mBlockChangedSignal = false;
61 std::unique_ptr< QgsAnnotationPolygonItem> mItem;
62};
63
64class QgsAnnotationLineItemWidget : public QgsAnnotationItemBaseWidget, private Ui_QgsAnnotationSymbolWidgetBase
65{
66 Q_OBJECT
67
68 public:
69 QgsAnnotationLineItemWidget( QWidget *parent );
70 ~QgsAnnotationLineItemWidget() override;
71 QgsAnnotationItem *createItem() override;
72 void updateItem( QgsAnnotationItem *item ) override;
73 void setDockMode( bool dockMode ) override;
74 void setContext( const QgsSymbolWidgetContext &context ) override;
75
76 protected:
77 bool setNewItem( QgsAnnotationItem *item ) override;
78
79 private:
80
81 QgsSymbolSelectorWidget *mSelector = nullptr;
82 std::unique_ptr< QgsLineSymbol > mSymbol;
83 bool mBlockChangedSignal = false;
84 std::unique_ptr< QgsAnnotationLineItem> mItem;
85};
86
87class QgsAnnotationMarkerItemWidget : public QgsAnnotationItemBaseWidget, private Ui_QgsAnnotationSymbolWidgetBase
88{
89 Q_OBJECT
90
91 public:
92 QgsAnnotationMarkerItemWidget( QWidget *parent );
93 ~QgsAnnotationMarkerItemWidget() override;
94 QgsAnnotationItem *createItem() override;
95 void updateItem( QgsAnnotationItem *item ) override;
96 void setDockMode( bool dockMode ) override;
97 void setContext( const QgsSymbolWidgetContext &context ) override;
98
99 protected:
100 bool setNewItem( QgsAnnotationItem *item ) override;
101
102 private:
103
104 QgsSymbolSelectorWidget *mSelector = nullptr;
105 std::unique_ptr< QgsMarkerSymbol > mSymbol;
106 bool mBlockChangedSignal = false;
107 std::unique_ptr< QgsAnnotationMarkerItem> mItem;
108};
109
110
111class QgsAnnotationPointTextItemWidget : public QgsAnnotationItemBaseWidget, private Ui_QgsAnnotationPointTextWidgetBase
112{
113 Q_OBJECT
114
115 public:
116 QgsAnnotationPointTextItemWidget( QWidget *parent );
117 ~QgsAnnotationPointTextItemWidget() override;
118 QgsAnnotationItem *createItem() override;
119 void updateItem( QgsAnnotationItem *item ) override;
120 void setDockMode( bool dockMode ) override;
121 void setContext( const QgsSymbolWidgetContext &context ) override;
122
123 public slots:
124
125 void focusDefaultWidget() override;
126
127 protected:
128 bool setNewItem( QgsAnnotationItem *item ) override;
129
130 private:
131 void mInsertExpressionButton_clicked();
132
133 QgsTextFormatWidget *mTextFormatWidget = nullptr;
134 bool mBlockChangedSignal = false;
135 std::unique_ptr< QgsAnnotationPointTextItem> mItem;
136};
137
139
140#endif // QGSANNOTATIONITEMWIDGETIMPL_H
A base class for property widgets for annotation items.
virtual void focusDefaultWidget()
Focuses the default widget for the page.
virtual void setContext(const QgsSymbolWidgetContext &context)
Sets the context in which the widget is shown, e.g., the associated map canvas and expression context...
virtual QgsAnnotationItem * createItem()=0
Creates a new item matching the settings defined in the widget.
virtual bool setNewItem(QgsAnnotationItem *item)
Attempts to update the widget to show the properties for the specified item.
virtual void updateItem(QgsAnnotationItem *item)=0
Updates an existing item to match the settings defined in the widget.
Abstract base class for annotation items which are drawn with QgsAnnotationLayers.
An annotation item which renders a line symbol along a line geometry.
An annotation item which renders a marker symbol at a point location.
An annotation item which renders a text string at a point location.
An annotation item which renders a fill symbol for a polygon geometry.
A fill symbol type, for rendering Polygon and MultiPolygon geometries.
Definition: qgsfillsymbol.h:30
A line symbol type, for rendering LineString and MultiLineString geometries.
Definition: qgslinesymbol.h:30
A marker symbol type, for rendering Point and MultiPoint geometries.
virtual void setDockMode(bool dockMode)
Set the widget in dock mode which tells the widget to emit panel widgets and not open dialogs.
Symbol selector widget that can be used to select and build a symbol.
Contains settings which reflect the context in which a symbol (or renderer) widget is shown,...
A widget for customizing text formatting settings.