QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
qgsfilecontentsourcelineedit.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsfilecontentsourcelineedit.h
3  ---------------------
4  begin : July 2018
5  copyright : (C) 2018 by 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 QGSFILECONTENTSOURCELINEEDIT_H
17 #define QGSFILECONTENTSOURCELINEEDIT_H
18 
19 #include "qgis_gui.h"
20 #include "qgis_sip.h"
21 #include <QWidget>
22 #include <QString>
23 
24 class QgsFilterLineEdit;
25 class QToolButton;
26 class QgsMessageBar;
28 
40 class GUI_EXPORT QgsAbstractFileContentSourceLineEdit : public QWidget SIP_ABSTRACT
41 {
42  Q_OBJECT
43  Q_PROPERTY( QString source READ source WRITE setSource NOTIFY sourceChanged )
44 
45  public:
46 
50  QgsAbstractFileContentSourceLineEdit( QWidget *parent SIP_TRANSFERTHIS = nullptr );
51 
57  void setMessageBar( QgsMessageBar *bar );
58 
63  QgsMessageBar *messageBar() const;
64 
70  QString source() const;
71 
76  void setLastPathSettingsKey( const QString &key );
77 
82  QgsPropertyOverrideButton *propertyOverrideToolButton() const {return mPropertyOverrideButton;}
83 
88  void setPropertyOverrideToolButtonVisible( bool visible );
89 
90  public slots:
91 
97  void setSource( const QString &source );
98 
99  signals:
100 
104  void sourceChanged( const QString &source );
105 
106  private:
107 
108 #ifndef SIP_RUN
109 
114  virtual QString fileFilter() const = 0;
115 
119  virtual QString selectFileTitle() const = 0;
120 
124  virtual QString fileFromUrlTitle() const = 0;
125 
129  virtual QString fileFromUrlText() const = 0;
130 
134  virtual QString embedFileTitle() const = 0;
135 
139  virtual QString extractFileTitle() const = 0;
140 
144  virtual QString defaultSettingsKey() const = 0;
145 
147 #endif
148 
149  private slots:
150  void selectFile();
151  void selectUrl();
152  void embedFile();
153  void extractFile();
154  void mFileLineEdit_textEdited( const QString &text );
155 
156  private:
157 
158  enum Mode
159  {
160  ModeFile,
161  ModeBase64,
162  };
163 
164  Mode mMode = ModeFile;
165  bool mPropertyOverrideButtonVisible = false;
166 
167  QgsFilterLineEdit *mFileLineEdit = nullptr;
168  QToolButton *mFileToolButton = nullptr;
169  QgsPropertyOverrideButton *mPropertyOverrideButton = nullptr;
170  QString mLastPathKey;
171  QString mBase64;
172  QgsMessageBar *mMessageBar = nullptr;
173 
174  QString defaultPath() const;
175  QString settingsKey() const;
176 
177 };
178 
179 
180 
191 {
192  Q_OBJECT
193  public:
194 
198  enum Format
199  {
200  Svg,
203  };
204 
209  QgsPictureSourceLineEditBase( QWidget *parent SIP_TRANSFERTHIS = nullptr )
211  {}
212 
214  void setMode( Format format ) {mFormat = format;}
215 
216  protected:
217 
221  QgsPictureSourceLineEditBase( Format format, QWidget *parent SIP_TRANSFERTHIS = nullptr )
223  , mFormat( format )
224  {}
225 
226  private:
227  Format mFormat = Svg;
228 
229 #ifndef SIP_RUN
230  QString fileFilter() const override;
232  QString selectFileTitle() const override;
233  QString fileFromUrlTitle() const override;
234  QString fileFromUrlText() const override;
235  QString embedFileTitle() const override;
236  QString extractFileTitle() const override;
237  QString defaultSettingsKey() const override;
239 #endif
240 };
241 
242 
255 {
256  Q_OBJECT
257  public:
258 
262  QgsSvgSourceLineEdit( QWidget *parent SIP_TRANSFERTHIS = nullptr )
263  : QgsPictureSourceLineEditBase( Svg, parent )
264  {}
265 };
266 
279 {
280  Q_OBJECT
281  public:
282 
286  QgsImageSourceLineEdit( QWidget *parent SIP_TRANSFERTHIS = nullptr )
287  : QgsPictureSourceLineEditBase( Image, parent )
288  {}
289 };
290 
291 
304 {
305  Q_OBJECT
306  public:
307 
312  : QgsPictureSourceLineEditBase( AnimatedImage, parent )
313  {}
314 };
315 
316 #endif // QGSFILECONTENTSOURCELINEEDIT_H
QgsAnimatedImageSourceLineEdit
A line edit widget with toolbutton for setting an animated raster image path.
Definition: qgsfilecontentsourcelineedit.h:303
QgsFilterLineEdit
QLineEdit subclass with built in support for clearing the widget's value and handling custom null val...
Definition: qgsfilterlineedit.h:39
QgsPictureSourceLineEditBase::setMode
void setMode(Format format)
Defines the mode of the source line edit.
Definition: qgsfilecontentsourcelineedit.h:214
QgsPictureSourceLineEditBase::QgsPictureSourceLineEditBase
QgsPictureSourceLineEditBase(QWidget *parent=nullptr)
Constructor for QgsImageSourceLineEdit, with the specified parent widget.
Definition: qgsfilecontentsourcelineedit.h:209
QgsSvgSourceLineEdit::QgsSvgSourceLineEdit
QgsSvgSourceLineEdit(QWidget *parent=nullptr)
Constructor for QgsSvgSourceLineEdit, with the specified parent widget.
Definition: qgsfilecontentsourcelineedit.h:262
QgsPropertyOverrideButton
A button for controlling property overrides which may apply to a widget.
Definition: qgspropertyoverridebutton.h:50
QgsPictureSourceLineEditBase::AnimatedImage
@ AnimatedImage
Animated image (since QGIS 3.26)
Definition: qgsfilecontentsourcelineedit.h:202
QgsPictureSourceLineEditBase::Svg
@ Svg
SVG image.
Definition: qgsfilecontentsourcelineedit.h:200
QgsAbstractFileContentSourceLineEdit
Abstract base class for a widgets which allows users to select content from a file,...
Definition: qgsfilecontentsourcelineedit.h:40
QgsPictureSourceLineEditBase::Image
@ Image
Raster image.
Definition: qgsfilecontentsourcelineedit.h:201
qgis_sip.h
QgsImageSourceLineEdit::QgsImageSourceLineEdit
QgsImageSourceLineEdit(QWidget *parent=nullptr)
Constructor for QgsImageSourceLineEdit, with the specified parent widget.
Definition: qgsfilecontentsourcelineedit.h:286
QgsMessageBar
A bar for displaying non-blocking messages to the user.
Definition: qgsmessagebar.h:60
QgsPictureSourceLineEditBase::QgsPictureSourceLineEditBase
QgsPictureSourceLineEditBase(Format format, QWidget *parent=nullptr)
Constructor for QgsImageSourceLineEdit, with the specified parent widget.
Definition: qgsfilecontentsourcelineedit.h:221
QgsPictureSourceLineEditBase
A line edit widget with toolbutton for setting a raster image path.
Definition: qgsfilecontentsourcelineedit.h:190
QgsAnimatedImageSourceLineEdit::QgsAnimatedImageSourceLineEdit
QgsAnimatedImageSourceLineEdit(QWidget *parent=nullptr)
Constructor for QgsAnimatedImageSourceLineEdit, with the specified parent widget.
Definition: qgsfilecontentsourcelineedit.h:311
QgsPictureSourceLineEditBase::Format
Format
Format of source image.
Definition: qgsfilecontentsourcelineedit.h:198
QgsSvgSourceLineEdit
A line edit widget with toolbutton for setting an SVG image path.
Definition: qgsfilecontentsourcelineedit.h:254
QgsImageSourceLineEdit
A line edit widget with toolbutton for setting a raster image path.
Definition: qgsfilecontentsourcelineedit.h:278
QgsAbstractFileContentSourceLineEdit::propertyOverrideToolButton
QgsPropertyOverrideButton * propertyOverrideToolButton() const
Returns the property override tool button.
Definition: qgsfilecontentsourcelineedit.h:82
SIP_TRANSFERTHIS
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53
SIP_ABSTRACT
#define SIP_ABSTRACT
Definition: qgis_sip.h:208