mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-28 00:17:30 -05:00
f
This commit is contained in:
parent
ae68549186
commit
493bdb1bf2
@ -7,6 +7,7 @@
|
|||||||
************************************************************************/
|
************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class QgsQmlWidgetWrapper : QgsWidgetWrapper
|
class QgsQmlWidgetWrapper : QgsWidgetWrapper
|
||||||
{
|
{
|
||||||
%Docstring
|
%Docstring
|
||||||
@ -46,6 +47,7 @@ the Free Software Foundation; either version 2 of the License, or *
|
|||||||
|
|
||||||
virtual void setFeature( const QgsFeature &feature );
|
virtual void setFeature( const QgsFeature &feature );
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
|
@ -733,6 +733,18 @@ SET(QGIS_GUI_MOC_HDRS
|
|||||||
processing/qgsprocessingwidgetwrapper.h
|
processing/qgsprocessingwidgetwrapper.h
|
||||||
processing/qgsprocessingwidgetwrapperimpl.h
|
processing/qgsprocessingwidgetwrapperimpl.h
|
||||||
)
|
)
|
||||||
|
FIND_PACKAGE(Qt5Qml REQUIRED)
|
||||||
|
FIND_PACKAGE(Qt5QuickWidgets REQUIRED)
|
||||||
|
|
||||||
|
IF(Qt5Qml_FOUND)
|
||||||
|
ADD_DEFINITIONS(-DWITH_QML)
|
||||||
|
SET(QGIS_GUI_MOC_HDRS
|
||||||
|
${QGIS_GUI_MOC_HDRS}
|
||||||
|
editorwidgets/qgsqmlwidgetwrapper.h
|
||||||
|
qgsqmlwidget.h
|
||||||
|
)
|
||||||
|
ENDIF(Qt5Qml_FOUND)
|
||||||
|
|
||||||
SET_PROPERTY(GLOBAL PROPERTY QGIS_GUI_MOC_HDRS ${QGIS_GUI_MOC_HDRS})
|
SET_PROPERTY(GLOBAL PROPERTY QGIS_GUI_MOC_HDRS ${QGIS_GUI_MOC_HDRS})
|
||||||
|
|
||||||
QT5_WRAP_CPP(QGIS_GUI_MOC_SRCS ${QGIS_GUI_MOC_HDRS})
|
QT5_WRAP_CPP(QGIS_GUI_MOC_SRCS ${QGIS_GUI_MOC_HDRS})
|
||||||
@ -839,22 +851,13 @@ SET(QGIS_GUI_HDRS
|
|||||||
symbology/qgssymbolwidgetcontext.h
|
symbology/qgssymbolwidgetcontext.h
|
||||||
)
|
)
|
||||||
|
|
||||||
Find_Package(Qt5Qml)
|
|
||||||
|
|
||||||
IF(Qt5Qml_FOUND)
|
IF(Qt5Qml_FOUND)
|
||||||
ADD_DEFINITIONS(-DWITH_QML)
|
|
||||||
SET(QGIS_GUI_MOC_HDRS
|
|
||||||
${QGIS_GUI_MOC_HDRS}
|
|
||||||
editorwidgets/qgsqmlwidgetwrapper.h
|
|
||||||
qgsqmlwidget.h
|
|
||||||
)
|
|
||||||
|
|
||||||
SET(QGIS_GUI_SRCS
|
SET(QGIS_GUI_SRCS
|
||||||
${QGIS_GUI_SRCS}
|
${QGIS_GUI_SRCS}
|
||||||
editorwidgets/qgsqmlwidgetwrapper.cpp
|
editorwidgets/qgsqmlwidgetwrapper.cpp
|
||||||
qgsqmlwidget.cpp
|
qgsqmlwidget.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
ENDIF(Qt5Qml_FOUND)
|
ENDIF(Qt5Qml_FOUND)
|
||||||
|
|
||||||
SET_PROPERTY(GLOBAL PROPERTY QGIS_GUI_HDRS ${QGIS_GUI_HDRS})
|
SET_PROPERTY(GLOBAL PROPERTY QGIS_GUI_HDRS ${QGIS_GUI_HDRS})
|
||||||
@ -1029,6 +1032,7 @@ TARGET_LINK_LIBRARIES(qgis_gui
|
|||||||
${Qt5UiTools_LIBRARIES}
|
${Qt5UiTools_LIBRARIES}
|
||||||
${QWT_LIBRARY}
|
${QWT_LIBRARY}
|
||||||
${QSCINTILLA_LIBRARY}
|
${QSCINTILLA_LIBRARY}
|
||||||
|
${Qt5QuickWidgets_LIBRARIES}
|
||||||
)
|
)
|
||||||
|
|
||||||
IF(ENABLE_MODELTEST)
|
IF(ENABLE_MODELTEST)
|
||||||
|
@ -14,9 +14,61 @@
|
|||||||
* *
|
* *
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
#include "qgsqmlwidgetwrapper.h"
|
#include "qgsqmlwidgetwrapper.h"
|
||||||
|
#include "qgsmessagelog.h"
|
||||||
|
#include <QtQuickWidgets/QQuickWidget>
|
||||||
|
|
||||||
QgsQmlWidgetWrapper::QgsQmlWidgetWrapper( QgsVectorLayer *layer, QWidget *editor, QWidget *parent )
|
QgsQmlWidgetWrapper::QgsQmlWidgetWrapper( QgsVectorLayer *layer, QWidget *editor, QWidget *parent )
|
||||||
: QgsWidgetWrapper( layer, editor, parent )
|
: QgsWidgetWrapper( layer, editor, parent )
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool QgsQmlWidgetWrapper::valid() const
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
QWidget *QgsQmlWidgetWrapper::createWidget( QWidget *parent )
|
||||||
|
{
|
||||||
|
return new QQuickWidget( parent );
|
||||||
|
}
|
||||||
|
|
||||||
|
void QgsQmlWidgetWrapper::initWidget( QWidget *editor )
|
||||||
|
{
|
||||||
|
QQuickWidget *quickWidget = qobject_cast<QQuickWidget *>( editor );
|
||||||
|
|
||||||
|
if ( !quickWidget )
|
||||||
|
return;
|
||||||
|
|
||||||
|
if ( !mQmlFile.open() )
|
||||||
|
{
|
||||||
|
QgsMessageLog::logMessage( tr( "Failed to open temporary QML file" ) );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString qmlCode = QStringLiteral(
|
||||||
|
"import QtQuick 2.0"
|
||||||
|
"import QtCharts 2.0"
|
||||||
|
""
|
||||||
|
"ChartView {"
|
||||||
|
" width: 600"
|
||||||
|
" height: 400"
|
||||||
|
""
|
||||||
|
" PieSeries {"
|
||||||
|
" id: pieSeries"
|
||||||
|
" PieSlice { label: \"outlet 1\"; value: attributes.outlet_1 }"
|
||||||
|
" PieSlice { label: \"outlet 2\"; value: attributes.outlet_2 }"
|
||||||
|
" PieSlice { label: \"outlet 3\"; value: attributes.outlet_3 }"
|
||||||
|
" PieSlice { label: \"outlet 4\"; value: attributes.outlet_4 }"
|
||||||
|
" }"
|
||||||
|
"}" );
|
||||||
|
|
||||||
|
mQmlFile.write( qmlCode.toUtf8() );
|
||||||
|
|
||||||
|
quickWidget->setSource( QUrl::fromLocalFile( mQmlFile.fileName() ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
void QgsQmlWidgetWrapper::setFeature( const QgsFeature &feature )
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
@ -17,9 +17,14 @@
|
|||||||
#define QGSQMLWIDGETWRAPPER_H
|
#define QGSQMLWIDGETWRAPPER_H
|
||||||
|
|
||||||
#include "qgswidgetwrapper.h"
|
#include "qgswidgetwrapper.h"
|
||||||
|
#include "qgis.h"
|
||||||
|
#include "qgis_gui.h"
|
||||||
|
|
||||||
|
|
||||||
class GUI_EXPORT QgsQmlWidgetWrapper : public QgsWidgetWrapper
|
class GUI_EXPORT QgsQmlWidgetWrapper : public QgsWidgetWrapper
|
||||||
{
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QgsQmlWidgetWrapper( QgsVectorLayer *layer, QWidget *editor, QWidget *parent );
|
QgsQmlWidgetWrapper( QgsVectorLayer *layer, QWidget *editor, QWidget *parent );
|
||||||
|
|
||||||
@ -32,6 +37,9 @@ class GUI_EXPORT QgsQmlWidgetWrapper : public QgsWidgetWrapper
|
|||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
void setFeature( const QgsFeature &feature ) override;
|
void setFeature( const QgsFeature &feature ) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
QTemporaryFile mQmlFile;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // QGSQMLWIDGETWRAPPER_H
|
#endif // QGSQMLWIDGETWRAPPER_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user