QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
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 
28 class QgsFillSymbol;
29 class QgsLineSymbol;
30 class QgsMarkerSymbol;
36 
37 #define SIP_NO_FILE
38 
40 
41 class 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 
64 class 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 
87 class 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 
111 class 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
QgsAnnotationItemBaseWidget
A base class for property widgets for annotation items.
Definition: qgsannotationitemwidget.h:35
QgsPanelWidget::setDockMode
virtual void setDockMode(bool dockMode)
Set the widget in dock mode which tells the widget to emit panel widgets and not open dialogs.
Definition: qgspanelwidget.cpp:44
QgsSymbolWidgetContext
Contains settings which reflect the context in which a symbol (or renderer) widget is shown,...
Definition: qgssymbolwidgetcontext.h:35
QgsSymbolSelectorWidget
Symbol selector widget that can be used to select and build a symbol.
Definition: qgssymbolselectordialog.h:87
QgsAnnotationMarkerItem
An annotation item which renders a marker symbol at a point location.
Definition: qgsannotationmarkeritem.h:32
QgsAnnotationItemBaseWidget::focusDefaultWidget
virtual void focusDefaultWidget()
Focuses the default widget for the page.
Definition: qgsannotationitemwidget.cpp:39
QgsAnnotationPolygonItem
An annotation item which renders a fill symbol for a polygon geometry.
Definition: qgsannotationpolygonitem.h:32
QgsMarkerSymbol
A marker symbol type, for rendering Point and MultiPoint geometries.
Definition: qgsmarkersymbol.h:30
QgsAnnotationItemBaseWidget::setContext
virtual void setContext(const QgsSymbolWidgetContext &context)
Sets the context in which the widget is shown, e.g., the associated map canvas and expression context...
Definition: qgsannotationitemwidget.cpp:29
QgsAnnotationItemBaseWidget::createItem
virtual QgsAnnotationItem * createItem()=0
Creates a new item matching the settings defined in the widget.
qgis_sip.h
QgsLineSymbol
A line symbol type, for rendering LineString and MultiLineString geometries.
Definition: qgslinesymbol.h:29
QgsTextFormatWidget
A widget for customizing text formatting settings.
Definition: qgstextformatwidget.h:50
qgsannotationitemwidget.h
QgsFillSymbol
A fill symbol type, for rendering Polygon and MultiPolygon geometries.
Definition: qgsfillsymbol.h:29
QgsAnnotationLineItem
An annotation item which renders a line symbol along a line geometry.
Definition: qgsannotationlineitem.h:33
qgstextformat.h
QgsAnnotationItemBaseWidget::updateItem
virtual void updateItem(QgsAnnotationItem *item)=0
Updates an existing item to match the settings defined in the widget.
QgsAnnotationItemBaseWidget::setNewItem
virtual bool setNewItem(QgsAnnotationItem *item)
Attempts to update the widget to show the properties for the specified item.
Definition: qgsannotationitemwidget.cpp:43
QgsAnnotationItem
Abstract base class for annotation items which are drawn with QgsAnnotationLayers.
Definition: qgsannotationitem.h:42
QgsAnnotationPointTextItem
An annotation item which renders a text string at a point location.
Definition: qgsannotationpointtextitem.h:33