20 #include <QGridLayout>
21 #include <QFileDialog>
29 , mPhotoLabel( nullptr )
30 , mPhotoPixmapLabel( nullptr )
31 , mLineEdit( nullptr )
39 void QgsPhotoWidgetWrapper::selectFileName()
58 void QgsPhotoWidgetWrapper::loadPixmap(
const QString& fileName )
74 if (
QUrl( fileName ).isRelative() )
80 mWebView->setUrl( filePath );
85 if ( !pm.isNull() && mPhotoLabel )
88 if ( size.width() == 0 && size.height() > 0 )
90 size.setWidth( size.height() * pm.size().width() / pm.size().height() );
92 else if ( size.width() > 0 && size.height() == 0 )
94 size.setHeight( size.width() * pm.size().height() / pm.size().width() );
97 if ( mPhotoPixmapLabel )
101 if ( size.width() != 0 || size.height() != 0 )
110 pm = pm.scaled( size, Qt::KeepAspectRatio, Qt::SmoothTransformation );
120 void QgsPhotoWidgetWrapper::clearPicture()
124 mPhotoLabel->
clear();
127 if ( mPhotoPixmapLabel )
143 v = mLineEdit->
text();
174 mLineEdit = qobject_cast<
QLineEdit*>( editor );
176 mWebView = qobject_cast<
QWebView*>( editor );
206 connect( mButton, SIGNAL( clicked() ),
this, SLOT( selectFileName() ) );
225 return mPhotoLabel || mLineEdit || mButton || mWebView;
227 return mPhotoLabel || mLineEdit || mButton;
QString toNativeSeparators(const QString &pathName)
QString relativeFilePath(const QString &fileName) const
void setContentsMargins(int left, int top, int right, int bottom)
void setPixmap(const QPixmap &)
void setPixmap(const QPixmap &)
QString filePath(const QString &fileName) const
QString tr(const char *sourceText, const char *disambiguation, int n)
void setObjectName(const QString &name)
bool startsWith(const QString &s, Qt::CaseSensitivity cs) const
Lineedit with builtin clear button.
void setMargin(int margin)
bool blockSignals(bool block)
QString cleanPath(const QString &path)
QVariant value(const QString &key, const QVariant &defaultValue) const
static QgsProject * instance()
access to canonical QgsProject instance
QString getOpenFileName(QWidget *parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedFilter, QFlags< QFileDialog::Option > options)
void setNullValue(const QString &nullValue)
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
Represents a vector layer which manages a vector based data sets.
The QgsPixmapLabel class shows a pixmap and adjusts its size to the space given to the widget by the ...
T findChild(const QString &name) const