QGIS API Documentation 3.37.0-Master (fdefdf9c27f)
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
25class QToolButton;
26class QgsMessageBar;
28
40class 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; // cppcheck-suppress pureVirtualCall
115
119 virtual QString selectFileTitle() const = 0; // cppcheck-suppress pureVirtualCall
120
124 virtual QString fileFromUrlTitle() const = 0; // cppcheck-suppress pureVirtualCall
125
129 virtual QString fileFromUrlText() const = 0; // cppcheck-suppress pureVirtualCall
130
134 virtual QString embedFileTitle() const = 0; // cppcheck-suppress pureVirtualCall
135
139 virtual QString extractFileTitle() const = 0; // cppcheck-suppress pureVirtualCall
140
144 virtual QString defaultSettingsKey() const = 0; // cppcheck-suppress pureVirtualCall
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
199 {
203 };
204
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
231 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
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.
A line edit widget with toolbutton for setting an animated raster image path.
QgsAnimatedImageSourceLineEdit(QWidget *parent=nullptr)
Constructor for QgsAnimatedImageSourceLineEdit, with the specified parent widget.
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.
@ AnimatedImage
Animated image (since QGIS 3.26)
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:213