QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
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 
191 {
192  Q_OBJECT
193  public:
194 
198  QgsSvgSourceLineEdit( QWidget *parent SIP_TRANSFERTHIS = nullptr )
200  {}
201 
202  private:
203 
204 #ifndef SIP_RUN
205  QString fileFilter() const override;
207  QString selectFileTitle() const override;
208  QString fileFromUrlTitle() const override;
209  QString fileFromUrlText() const override;
210  QString embedFileTitle() const override;
211  QString extractFileTitle() const override;
212  QString defaultSettingsKey() const override;
214 #endif
215 };
216 
217 
230 {
231  Q_OBJECT
232  public:
233 
237  QgsImageSourceLineEdit( QWidget *parent SIP_TRANSFERTHIS = nullptr )
239  {}
240 
241  private:
242 #ifndef SIP_RUN
243  QString fileFilter() const override;
245  QString selectFileTitle() const override;
246  QString fileFromUrlTitle() const override;
247  QString fileFromUrlText() const override;
248  QString embedFileTitle() const override;
249  QString extractFileTitle() const override;
250  QString defaultSettingsKey() const override;
252 #endif
253 };
254 
255 #endif // QGSFILECONTENTSOURCELINEEDIT_H
QgsFilterLineEdit
QLineEdit subclass with built in support for clearing the widget's value and handling custom null val...
Definition: qgsfilterlineedit.h:40
QgsSvgSourceLineEdit::QgsSvgSourceLineEdit
QgsSvgSourceLineEdit(QWidget *parent=nullptr)
Constructor for QgsSvgSourceLineEdit, with the specified parent widget.
Definition: qgsfilecontentsourcelineedit.h:198
QgsPropertyOverrideButton
A button for controlling property overrides which may apply to a widget.
Definition: qgspropertyoverridebutton.h:51
QgsAbstractFileContentSourceLineEdit
Abstract base class for a widgets which allows users to select content from a file,...
Definition: qgsfilecontentsourcelineedit.h:41
qgis_sip.h
QgsImageSourceLineEdit::QgsImageSourceLineEdit
QgsImageSourceLineEdit(QWidget *parent=nullptr)
Constructor for QgsImageSourceLineEdit, with the specified parent widget.
Definition: qgsfilecontentsourcelineedit.h:237
QgsMessageBar
A bar for displaying non-blocking messages to the user.
Definition: qgsmessagebar.h:61
QgsSvgSourceLineEdit
A line edit widget with toolbutton for setting an SVG image path.
Definition: qgsfilecontentsourcelineedit.h:191
QgsImageSourceLineEdit
A line edit widget with toolbutton for setting a raster image path.
Definition: qgsfilecontentsourcelineedit.h:230
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
QgsAbstractFileContentSourceLineEdit::sourceChanged
void sourceChanged(const QString &source)
Emitted whenever the file source is changed in the widget.
SIP_ABSTRACT
#define SIP_ABSTRACT
Definition: qgis_sip.h:199