QGIS API Documentation 3.41.0-Master (cea29feecf2)
Loading...
Searching...
No Matches
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:
49 QgsAbstractFileContentSourceLineEdit( QWidget *parent SIP_TRANSFERTHIS = nullptr );
50
56 void setMessageBar( QgsMessageBar *bar );
57
62 QgsMessageBar *messageBar() const;
63
69 QString source() const;
70
75 void setLastPathSettingsKey( const QString &key );
76
81 QgsPropertyOverrideButton *propertyOverrideToolButton() const { return mPropertyOverrideButton; }
82
87 void setPropertyOverrideToolButtonVisible( bool visible );
88
89 public slots:
90
96 void setSource( const QString &source );
97
98 signals:
99
103 void sourceChanged( const QString &source );
104
105 private:
106#ifndef SIP_RUN
108
112 virtual QString fileFilter() const = 0; // cppcheck-suppress pureVirtualCall
113
117 virtual QString selectFileTitle() const = 0; // cppcheck-suppress pureVirtualCall
118
122 virtual QString fileFromUrlTitle() const = 0; // cppcheck-suppress pureVirtualCall
123
127 virtual QString fileFromUrlText() const = 0; // cppcheck-suppress pureVirtualCall
128
132 virtual QString embedFileTitle() const = 0; // cppcheck-suppress pureVirtualCall
133
137 virtual QString extractFileTitle() const = 0; // cppcheck-suppress pureVirtualCall
138
142 virtual QString defaultSettingsKey() const = 0; // cppcheck-suppress pureVirtualCall
143
145#endif
146
147 private slots:
148 void selectFile();
149 void selectUrl();
150 void embedFile();
151 void extractFile();
152 void mFileLineEdit_textEdited( const QString &text );
153
154 private:
155 enum Mode
156 {
157 ModeFile,
158 ModeBase64,
159 };
160
161 Mode mMode = ModeFile;
162 bool mPropertyOverrideButtonVisible = false;
163
164 QgsFilterLineEdit *mFileLineEdit = nullptr;
165 QToolButton *mFileToolButton = nullptr;
166 QgsPropertyOverrideButton *mPropertyOverrideButton = nullptr;
167 QString mLastPathKey;
168 QString mBase64;
169 QgsMessageBar *mMessageBar = nullptr;
170
171 QString defaultPath() const;
172 QString settingsKey() const;
173};
174
175
186{
187 Q_OBJECT
188 public:
198
205 {}
206
208 void setMode( Format format ) { mFormat = format; }
209
210 protected:
214 QgsPictureSourceLineEditBase( Format format, QWidget *parent SIP_TRANSFERTHIS = nullptr )
216 , mFormat( format )
217 {}
218
219 private:
220 Format mFormat = Svg;
221
222#ifndef SIP_RUN
224 QString fileFilter() const override;
225 QString selectFileTitle() const override;
226 QString fileFromUrlTitle() const override;
227 QString fileFromUrlText() const override;
228 QString embedFileTitle() const override;
229 QString extractFileTitle() const override;
230 QString defaultSettingsKey() const override;
232#endif
233};
234
235
248{
249 Q_OBJECT
250 public:
254 QgsSvgSourceLineEdit( QWidget *parent SIP_TRANSFERTHIS = nullptr )
255 : QgsPictureSourceLineEditBase( Svg, parent )
256 {}
257};
258
271{
272 Q_OBJECT
273 public:
277 QgsImageSourceLineEdit( QWidget *parent SIP_TRANSFERTHIS = nullptr )
278 : QgsPictureSourceLineEditBase( Image, parent )
279 {}
280};
281
282
295{
296 Q_OBJECT
297 public:
302 : QgsPictureSourceLineEditBase( AnimatedImage, parent )
303 {}
304};
305
306#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.
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:213