QGIS API Documentation 4.1.0-Master (376402f9aeb)
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
22#include <QString>
23#include <QWidget>
24
25class QgsFileDropEdit;
26class QToolButton;
27class QgsMessageBar;
29
41class GUI_EXPORT QgsAbstractFileContentSourceLineEdit : public QWidget SIP_ABSTRACT
42{
43 Q_OBJECT
44 Q_PROPERTY( QString source READ source WRITE setSource NOTIFY sourceChanged )
45
46 public:
50 QgsAbstractFileContentSourceLineEdit( QWidget *parent SIP_TRANSFERTHIS = nullptr );
51
57 void setMessageBar( QgsMessageBar *bar );
58
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#ifndef SIP_RUN
109
113 virtual QString fileFilter( bool includeAllFiles ) const = 0; // cppcheck-suppress pureVirtualCall
114
118 virtual QString selectFileTitle() const = 0; // cppcheck-suppress pureVirtualCall
119
123 virtual QString fileFromUrlTitle() const = 0; // cppcheck-suppress pureVirtualCall
124
128 virtual QString fileFromUrlText() const = 0; // cppcheck-suppress pureVirtualCall
129
133 virtual QString embedFileTitle() const = 0; // cppcheck-suppress pureVirtualCall
134
138 virtual QString extractFileTitle() const = 0; // cppcheck-suppress pureVirtualCall
139
143 virtual QString defaultSettingsKey() const = 0; // cppcheck-suppress pureVirtualCall
144
146#endif
147
148 protected:
149 SIP_SKIP QgsFileDropEdit *mFileLineEdit = nullptr;
150
151 private slots:
152 void selectFile();
153 void selectUrl();
154 void embedFile();
155 void extractFile();
156 void mFileLineEdit_textEdited( const QString &text );
157
158 private:
159 enum Mode
160 {
161 ModeFile,
162 ModeBase64,
163 };
164
165 Mode mMode = ModeFile;
166 bool mPropertyOverrideButtonVisible = false;
167
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
189{
190 Q_OBJECT
191 public:
201
208 {}
209
211 void setMode( Format format ) { mFormat = format; }
212
213 protected:
217 QgsPictureSourceLineEditBase( Format format, QWidget *parent SIP_TRANSFERTHIS = nullptr );
218
219 private:
220 Format mFormat = Svg;
221
222#ifndef SIP_RUN
224 QString fileFilter( bool includeAllFiles ) const final;
225 QString selectFileTitle() const final;
226 QString fileFromUrlTitle() const final;
227 QString fileFromUrlText() const final;
228 QString embedFileTitle() const final;
229 QString extractFileTitle() const final;
230 QString defaultSettingsKey() const final;
232#endif
233};
234
235
248{
249 Q_OBJECT
250 public:
254 QgsSvgSourceLineEdit( QWidget *parent SIP_TRANSFERTHIS = nullptr )
256 {}
257};
258
271{
272 Q_OBJECT
273 public:
277 QgsImageSourceLineEdit( QWidget *parent SIP_TRANSFERTHIS = nullptr )
279 {}
280};
281
282
295{
296 Q_OBJECT
297 public:
304};
305
306#endif // QGSFILECONTENTSOURCELINEEDIT_H
void setLastPathSettingsKey(const QString &key)
Sets a specific settings key to use when storing the last used path for the file source.
void sourceChanged(const QString &source)
Emitted whenever the file source is changed in the widget.
void setMessageBar(QgsMessageBar *bar)
Sets the message bar associated with the widget.
QgsMessageBar * messageBar() const
Returns the message bar associated with the widget.
QgsPropertyOverrideButton * propertyOverrideToolButton() const
Returns the property override tool button.
void setSource(const QString &source)
Sets a new source to show in the widget.
QgsAbstractFileContentSourceLineEdit(QWidget *parent=nullptr)
Constructor for QgsAbstractFileContentSourceLineEdit, with the specified parent widget.
QgsAnimatedImageSourceLineEdit(QWidget *parent=nullptr)
Constructor for QgsAnimatedImageSourceLineEdit, with the specified parent widget.
QgsImageSourceLineEdit(QWidget *parent=nullptr)
Constructor for QgsImageSourceLineEdit, with the specified parent widget.
A bar for displaying non-blocking messages to the user.
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.
QgsSvgSourceLineEdit(QWidget *parent=nullptr)
Constructor for QgsSvgSourceLineEdit, with the specified parent widget.
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:52
#define SIP_SKIP
Definition qgis_sip.h:133
#define SIP_ABSTRACT
Definition qgis_sip.h:220