QGIS API Documentation  3.22.4-Białowieża (ce8e65e95e)
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
110 
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,
202  };
203 
208  QgsPictureSourceLineEditBase( QWidget *parent SIP_TRANSFERTHIS = nullptr )
210  {}
211 
213  void setMode( Format format ) {mFormat = format;}
214 
215  protected:
216 
220  QgsPictureSourceLineEditBase( Format format, QWidget *parent SIP_TRANSFERTHIS = nullptr )
222  , mFormat( format )
223  {}
224 
225  private:
226  Format mFormat = Svg;
227 
228 #ifndef SIP_RUN
230  QString fileFilter() const override;
231  QString selectFileTitle() const override;
232  QString fileFromUrlTitle() const override;
233  QString fileFromUrlText() const override;
234  QString embedFileTitle() const override;
235  QString extractFileTitle() const override;
236  QString defaultSettingsKey() const override;
238 #endif
239 };
240 
241 
254 {
255  Q_OBJECT
256  public:
257 
261  QgsSvgSourceLineEdit( QWidget *parent SIP_TRANSFERTHIS = nullptr )
262  : QgsPictureSourceLineEditBase( Svg, parent )
263  {}
264 };
265 
278 {
279  Q_OBJECT
280  public:
281 
285  QgsImageSourceLineEdit( QWidget *parent SIP_TRANSFERTHIS = nullptr )
286  : QgsPictureSourceLineEditBase( Image, parent )
287  {}
288 };
289 
290 #endif // QGSFILECONTENTSOURCELINEEDIT_H
Abstract base class for a widgets which allows users to select content from a file,...
void sourceChanged(const QString &source)
Emitted whenever the file source is changed in the widget.
QgsPropertyOverrideButton * propertyOverrideToolButton() const
Returns the property override tool button.
QLineEdit subclass with built in support for clearing the widget's value and handling custom null val...
A line edit widget with toolbutton for setting a raster image path.
QgsImageSourceLineEdit(QWidget *parent=nullptr)
Constructor for QgsImageSourceLineEdit, with the specified parent widget.
A bar for displaying non-blocking messages to the user.
Definition: qgsmessagebar.h:61
A line edit widget with toolbutton for setting a raster image path.
QgsPictureSourceLineEditBase(Format format, QWidget *parent=nullptr)
Constructor for QgsImageSourceLineEdit, with the specified parent widget.
void setMode(Format format)
Defines the mode of the source line edit.
QgsPictureSourceLineEditBase(QWidget *parent=nullptr)
Constructor for QgsImageSourceLineEdit, with the specified parent widget.
A button for controlling property overrides which may apply to a widget.
A line edit widget with toolbutton for setting an SVG image path.
QgsSvgSourceLineEdit(QWidget *parent=nullptr)
Constructor for QgsSvgSourceLineEdit, with the specified parent widget.
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53
#define SIP_ABSTRACT
Definition: qgis_sip.h:199